Bug 1244120 - Enable browser_rules_content_02.js with e10s; r=bgrins

Extracted a shared helper to open the browser context menu and choose
the 'inspect element' item. This helper works with e10s.
Adapted it a little bit so it waits for the right events in order to
make sure the inspector is ready.

This also involved modifying inspectNode in nsContextMenu.js to make it
wait until the node was selected and the node was ready.

Used this in browser_inspector_initialization.js,
browser_rules_content_02.js and browser_markup_keybindings_04.js

Also removed a now useless inspector-updated event that was trigger from
the animation-inspector panel in some situation. This was left behind
from a long time ago but didn't serve any purpose anymore.

MozReview-Commit-ID: 5bFHxxrwxhL

--HG--
extra : rebase_source : cb30c7e47605f59674f2344dba10af814172333d
This commit is contained in:
Patrick Brosset 2016-02-22 10:02:54 +01:00
Родитель 0739f5ba4b
Коммит ce1b99b254
9 изменённых файлов: 57 добавлений и 84 удалений

Просмотреть файл

@ -564,12 +564,18 @@ nsContextMenu.prototype = {
LoginHelper.openPasswordManager(window, gContextMenuContentData.documentURIObject.host);
},
inspectNode: function CM_inspectNode() {
inspectNode: function() {
let {devtools} = Cu.import("resource://devtools/shared/Loader.jsm", {});
let gBrowser = this.browser.ownerDocument.defaultView.gBrowser;
let tt = devtools.TargetFactory.forTab(gBrowser.selectedTab);
return gDevTools.showToolbox(tt, "inspector").then(function(toolbox) {
let target = devtools.TargetFactory.forTab(gBrowser.selectedTab);
return gDevTools.showToolbox(target, "inspector").then(toolbox => {
let inspector = toolbox.getCurrentPanel();
// new-node-front tells us when the node has been selected, whether the
// browser is remote or not.
let onNewNode = inspector.selection.once("new-node-front");
if (this.isRemote) {
this.browser.messageManager.sendAsyncMessage("debug:inspect", {}, {node: this.target});
inspector.walker.findInspectingNode().then(nodeFront => {
@ -578,7 +584,13 @@ nsContextMenu.prototype = {
} else {
inspector.selection.setNode(this.target, "browser-context-menu");
}
}.bind(this));
return onNewNode.then(() => {
// Now that the node has been selected, wait until the inspector is
// fully updated.
return inspector.once("inspector-updated");
});
});
},
// Set various context menu attributes based on the state of the world.

Просмотреть файл

@ -258,8 +258,6 @@ var AnimationsPanel = {
* the various components again.
*/
refreshAnimationsUI: Task.async(function*() {
let done = gInspector.updating("animationspanel");
// Empty the whole panel first.
this.togglePlayers(true);
@ -278,12 +276,10 @@ var AnimationsPanel = {
if (!AnimationsController.animationPlayers.length) {
this.togglePlayers(false);
this.emit(this.UI_UPDATED_EVENT);
done();
return;
}
this.emit(this.UI_UPDATED_EVENT);
done();
})
};

Просмотреть файл

@ -1,5 +1,4 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* global nsContextMenu*/
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
@ -17,7 +16,7 @@ add_task(function*() {
let {inspector, testActor} = yield openInspectorForURL(TEST_URL);
info("Select the test node with the browser ctx menu");
yield selectWithBrowserMenu(inspector);
yield clickOnInspectMenuItem(testActor, "div");
assertNodeSelected(inspector, "div");
info("Press arrowUp to focus <body> " +
@ -47,27 +46,6 @@ function selectPreviousNodeWithArrowUp(inspector) {
return Promise.all([onUpdated, onNodeHighlighted]);
}
function* selectWithBrowserMenu(inspector) {
let contentAreaContextMenu = document.querySelector("#contentAreaContextMenu");
let contextOpened = once(contentAreaContextMenu, "popupshown");
yield BrowserTestUtils.synthesizeMouseAtCenter("div", {
type: "contextmenu",
button: 2
}, gBrowser.selectedBrowser);
yield contextOpened;
yield gContextMenu.inspectNode();
let contextClosed = once(contentAreaContextMenu, "popuphidden");
contentAreaContextMenu.hidden = true;
contentAreaContextMenu.hidePopup();
yield inspector.once("inspector-updated");
yield contextClosed;
}
function* selectWithElementPicker(inspector, testActor) {
yield startPicker(inspector.toolbox);

Просмотреть файл

@ -68,7 +68,7 @@ support-files =
[browser_rules_completion-popup-hidden-after-navigation.js]
[browser_rules_content_01.js]
[browser_rules_content_02.js]
skip-if = e10s # Bug 1039528: "inspect element" contextual-menu doesn't work with e10s
skip-if = e10s && debug && os == 'win' # Bug 1250058 - Docshell leak on win debug e10s
[browser_rules_context-menu-show-mdn-docs-01.js]
[browser_rules_context-menu-show-mdn-docs-02.js]
[browser_rules_context-menu-show-mdn-docs-03.js]

Просмотреть файл

@ -19,34 +19,12 @@ const STRINGS = Services.strings
.createBundle("chrome://devtools-shared/locale/styleinspector.properties");
add_task(function*() {
yield addTab("data:text/html;charset=utf-8," + CONTENT);
let tab = yield addTab("data:text/html;charset=utf-8," + CONTENT);
info("Getting the test element");
let element = getNode("span");
let testActor = yield getTestActorWithoutToolbox(tab);
let inspector = yield clickOnInspectMenuItem(testActor, "span");
info("Opening the inspector using the content context-menu");
let onInspectorReady = gDevTools.once("inspector-ready");
document.popupNode = element;
let contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
let contextMenu = new nsContextMenu(contentAreaContextMenu);
yield contextMenu.inspectNode();
// Clean up context menu:
contextMenu.hiding();
yield onInspectorReady;
let target = TargetFactory.forTab(gBrowser.selectedTab);
let toolbox = gDevTools.getToolbox(target);
info("Getting the inspector and making sure it is fully updated");
let inspector = toolbox.getPanel("inspector");
yield inspector.once("inspector-updated");
let view = inspector.ruleview.view;
checkRuleViewContent(view);
checkRuleViewContent(inspector.ruleview.view);
});
function checkRuleViewContent({styleDocument}) {
@ -81,3 +59,4 @@ function checkRuleViewContent({styleDocument}) {
is(propertyValues.length, 1, "There's only one property value, as expected");
}
}

Просмотреть файл

@ -217,7 +217,9 @@ var openInspector = Task.async(function*() {
inspector = toolbox.getPanel("inspector");
info("Waiting for the inspector to update");
yield inspector.once("inspector-updated");
if (inspector._updateProgress) {
yield inspector.once("inspector-updated");
}
return {
toolbox: toolbox,

Просмотреть файл

@ -80,7 +80,7 @@ skip-if = e10s # GCLI isn't e10s compatible. See bug 1128988.
[browser_inspector_iframe-navigation.js]
[browser_inspector_infobar_01.js]
[browser_inspector_initialization.js]
skip-if = e10s && debug && os == 'win'
skip-if = e10s && debug && os == 'win' # Bug 1250058 - Docshell leak on win debug e10s
[browser_inspector_inspect-object-element.js]
[browser_inspector_invalidate.js]
[browser_inspector_keyboard-shortcuts-copy-outerhtml.js]

Просмотреть файл

@ -114,27 +114,3 @@ function* testBreadcrumbs(selector, inspector) {
ok(button, "A crumbs is checked=true");
is(button.getAttribute("tooltiptext"), expectedText, "Crumb refers to the right node");
}
function* clickOnInspectMenuItem(testActor, selector) {
info("Showing the contextual menu on node " + selector);
let contentAreaContextMenu = document.querySelector("#contentAreaContextMenu");
let contextOpened = once(contentAreaContextMenu, "popupshown");
yield testActor.synthesizeMouse({
selector: selector,
center: true,
options: {type: "contextmenu", button: 2}
});
yield contextOpened;
info("Triggering inspect action and hiding the menu.");
yield gContextMenu.inspectNode();
let contextClosed = once(contentAreaContextMenu, "popuphidden");
contentAreaContextMenu.hidePopup();
info("Waiting for inspector to update.");
yield getActiveInspector().once("inspector-updated");
yield contextClosed;
}

Просмотреть файл

@ -175,6 +175,36 @@ function getActiveInspector() {
return gDevTools.getToolbox(target).getPanel("inspector");
}
/**
* Right click on a node in the test page and click on the inspect menu item.
* @param {TestActor}
* @param {String} selector The selector for the node to click on in the page.
* @return {Promise} Resolves to the inspector when it has opened and is updated
*/
var clickOnInspectMenuItem = Task.async(function*(testActor, selector) {
info("Showing the contextual menu on node " + selector);
let contentAreaContextMenu = document.querySelector("#contentAreaContextMenu");
let contextOpened = once(contentAreaContextMenu, "popupshown");
yield testActor.synthesizeMouse({
selector: selector,
center: true,
options: {type: "contextmenu", button: 2}
});
yield contextOpened;
info("Triggering the inspect action");
yield gContextMenu.inspectNode();
info("Hiding the menu");
let contextClosed = once(contentAreaContextMenu, "popuphidden");
contentAreaContextMenu.hidePopup();
yield contextClosed;
return getActiveInspector();
});
/**
* Open the toolbox, with the inspector tool visible, and the one of the sidebar
* tabs selected.