From 7d17cca476df7612d0c01b6ceb0e55e115d527e3 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 22 May 2015 07:01:59 -0500 Subject: [PATCH] Backed out changeset a5e245f216b7 on CLOSED TREE (bug 1067325) --- .../browser_computedview_style-editor-link.js | 14 +-- .../browser_ruleview_style-editor-link.js | 14 +-- browser/devtools/styleinspector/test/head.js | 15 ---- .../test/browser_webconsole_view_source.js | 86 ++++++++++++------- browser/devtools/webconsole/test/head.js | 15 ---- toolkit/devtools/server/actors/webbrowser.js | 11 ++- 6 files changed, 74 insertions(+), 81 deletions(-) diff --git a/browser/devtools/styleinspector/test/browser_computedview_style-editor-link.js b/browser/devtools/styleinspector/test/browser_computedview_style-editor-link.js index 4a2ad240f18..7f56cf23346 100644 --- a/browser/devtools/styleinspector/test/browser_computedview_style-editor-link.js +++ b/browser/devtools/styleinspector/test/browser_computedview_style-editor-link.js @@ -7,7 +7,7 @@ /////////////////// // // Whitelisting this test. -// As part of bug 1077403, the leaking uncaught rejection should be fixed. +// As part of bug 1077403, the leaking uncaught rejection should be fixed. // thisTestLeaksUncaughtRejectionsAndShouldBeFixed("Error: Unknown sheet source"); @@ -70,16 +70,16 @@ function* testInlineStyle(view, inspector) { yield expandComputedViewPropertyByIndex(view, 0); - let onTab = waitForTab(); + let onWindow = waitForWindow(); info("Clicking on the first rule-link in the computed-view"); clickLinkByIndex(view, 0); - let tab = yield onTab; + let win = yield onWindow; - let tabURI = tab.linkedBrowser.documentURI.spec; - ok(tabURI.startsWith("view-source:"), "View source tab is open"); - info("Closing tab"); - gBrowser.removeTab(tab); + let windowType = win.document.documentElement.getAttribute("windowtype"); + is(windowType, "navigator:view-source", "View source window is open"); + info("Closing window"); + win.close(); } function* testFirstInlineStyleSheet(view, toolbox) { diff --git a/browser/devtools/styleinspector/test/browser_ruleview_style-editor-link.js b/browser/devtools/styleinspector/test/browser_ruleview_style-editor-link.js index b7a6f4bd8ab..559ba057093 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_style-editor-link.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_style-editor-link.js @@ -7,7 +7,7 @@ /////////////////// // // Whitelisting this test. -// As part of bug 1077403, the leaking uncaught rejection should be fixed. +// As part of bug 1077403, the leaking uncaught rejection should be fixed. // thisTestLeaksUncaughtRejectionsAndShouldBeFixed("Error: Unknown sheet source"); @@ -70,16 +70,16 @@ add_task(function*() { function* testInlineStyle(view, inspector) { info("Testing inline style"); - let onTab = waitForTab(); + let onWindow = waitForWindow(); info("Clicking on the first link in the rule-view"); clickLinkByIndex(view, 0); - let tab = yield onTab; + let win = yield onWindow; - let tabURI = tab.linkedBrowser.documentURI.spec; - ok(tabURI.startsWith("view-source:"), "View source tab is open"); - info("Closing tab"); - gBrowser.removeTab(tab); + let windowType = win.document.documentElement.getAttribute("windowtype"); + is(windowType, "navigator:view-source", "View source window is open"); + info("Closing window"); + win.close(); } function* testFirstInlineStyleSheet(view, toolbox) { diff --git a/browser/devtools/styleinspector/test/head.js b/browser/devtools/styleinspector/test/head.js index f9f6646855e..989d4fb53fc 100644 --- a/browser/devtools/styleinspector/test/head.js +++ b/browser/devtools/styleinspector/test/head.js @@ -491,21 +491,6 @@ function waitForWindow() { return def.promise; } -/** - * Listen for a new tab to open and return a promise that resolves when one - * does and completes the load event. - * @return a promise that resolves to the tab object - */ -let waitForTab = Task.async(function*() { - info("Waiting for a tab to open"); - yield once(gBrowser.tabContainer, "TabOpen"); - let tab = gBrowser.selectedTab; - let browser = tab.linkedBrowser; - yield once(browser, "load", true); - info("The tab load completed"); - return tab; -}); - /** * @see SimpleTest.waitForClipboard * @param {Function} setup Function to execute before checking for the diff --git a/browser/devtools/webconsole/test/browser_webconsole_view_source.js b/browser/devtools/webconsole/test/browser_webconsole_view_source.js index ad657ba5faf..ad008478df7 100644 --- a/browser/devtools/webconsole/test/browser_webconsole_view_source.js +++ b/browser/devtools/webconsole/test/browser_webconsole_view_source.js @@ -10,9 +10,13 @@ let getItemForAttachment; let Sources; let getItemInvoked = false; -add_task(function*() { - yield loadTab(TEST_URI); - let hud = yield openConsole(null); +function test() { + loadTab(TEST_URI).then(() => { + openConsole(null).then(testViewSource); + }); +} + +function testViewSource(hud) { info("console opened"); let button = content.document.querySelector("button"); @@ -21,42 +25,58 @@ add_task(function*() { expectUncaughtException(); EventUtils.sendMouseEvent({ type: "click" }, button, content); - let { panelWin: { DebuggerView } } = yield openDebugger(); - info("debugger opened"); - Sources = DebuggerView.Sources; - hud = yield openConsole(); - info("console opened again"); + openDebugger().then(({panelWin: { DebuggerView }}) => { + info("debugger opened"); + Sources = DebuggerView.Sources; + openConsole().then((hud) => { + info("console opened again"); - let [result] = yield waitForMessages({ - webconsole: hud, - messages: [{ - text: "fooBazBaz is not defined", - category: CATEGORY_JS, - severity: SEVERITY_ERROR, - }], + waitForMessages({ + webconsole: hud, + messages: [{ + text: "fooBazBaz is not defined", + category: CATEGORY_JS, + severity: SEVERITY_ERROR, + }], + }).then(onMessage); + }); }); - let msg = [...result.matched][0]; - ok(msg, "error message"); - let locationNode = msg.querySelector(".message-location"); - ok(locationNode, "location node"); + function onMessage([result]) { + let msg = [...result.matched][0]; + ok(msg, "error message"); + let locationNode = msg.querySelector(".message-location"); + ok(locationNode, "location node"); - let onTabOpen = waitForTab(); + Services.ww.registerNotification(observer); - getItemForAttachment = Sources.getItemForAttachment; - Sources.getItemForAttachment = () => { - getItemInvoked = true; - return false; - }; + getItemForAttachment = Sources.getItemForAttachment; + Sources.getItemForAttachment = () => { + getItemInvoked = true; + return false; + }; - EventUtils.sendMouseEvent({ type: "click" }, locationNode); + EventUtils.sendMouseEvent({ type: "click" }, locationNode); + } +} - let tab = yield onTabOpen; - ok(true, "the view source tab was opened in response to clicking " + - "the location node"); - gBrowser.removeTab(tab); +let observer = { + observe: function(aSubject, aTopic, aData) { + if (aTopic != "domwindowopened") { + return; + } - ok(getItemInvoked, "custom getItemForAttachment() was invoked"); - Sources.getItemForAttachment = getItemForAttachment; - Sources = getItemForAttachment = null; + ok(true, "the view source window was opened in response to clicking " + + "the location node"); + + aSubject.close(); + ok(getItemInvoked, "custom getItemForAttachment() was invoked"); + Sources.getItemForAttachment = getItemForAttachment; + Sources = getItemForAttachment = null; + finishTest(); + } +}; + +registerCleanupFunction(function() { + Services.ww.unregisterNotification(observer); }); diff --git a/browser/devtools/webconsole/test/head.js b/browser/devtools/webconsole/test/head.js index 8dd9d0ce595..cbd027a1f1b 100644 --- a/browser/devtools/webconsole/test/head.js +++ b/browser/devtools/webconsole/test/head.js @@ -255,21 +255,6 @@ function waitForContextMenu(aPopup, aButton, aOnShown, aOnHidden) return deferred.promise; } -/** - * Listen for a new tab to open and return a promise that resolves when one - * does and completes the load event. - * @return a promise that resolves to the tab object - */ -let waitForTab = Task.async(function*() { - info("Waiting for a tab to open"); - yield once(gBrowser.tabContainer, "TabOpen"); - let tab = gBrowser.selectedTab; - let browser = tab.linkedBrowser; - yield once(browser, "load", true); - info("The tab load completed"); - return tab; -}); - /** * Dump the output of all open Web Consoles - used only for debugging purposes. */ diff --git a/toolkit/devtools/server/actors/webbrowser.js b/toolkit/devtools/server/actors/webbrowser.js index a2fa8253264..4a22bbc4955 100644 --- a/toolkit/devtools/server/actors/webbrowser.js +++ b/toolkit/devtools/server/actors/webbrowser.js @@ -978,6 +978,7 @@ TabActor.prototype = { }); this._extraActors = null; + this._styleSheetActors.clear(); this._exited = true; }, @@ -1324,10 +1325,6 @@ TabActor.prototype = { this._popContext(); // Shut down actors that belong to this tab's pool. - for (let sheetActor of this._styleSheetActors.values()) { - this._tabPool.removeActor(sheetActor); - } - this._styleSheetActors.clear(); this.conn.removeActorPool(this._tabPool); this._tabPool = null; if (this._tabActorPool) { @@ -1645,6 +1642,12 @@ TabActor.prototype = { threadActor.global = window; } + for (let sheetActor of this._styleSheetActors.values()) { + this._tabPool.removeActor(sheetActor); + } + this._styleSheetActors.clear(); + + // Refresh the debuggee list when a new window object appears (top window or // iframe). if (threadActor.attached) {