From 6b20ea38c83ddde3161f4d031761753a2989e2fb Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Thu, 4 Feb 2016 12:51:14 -0800 Subject: [PATCH] Backed out changeset 3d2eace770d1 (bug 1244120) for very frequent leaks on Win7 CLOSED TREE --- browser/base/content/nsContextMenu.js | 20 +++--------- .../animationinspector/animation-panel.js | 4 +++ .../test/browser_markup_keybindings_04.js | 24 +++++++++++++- .../client/inspector/rules/test/browser.ini | 1 + .../rules/test/browser_rules_content_02.js | 31 ++++++++++++++++--- devtools/client/inspector/shared/test/head.js | 4 +-- .../test/browser_inspector_initialization.js | 24 ++++++++++++++ devtools/client/inspector/test/head.js | 30 ------------------ 8 files changed, 83 insertions(+), 55 deletions(-) diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js index ed9ecf58721..a840ff89e89 100644 --- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -559,18 +559,12 @@ nsContextMenu.prototype = { LoginHelper.openPasswordManager(window, gContextMenuContentData.documentURIObject.host); }, - inspectNode: function() { + inspectNode: function CM_inspectNode() { let {devtools} = Cu.import("resource://devtools/shared/Loader.jsm", {}); let gBrowser = this.browser.ownerDocument.defaultView.gBrowser; - let target = devtools.TargetFactory.forTab(gBrowser.selectedTab); - - return gDevTools.showToolbox(target, "inspector").then(toolbox => { + let tt = devtools.TargetFactory.forTab(gBrowser.selectedTab); + return gDevTools.showToolbox(tt, "inspector").then(function(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 => { @@ -579,13 +573,7 @@ nsContextMenu.prototype = { } else { inspector.selection.setNode(this.target, "browser-context-menu"); } - - return onNewNode.then(() => { - // Now that the node has been selected, wait until the inspector is - // fully updated. - return inspector.once("inspector-updated"); - }); - }); + }.bind(this)); }, // 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 dec3a4185c3..e68405e8573 100644 --- a/devtools/client/animationinspector/animation-panel.js +++ b/devtools/client/animationinspector/animation-panel.js @@ -249,6 +249,8 @@ var AnimationsPanel = { * the various components again. */ refreshAnimationsUI: Task.async(function*() { + let done = gInspector.updating("animationspanel"); + // Empty the whole panel first. this.togglePlayers(true); @@ -267,10 +269,12 @@ 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 a80488b06f4..e406619e4fa 100644 --- a/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js +++ b/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js @@ -1,4 +1,5 @@ /* 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/ */ @@ -16,7 +17,7 @@ add_task(function*() { let {inspector, testActor} = yield openInspectorForURL(TEST_URL); info("Select the test node with the browser ctx menu"); - yield clickOnInspectMenuItem(testActor, "div"); + yield selectWithBrowserMenu(inspector); assertNodeSelected(inspector, "div"); info("Press arrowUp to focus " + @@ -46,6 +47,27 @@ 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 inspector.toolbox.highlighterUtils.startPicker(); diff --git a/devtools/client/inspector/rules/test/browser.ini b/devtools/client/inspector/rules/test/browser.ini index fc0ee7dab42..6adb64fd217 100644 --- a/devtools/client/inspector/rules/test/browser.ini +++ b/devtools/client/inspector/rules/test/browser.ini @@ -66,6 +66,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 [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 5c9d31409fa..6d4849c5218 100644 --- a/devtools/client/inspector/rules/test/browser_rules_content_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_content_02.js @@ -19,12 +19,34 @@ const STRINGS = Services.strings .createBundle("chrome://devtools-shared/locale/styleinspector.properties"); add_task(function*() { - let tab = yield addTab("data:text/html;charset=utf-8," + CONTENT); + yield addTab("data:text/html;charset=utf-8," + CONTENT); - let testActor = yield getTestActorWithoutToolbox(tab); - let inspector = yield clickOnInspectMenuItem(testActor, "span"); + info("Getting the test element"); + let element = getNode("span"); - checkRuleViewContent(inspector.ruleview.view); + 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); }); function checkRuleViewContent({styleDocument}) { @@ -59,4 +81,3 @@ 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 ef40ff17d44..8d1bf4f1250 100644 --- a/devtools/client/inspector/shared/test/head.js +++ b/devtools/client/inspector/shared/test/head.js @@ -218,9 +218,7 @@ var openInspector = Task.async(function*() { inspector = toolbox.getPanel("inspector"); info("Waiting for the inspector to update"); - if (inspector._updateProgress) { - yield inspector.once("inspector-updated"); - } + yield inspector.once("inspector-updated"); return { toolbox: toolbox, diff --git a/devtools/client/inspector/test/browser_inspector_initialization.js b/devtools/client/inspector/test/browser_inspector_initialization.js index e9c03057ed0..dd978445879 100644 --- a/devtools/client/inspector/test/browser_inspector_initialization.js +++ b/devtools/client/inspector/test/browser_inspector_initialization.js @@ -114,3 +114,27 @@ 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 d469e76b494..fcadc391d36 100644 --- a/devtools/client/inspector/test/head.js +++ b/devtools/client/inspector/test/head.js @@ -161,36 +161,6 @@ 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.