Bug 1244120 - Enable browser_rules_content_02.js with e10s; r=bgrins
☠☠ backed out by 614253f3ef08 ☠ ☠
authorPatrick Brosset <pbrosset@mozilla.com>
Wed, 03 Feb 2016 18:52:02 +0100
changeset 283021 3d2eace770d1a64ebd3056affac1806c37ebbf71
parent 283020 d8180fcec749a74510b27cc4882f57a141bc0b21
child 283022 3cd839e515b995a143711ad2d3e54c375d2d861d
push id29973
push userphilringnalda@gmail.com
push dateFri, 05 Feb 2016 03:25:00 +0000
treeherdermozilla-central@5e024441510f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1244120
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.
browser/base/content/nsContextMenu.js
devtools/client/animationinspector/animation-panel.js
devtools/client/inspector/markup/test/browser_markup_keybindings_04.js
devtools/client/inspector/rules/test/browser.ini
devtools/client/inspector/rules/test/browser_rules_content_02.js
devtools/client/inspector/shared/test/head.js
devtools/client/inspector/test/browser_inspector_initialization.js
devtools/client/inspector/test/head.js
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -554,31 +554,43 @@ nsContextMenu.prototype = {
     let insertBeforeElement = document.getElementById("fill-login-no-logins");
     popup.insertBefore(fragment, insertBeforeElement);
   },
 
   openPasswordManager: function() {
     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 => {
           inspector.selection.setNodeFront(nodeFront, "browser-context-menu");
         });
       } 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.
   setTarget: function (aNode, aRangeParent, aRangeOffset) {
     // gContextMenuContentData.isRemote tells us if the event came from a remote
     // process. gContextMenuContentData can be null if something (like tests)
     // opens the context menu directly.
     let editFlags;
--- a/devtools/client/animationinspector/animation-panel.js
+++ b/devtools/client/animationinspector/animation-panel.js
@@ -244,18 +244,16 @@ var AnimationsPanel = {
     yield this.refreshAnimationsUI();
   }),
 
   /**
    * Refresh the list of animations UI. This will empty the panel and re-render
    * the various components again.
    */
   refreshAnimationsUI: Task.async(function*() {
-    let done = gInspector.updating("animationspanel");
-
     // Empty the whole panel first.
     this.togglePlayers(true);
 
     // Re-render the timeline component.
     this.animationsTimelineComponent.render(
       AnimationsController.animationPlayers,
       AnimationsController.documentCurrentTime);
 
@@ -264,18 +262,16 @@ var AnimationsPanel = {
       this.rateSelectorComponent.render(AnimationsController.animationPlayers);
     }
 
     // If there are no players to show, show the error message instead and
     // return.
     if (!AnimationsController.animationPlayers.length) {
       this.togglePlayers(false);
       this.emit(this.UI_UPDATED_EVENT);
-      done();
       return;
     }
 
     this.emit(this.UI_UPDATED_EVENT);
-    done();
   })
 };
 
 EventEmitter.decorate(AnimationsPanel);
--- a/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js
+++ b/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js
@@ -1,10 +1,9 @@
 /* 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/ */
 
 "use strict";
 
 requestLongerTimeout(2);
 
 // Tests that selecting a node using the browser context menu (inspect element)
@@ -12,17 +11,17 @@ requestLongerTimeout(2);
 // immediately.
 
 const TEST_URL = "data:text/html;charset=utf8,<div>test element</div>";
 
 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> " +
        "(which works if the node was focused properly)");
   yield selectPreviousNodeWithArrowUp(inspector);
   assertNodeSelected(inspector, "body");
 
   info("Select the test node with the element picker");
@@ -42,37 +41,16 @@ function assertNodeSelected(inspector, t
 
 function selectPreviousNodeWithArrowUp(inspector) {
   let onNodeHighlighted = inspector.toolbox.once("node-highlight");
   let onUpdated = inspector.once("inspector-updated");
   EventUtils.synthesizeKey("VK_UP", {});
   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 inspector.toolbox.highlighterUtils.startPicker();
 
   yield BrowserTestUtils.synthesizeMouseAtCenter("div", {
     type: "mousemove",
   }, gBrowser.selectedBrowser);
 
   yield testActor.synthesizeKey({key: "VK_RETURN", options: {}});
--- a/devtools/client/inspector/rules/test/browser.ini
+++ b/devtools/client/inspector/rules/test/browser.ini
@@ -61,17 +61,16 @@ support-files =
 [browser_rules_completion-new-property_01.js]
 [browser_rules_completion-new-property_02.js]
 [browser_rules_completion-new-property_03.js]
 [browser_rules_computed-lists_01.js]
 [browser_rules_computed-lists_02.js]
 [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
 [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]
 [browser_rules_copy_styles.js]
 [browser_rules_cssom.js]
 [browser_rules_cubicbezier-appears-on-swatch-click.js]
 [browser_rules_cubicbezier-commit-on-ENTER.js]
 [browser_rules_cubicbezier-revert-on-ESC.js]
--- a/devtools/client/inspector/rules/test/browser_rules_content_02.js
+++ b/devtools/client/inspector/rules/test/browser_rules_content_02.js
@@ -14,44 +14,22 @@ const CONTENT = '<body style="color:red;
                      </p>\
                    </div>\
                  </body>';
 
 const STRINGS = Services.strings
   .createBundle("chrome://devtools-shared/locale/styleinspector.properties");
 
 add_task(function*() {
-  yield addTab("data:text/html;charset=utf-8," + CONTENT);
-
-  info("Getting the test element");
-  let element = getNode("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();
+  let tab = yield addTab("data:text/html;charset=utf-8," + CONTENT);
 
-  // Clean up context menu:
-  contextMenu.hiding();
-
-  yield onInspectorReady;
-
-  let target = TargetFactory.forTab(gBrowser.selectedTab);
-  let toolbox = gDevTools.getToolbox(target);
+  let testActor = yield getTestActorWithoutToolbox(tab);
+  let inspector = yield clickOnInspectMenuItem(testActor, "span");
 
-  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}) {
   info("Making sure the rule-view contains the expected content");
 
   let headers = [...styleDocument.querySelectorAll(".ruleview-header")];
   is(headers.length, 3, "There are 3 headers for inherited rules");
 
@@ -76,8 +54,9 @@ function checkRuleViewContent({styleDocu
 
     let propertyNames = [...rule.querySelectorAll(".ruleview-propertyname")];
     is(propertyNames.length, 1, "There's only one property name, as expected");
 
     let propertyValues = [...rule.querySelectorAll(".ruleview-propertyvalue")];
     is(propertyValues.length, 1, "There's only one property value, as expected");
   }
 }
+
--- a/devtools/client/inspector/shared/test/head.js
+++ b/devtools/client/inspector/shared/test/head.js
@@ -213,17 +213,19 @@ var openInspector = Task.async(function*
   }
 
   info("Opening the toolbox");
   toolbox = yield gDevTools.showToolbox(target, "inspector");
   yield waitForToolboxFrameFocus(toolbox);
   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,
     inspector: inspector
   };
 });
 
 /**
--- a/devtools/client/inspector/test/browser_inspector_initialization.js
+++ b/devtools/client/inspector/test/browser_inspector_initialization.js
@@ -109,32 +109,8 @@ function* testBreadcrumbs(selector, insp
   let nodeFront = yield getNodeFront(selector, inspector);
 
   let b = inspector.breadcrumbs;
   let expectedText = b.prettyPrintNodeAsText(nodeFront);
   let button = b.container.querySelector("button[checked=true]");
   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;
-}
--- a/devtools/client/inspector/test/head.js
+++ b/devtools/client/inspector/test/head.js
@@ -157,16 +157,46 @@ var openInspector = Task.async(function*
 });
 
 function getActiveInspector() {
   let target = TargetFactory.forTab(gBrowser.selectedTab);
   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.
  * @param {String} id The ID of the sidebar tab to be opened
  * @param {String} hostType Optional hostType, as defined in Toolbox.HostType
  * @return a promise that resolves when the inspector is ready and the tab is
  * visible and ready
  */
 var openInspectorSidebarTab = Task.async(function*(id, hostType) {