From ce1b99b254988b7844e54a9bfb424f9750c09207 Mon Sep 17 00:00:00 2001 From: Patrick Brosset Date: Mon, 22 Feb 2016 10:02:54 +0100 Subject: [PATCH] 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 --- browser/base/content/nsContextMenu.js | 20 +++++++++--- .../animationinspector/animation-panel.js | 4 --- .../test/browser_markup_keybindings_04.js | 24 +------------- .../client/inspector/rules/test/browser.ini | 2 +- .../rules/test/browser_rules_content_02.js | 31 +++---------------- devtools/client/inspector/shared/test/head.js | 4 ++- devtools/client/inspector/test/browser.ini | 2 +- .../test/browser_inspector_initialization.js | 24 -------------- devtools/client/inspector/test/head.js | 30 ++++++++++++++++++ 9 files changed, 57 insertions(+), 84 deletions(-) diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js index c452f8a47de0..ae450ec7a129 100644 --- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -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. diff --git a/devtools/client/animationinspector/animation-panel.js b/devtools/client/animationinspector/animation-panel.js index 679eed936bd4..0b5265daac4b 100644 --- a/devtools/client/animationinspector/animation-panel.js +++ b/devtools/client/animationinspector/animation-panel.js @@ -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(); }) }; diff --git a/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js b/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js index c165a62f1de9..ffa81aead6bb 100644 --- a/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js +++ b/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js @@ -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 " + @@ -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); diff --git a/devtools/client/inspector/rules/test/browser.ini b/devtools/client/inspector/rules/test/browser.ini index 71291874e512..7e3f0579ba33 100644 --- a/devtools/client/inspector/rules/test/browser.ini +++ b/devtools/client/inspector/rules/test/browser.ini @@ -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] diff --git a/devtools/client/inspector/rules/test/browser_rules_content_02.js b/devtools/client/inspector/rules/test/browser_rules_content_02.js index 6d4849c5218f..5c9d31409fa3 100644 --- a/devtools/client/inspector/rules/test/browser_rules_content_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_content_02.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"); } } + diff --git a/devtools/client/inspector/shared/test/head.js b/devtools/client/inspector/shared/test/head.js index 5857f12c7f29..c8421e8496d3 100644 --- a/devtools/client/inspector/shared/test/head.js +++ b/devtools/client/inspector/shared/test/head.js @@ -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, diff --git a/devtools/client/inspector/test/browser.ini b/devtools/client/inspector/test/browser.ini index 0e846dbeb28f..dcbf593372ce 100644 --- a/devtools/client/inspector/test/browser.ini +++ b/devtools/client/inspector/test/browser.ini @@ -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] diff --git a/devtools/client/inspector/test/browser_inspector_initialization.js b/devtools/client/inspector/test/browser_inspector_initialization.js index dd9784458794..e9c03057ed03 100644 --- a/devtools/client/inspector/test/browser_inspector_initialization.js +++ b/devtools/client/inspector/test/browser_inspector_initialization.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; -} diff --git a/devtools/client/inspector/test/head.js b/devtools/client/inspector/test/head.js index a1f4f578ef71..61d1f6ed2d95 100644 --- a/devtools/client/inspector/test/head.js +++ b/devtools/client/inspector/test/head.js @@ -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.