mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 22:55:23 +00:00
Bug 1245776 - part2: remove custom openInspector methods;r=gl
shared/test/head had custom methods to open the Computed & Rule view. They did not register any test actor and could be called several times in the same test. In order to reuse the openInspector method from inspector/test/head, the tests have been modified. We are moving from openRuleView() -> do rule view tests -> openComputedView() -> do computed view tests to openInspector() -> select rule view -> do rule view tests -> select computed view -> do computed view tests A bit more verbose for the tests themselves, but this will be useful when migrating the shared tests to using the testActor. MozReview-Commit-ID: 94cOqhPICyI --HG-- extra : rebase_source : f7892af19b78ecdbb759fb21d17920f0f6e0f4c6
This commit is contained in:
parent
fb695be31f
commit
8e94f2fd48
@ -12,22 +12,6 @@ registerCleanupFunction(() => {
|
||||
Services.prefs.clearUserPref("devtools.defaultColorUnit");
|
||||
});
|
||||
|
||||
/**
|
||||
* Open the toolbox, with the inspector tool visible, and the computed-view
|
||||
* sidebar tab selected.
|
||||
* @return a promise that resolves when the inspector is ready and the computed
|
||||
* view is visible and ready
|
||||
*/
|
||||
function openComputedView() {
|
||||
return openInspectorSidebarTab("computedview").then(({toolbox, inspector}) => {
|
||||
return {
|
||||
toolbox,
|
||||
inspector,
|
||||
view: inspector.computedview.view
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch the copy event on the given element
|
||||
*/
|
||||
|
@ -41,24 +41,6 @@ addTab = function(url) {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Open the toolbox, with the inspector tool visible, and the rule-view
|
||||
* sidebar tab selected.
|
||||
*
|
||||
* @return a promise that resolves when the inspector is ready and the rule
|
||||
* view is visible and ready
|
||||
*/
|
||||
function openRuleView() {
|
||||
return openInspectorSidebarTab("ruleview").then(data => {
|
||||
return {
|
||||
toolbox: data.toolbox,
|
||||
inspector: data.inspector,
|
||||
testActor: data.testActor,
|
||||
view: data.inspector.ruleview.view
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for a content -> chrome message on the message manager (the window
|
||||
* messagemanager is used).
|
||||
|
@ -11,31 +11,20 @@ const TEST_URI = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
const TEST_CASES = [
|
||||
{
|
||||
viewName: "RuleView",
|
||||
initializer: openRuleView
|
||||
},
|
||||
{
|
||||
viewName: "ComputedView",
|
||||
initializer: openComputedView
|
||||
}
|
||||
];
|
||||
|
||||
add_task(function* () {
|
||||
// Test is slow on Linux EC2 instances - Bug 1137765
|
||||
requestLongerTimeout(2);
|
||||
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
||||
|
||||
for (let test of TEST_CASES) {
|
||||
yield testView(test);
|
||||
}
|
||||
let {inspector} = yield openInspector();
|
||||
yield testView("ruleview", inspector);
|
||||
yield testView("computedview", inspector);
|
||||
});
|
||||
|
||||
function* testView({viewName, initializer}) {
|
||||
info("Testing " + viewName);
|
||||
function* testView(viewId, inspector) {
|
||||
info("Testing " + viewId);
|
||||
|
||||
let {inspector, view} = yield initializer();
|
||||
yield inspector.sidebar.select(viewId);
|
||||
let view = inspector[viewId].view;
|
||||
yield selectNode("div", inspector);
|
||||
|
||||
testIsColorValueNode(view);
|
||||
|
@ -19,6 +19,7 @@ add_task(function* () {
|
||||
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
||||
|
||||
let {inspector, view} = yield openRuleView();
|
||||
|
||||
yield testCopyToClipboard(inspector, view);
|
||||
yield testManualEdit(inspector, view);
|
||||
yield testColorPickerEdit(inspector, view);
|
||||
|
@ -39,24 +39,24 @@ add_task(function*() {
|
||||
|
||||
function* startTest() {
|
||||
info("Opening rule view");
|
||||
let ruleViewData = yield openRuleView();
|
||||
let {inspector, view} = yield openRuleView();
|
||||
|
||||
info("Test valid background image URL in rule view");
|
||||
yield testCopyUrlToClipboard(ruleViewData, "data-uri", ".valid-background", TEST_DATA_URI);
|
||||
yield testCopyUrlToClipboard(ruleViewData, "url", ".valid-background", TEST_DATA_URI);
|
||||
yield testCopyUrlToClipboard({view, inspector}, "data-uri", ".valid-background", TEST_DATA_URI);
|
||||
yield testCopyUrlToClipboard({view, inspector}, "url", ".valid-background", TEST_DATA_URI);
|
||||
info("Test invalid background image URL in rue view");
|
||||
yield testCopyUrlToClipboard(ruleViewData, "data-uri", ".invalid-background", ERROR_MESSAGE);
|
||||
yield testCopyUrlToClipboard(ruleViewData, "url", ".invalid-background", INVALID_IMAGE_URI);
|
||||
yield testCopyUrlToClipboard({view, inspector}, "data-uri", ".invalid-background", ERROR_MESSAGE);
|
||||
yield testCopyUrlToClipboard({view, inspector}, "url", ".invalid-background", INVALID_IMAGE_URI);
|
||||
|
||||
info("Opening computed view");
|
||||
let computedViewData = yield openComputedView();
|
||||
view = selectComputedView(inspector);
|
||||
|
||||
info("Test valid background image URL in computed view");
|
||||
yield testCopyUrlToClipboard(computedViewData, "data-uri", ".valid-background", TEST_DATA_URI);
|
||||
yield testCopyUrlToClipboard(computedViewData, "url", ".valid-background", TEST_DATA_URI);
|
||||
yield testCopyUrlToClipboard({view, inspector}, "data-uri", ".valid-background", TEST_DATA_URI);
|
||||
yield testCopyUrlToClipboard({view, inspector}, "url", ".valid-background", TEST_DATA_URI);
|
||||
info("Test invalid background image URL in computed view");
|
||||
yield testCopyUrlToClipboard(computedViewData, "data-uri", ".invalid-background", ERROR_MESSAGE);
|
||||
yield testCopyUrlToClipboard(computedViewData, "url", ".invalid-background", INVALID_IMAGE_URI);
|
||||
yield testCopyUrlToClipboard({view, inspector}, "data-uri", ".invalid-background", ERROR_MESSAGE);
|
||||
yield testCopyUrlToClipboard({view, inspector}, "url", ".invalid-background", INVALID_IMAGE_URI);
|
||||
}
|
||||
|
||||
function* testCopyUrlToClipboard({view, inspector}, type, selector, expected) {
|
||||
|
@ -27,7 +27,7 @@ add_task(function*() {
|
||||
yield addTab(TEST_URI_HTML);
|
||||
let target = getNode("#target");
|
||||
|
||||
let {inspector} = yield openRuleView();
|
||||
let {inspector} = yield openInspector();
|
||||
yield selectNode("#target", inspector);
|
||||
|
||||
info("Checking stylesheets");
|
||||
@ -36,7 +36,7 @@ add_task(function*() {
|
||||
info("Checking authored stylesheets");
|
||||
yield addTab(TEST_URI_AUTHOR);
|
||||
|
||||
({inspector} = yield openRuleView());
|
||||
({inspector} = yield openInspector());
|
||||
target = getNode("#target");
|
||||
yield selectNode("#target", inspector);
|
||||
yield checkSheets(target);
|
||||
@ -46,7 +46,7 @@ add_task(function*() {
|
||||
allowXUL();
|
||||
yield addTab(TEST_URI_XUL);
|
||||
|
||||
({inspector} = yield openRuleView());
|
||||
({inspector} = yield openInspector());
|
||||
target = getNode("#target");
|
||||
yield selectNode("#target", inspector);
|
||||
|
||||
|
@ -14,6 +14,7 @@ const TEST_URI = `
|
||||
add_task(function*() {
|
||||
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
||||
let {inspector, view} = yield openRuleView();
|
||||
|
||||
yield selectNode("#one", inspector);
|
||||
|
||||
is(getRuleViewPropertyValue(view, "element", "color"), "red",
|
||||
@ -25,7 +26,7 @@ add_task(function*() {
|
||||
|
||||
info("Switching to the computed-view");
|
||||
let onComputedViewReady = inspector.once("computed-view-refreshed");
|
||||
yield openComputedView();
|
||||
selectComputedView(inspector);
|
||||
yield onComputedViewReady;
|
||||
|
||||
ok(getComputedViewPropertyValue(cView, "color"), "#F00",
|
||||
|
@ -43,7 +43,7 @@ add_task(function*() {
|
||||
|
||||
info("Switching over to the computed-view");
|
||||
let onComputedViewReady = inspector.once("computed-view-refreshed");
|
||||
({view} = yield openComputedView());
|
||||
view = selectComputedView(inspector);
|
||||
yield onComputedViewReady;
|
||||
|
||||
info("Testing that the background-image computed style has a tooltip too");
|
||||
|
@ -17,7 +17,7 @@ add_task(function*() {
|
||||
yield testRuleView(view, inspector);
|
||||
|
||||
info("Testing computed view tooltip closes on new selection");
|
||||
({view} = yield openComputedView());
|
||||
view = selectComputedView(inspector);
|
||||
yield testComputedView(view, inspector);
|
||||
});
|
||||
|
||||
|
@ -25,7 +25,7 @@ add_task(function*() {
|
||||
|
||||
info("Opening the computed view");
|
||||
let onComputedViewReady = inspector.once("computed-view-refreshed");
|
||||
({inspector, view} = yield openComputedView());
|
||||
view = selectComputedView(inspector);
|
||||
yield onComputedViewReady;
|
||||
|
||||
yield testComputedView(view, inspector.selection.nodeFront);
|
||||
|
@ -25,25 +25,27 @@ add_task(function* () {
|
||||
yield addTab("data:text/html;charset=utf-8,background image tooltip test");
|
||||
content.document.body.innerHTML = PAGE_CONTENT;
|
||||
|
||||
yield testRuleViewUrls();
|
||||
yield testComputedViewUrls();
|
||||
let {inspector} = yield openInspector();
|
||||
yield testRuleViewUrls(inspector);
|
||||
yield testComputedViewUrls(inspector);
|
||||
});
|
||||
|
||||
function* testRuleViewUrls() {
|
||||
function* testRuleViewUrls(inspector) {
|
||||
info("Testing tooltips in the rule view");
|
||||
|
||||
let {view, inspector} = yield openRuleView();
|
||||
let view = selectRuleView(inspector);
|
||||
yield selectNode("h1", inspector);
|
||||
|
||||
let {valueSpan} = getRuleViewProperty(view, "h1", "background");
|
||||
yield performChecks(view, valueSpan);
|
||||
}
|
||||
|
||||
function* testComputedViewUrls() {
|
||||
function* testComputedViewUrls(inspector) {
|
||||
info("Testing tooltips in the computed view");
|
||||
|
||||
let {view, inspector} = yield openComputedView();
|
||||
yield inspector.once("computed-view-refreshed");
|
||||
let onComputedViewReady = inspector.once("computed-view-refreshed");
|
||||
let view = selectComputedView(inspector);
|
||||
yield onComputedViewReady;
|
||||
|
||||
let {valueSpan} = getComputedViewProperty(view, "background-image");
|
||||
|
||||
yield performChecks(view, valueSpan);
|
||||
|
@ -18,6 +18,7 @@ const TEST_URI = `
|
||||
add_task(function*() {
|
||||
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
||||
let {inspector, view} = yield openRuleView();
|
||||
|
||||
yield selectNode("#testElement", inspector);
|
||||
yield testRuleView(view, inspector.selection.nodeFront);
|
||||
});
|
||||
|
@ -20,6 +20,7 @@ const TYPE = "CssTransformHighlighter";
|
||||
add_task(function*() {
|
||||
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
||||
let {inspector, view} = yield openRuleView();
|
||||
|
||||
let overlay = view.highlighters;
|
||||
|
||||
ok(!overlay.highlighters[TYPE], "No highlighter exists in the rule-view");
|
||||
@ -32,7 +33,7 @@ add_task(function*() {
|
||||
"The same instance of highlighter is returned everytime in the rule-view");
|
||||
|
||||
let onComputedViewReady = inspector.once("computed-view-refreshed");
|
||||
let {view: cView} = yield openComputedView();
|
||||
let cView = selectComputedView(inspector);
|
||||
yield onComputedViewReady;
|
||||
overlay = cView.highlighters;
|
||||
|
||||
|
@ -38,7 +38,7 @@ add_task(function*() {
|
||||
yield onHighlighterShown;
|
||||
|
||||
let onComputedViewReady = inspector.once("computed-view-refreshed");
|
||||
let {view: cView} = yield openComputedView();
|
||||
let cView = selectComputedView(inspector);
|
||||
yield onComputedViewReady;
|
||||
hs = cView.highlighters;
|
||||
|
||||
|
@ -39,8 +39,9 @@ registerCleanupFunction(() => {
|
||||
*
|
||||
* add_task(function*() {
|
||||
* yield addTab(TEST_URI);
|
||||
* let {toolbox, inspector, view} = yield openComputedView();
|
||||
*
|
||||
* let {toolbox, inspector, view} = yield openInspector();
|
||||
* inspector.sidebar.select(viewId);
|
||||
* let view = inspector[viewId].view;
|
||||
* yield selectNode("#test", inspector);
|
||||
* yield someAsyncTestFunction(view);
|
||||
* });
|
||||
@ -85,104 +86,6 @@ addTab = function(url) {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Open the toolbox, with the inspector tool visible.
|
||||
*
|
||||
* @return a promise that resolves when the inspector is ready
|
||||
*/
|
||||
var openInspector = Task.async(function*() {
|
||||
info("Opening the inspector");
|
||||
let target = TargetFactory.forTab(gBrowser.selectedTab);
|
||||
|
||||
let inspector, toolbox;
|
||||
|
||||
// Checking if the toolbox and the inspector are already loaded
|
||||
// The inspector-updated event should only be waited for if the inspector
|
||||
// isn't loaded yet
|
||||
toolbox = gDevTools.getToolbox(target);
|
||||
if (toolbox) {
|
||||
inspector = toolbox.getPanel("inspector");
|
||||
if (inspector) {
|
||||
info("Toolbox and inspector already open");
|
||||
return {
|
||||
toolbox: toolbox,
|
||||
inspector: inspector
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
info("Opening the toolbox");
|
||||
toolbox = yield gDevTools.showToolbox(target, "inspector");
|
||||
yield waitForToolboxFrameFocus(toolbox);
|
||||
inspector = toolbox.getPanel("inspector");
|
||||
|
||||
info("Waiting for the inspector to update");
|
||||
if (inspector._updateProgress) {
|
||||
yield inspector.once("inspector-updated");
|
||||
}
|
||||
|
||||
return {
|
||||
toolbox: toolbox,
|
||||
inspector: inspector
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Wait for the toolbox frame to receive focus after it loads
|
||||
*
|
||||
* @param {Toolbox} toolbox
|
||||
* @return a promise that resolves when focus has been received
|
||||
*/
|
||||
function waitForToolboxFrameFocus(toolbox) {
|
||||
info("Making sure that the toolbox's frame is focused");
|
||||
let def = promise.defer();
|
||||
let win = toolbox.frame.contentWindow;
|
||||
waitForFocus(def.resolve, win);
|
||||
return def.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the toolbox, with the inspector tool visible, and the sidebar that
|
||||
* corresponds to the given id selected
|
||||
*
|
||||
* @return a promise that resolves when the inspector is ready and the sidebar
|
||||
* view is visible and ready
|
||||
*/
|
||||
var openInspectorSideBar = Task.async(function*(id) {
|
||||
let {toolbox, inspector} = yield openInspector();
|
||||
|
||||
info("Selecting the " + id + " sidebar");
|
||||
inspector.sidebar.select(id);
|
||||
|
||||
return {
|
||||
toolbox: toolbox,
|
||||
inspector: inspector,
|
||||
view: inspector[id].view
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Open the toolbox, with the inspector tool visible, and the computed-view
|
||||
* sidebar tab selected.
|
||||
*
|
||||
* @return a promise that resolves when the inspector is ready and the computed
|
||||
* view is visible and ready
|
||||
*/
|
||||
function openComputedView() {
|
||||
return openInspectorSideBar("computedview");
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the toolbox, with the inspector tool visible, and the rule-view
|
||||
* sidebar tab selected.
|
||||
*
|
||||
* @return a promise that resolves when the inspector is ready and the rule
|
||||
* view is visible and ready
|
||||
*/
|
||||
function openRuleView() {
|
||||
return openInspectorSideBar("ruleview");
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for a content -> chrome message on the message manager (the window
|
||||
* messagemanager is used).
|
||||
|
@ -224,12 +224,13 @@ var clickOnInspectMenuItem = Task.async(function*(testActor, selector) {
|
||||
/**
|
||||
* Open the toolbox, with the inspector tool visible, and the one of the sidebar
|
||||
* tabs selected.
|
||||
* @param {String} id The ID of the sidebar tab to be opened
|
||||
* @param {String} hostType Optional hostType, as defined in Toolbox.HostType
|
||||
*
|
||||
* @param {String} id
|
||||
* The ID of the sidebar tab to be opened
|
||||
* @return a promise that resolves when the inspector is ready and the tab is
|
||||
* visible and ready
|
||||
*/
|
||||
var openInspectorSidebarTab = Task.async(function*(id, hostType) {
|
||||
var openInspectorSidebarTab = Task.async(function* (id) {
|
||||
let {toolbox, inspector, testActor} = yield openInspector();
|
||||
|
||||
info("Selecting the " + id + " sidebar");
|
||||
@ -242,6 +243,66 @@ var openInspectorSidebarTab = Task.async(function*(id, hostType) {
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Open the toolbox, with the inspector tool visible, and the rule-view
|
||||
* sidebar tab selected.
|
||||
*
|
||||
* @return a promise that resolves when the inspector is ready and the rule view
|
||||
* is visible and ready
|
||||
*/
|
||||
function openRuleView() {
|
||||
return openInspectorSidebarTab("ruleview").then(data => {
|
||||
return {
|
||||
toolbox: data.toolbox,
|
||||
inspector: data.inspector,
|
||||
testActor: data.testActor,
|
||||
view: data.inspector.ruleview.view
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the toolbox, with the inspector tool visible, and the computed-view
|
||||
* sidebar tab selected.
|
||||
*
|
||||
* @return a promise that resolves when the inspector is ready and the computed
|
||||
* view is visible and ready
|
||||
*/
|
||||
function openComputedView() {
|
||||
return openInspectorSidebarTab("computedview").then(data => {
|
||||
return {
|
||||
toolbox: data.toolbox,
|
||||
inspector: data.inspector,
|
||||
testActor: data.testActor,
|
||||
view: data.inspector.computedview.view
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the rule view sidebar tab on an already opened inspector panel.
|
||||
*
|
||||
* @param {InspectorPanel} inspector
|
||||
* The opened inspector panel
|
||||
* @return {CssRuleView} the rule view
|
||||
*/
|
||||
function selectRuleView(inspector) {
|
||||
inspector.sidebar.select("ruleview");
|
||||
return inspector.ruleview.view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the computed view sidebar tab on an already opened inspector panel.
|
||||
*
|
||||
* @param {InspectorPanel} inspector
|
||||
* The opened inspector panel
|
||||
* @return {CssComputedView} the computed view
|
||||
*/
|
||||
function selectComputedView(inspector) {
|
||||
inspector.sidebar.select("computedview");
|
||||
return inspector.computedview.view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the NodeFront for a node that matches a given css selector, via the
|
||||
* protocol.
|
||||
|
Loading…
Reference in New Issue
Block a user