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 7f56cf23346..4a2ad240f18 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 onWindow = waitForWindow(); + let onTab = waitForTab(); info("Clicking on the first rule-link in the computed-view"); clickLinkByIndex(view, 0); - let win = yield onWindow; + let tab = yield onTab; - let windowType = win.document.documentElement.getAttribute("windowtype"); - is(windowType, "navigator:view-source", "View source window is open"); - info("Closing window"); - win.close(); + let tabURI = tab.linkedBrowser.documentURI.spec; + ok(tabURI.startsWith("view-source:"), "View source tab is open"); + info("Closing tab"); + gBrowser.removeTab(tab); } 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 559ba057093..b7a6f4bd8ab 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 onWindow = waitForWindow(); + let onTab = waitForTab(); info("Clicking on the first link in the rule-view"); clickLinkByIndex(view, 0); - let win = yield onWindow; + let tab = yield onTab; - let windowType = win.document.documentElement.getAttribute("windowtype"); - is(windowType, "navigator:view-source", "View source window is open"); - info("Closing window"); - win.close(); + let tabURI = tab.linkedBrowser.documentURI.spec; + ok(tabURI.startsWith("view-source:"), "View source tab is open"); + info("Closing tab"); + gBrowser.removeTab(tab); } function* testFirstInlineStyleSheet(view, toolbox) { diff --git a/browser/devtools/styleinspector/test/head.js b/browser/devtools/styleinspector/test/head.js index 989d4fb53fc..f9f6646855e 100644 --- a/browser/devtools/styleinspector/test/head.js +++ b/browser/devtools/styleinspector/test/head.js @@ -491,6 +491,21 @@ 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 ad008478df7..ad657ba5faf 100644 --- a/browser/devtools/webconsole/test/browser_webconsole_view_source.js +++ b/browser/devtools/webconsole/test/browser_webconsole_view_source.js @@ -10,13 +10,9 @@ let getItemForAttachment; let Sources; let getItemInvoked = false; -function test() { - loadTab(TEST_URI).then(() => { - openConsole(null).then(testViewSource); - }); -} - -function testViewSource(hud) { +add_task(function*() { + yield loadTab(TEST_URI); + let hud = yield openConsole(null); info("console opened"); let button = content.document.querySelector("button"); @@ -25,58 +21,42 @@ function testViewSource(hud) { expectUncaughtException(); EventUtils.sendMouseEvent({ type: "click" }, button, content); - openDebugger().then(({panelWin: { DebuggerView }}) => { - info("debugger opened"); - Sources = DebuggerView.Sources; - openConsole().then((hud) => { - info("console opened again"); + let { panelWin: { DebuggerView } } = yield openDebugger(); + info("debugger opened"); + Sources = DebuggerView.Sources; + hud = yield openConsole(); + info("console opened again"); - waitForMessages({ - webconsole: hud, - messages: [{ - text: "fooBazBaz is not defined", - category: CATEGORY_JS, - severity: SEVERITY_ERROR, - }], - }).then(onMessage); - }); + let [result] = yield waitForMessages({ + webconsole: hud, + messages: [{ + text: "fooBazBaz is not defined", + category: CATEGORY_JS, + severity: SEVERITY_ERROR, + }], }); - function onMessage([result]) { - let msg = [...result.matched][0]; - ok(msg, "error message"); - let locationNode = msg.querySelector(".message-location"); - ok(locationNode, "location node"); + let msg = [...result.matched][0]; + ok(msg, "error message"); + let locationNode = msg.querySelector(".message-location"); + ok(locationNode, "location node"); - Services.ww.registerNotification(observer); + let onTabOpen = waitForTab(); - 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 observer = { - observe: function(aSubject, aTopic, aData) { - if (aTopic != "domwindowopened") { - return; - } + let tab = yield onTabOpen; + ok(true, "the view source tab was opened in response to clicking " + + "the location node"); + gBrowser.removeTab(tab); - 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); + ok(getItemInvoked, "custom getItemForAttachment() was invoked"); + Sources.getItemForAttachment = getItemForAttachment; + Sources = getItemForAttachment = null; }); diff --git a/browser/devtools/webconsole/test/head.js b/browser/devtools/webconsole/test/head.js index cbd027a1f1b..8dd9d0ce595 100644 --- a/browser/devtools/webconsole/test/head.js +++ b/browser/devtools/webconsole/test/head.js @@ -255,6 +255,21 @@ 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 4a22bbc4955..a2fa8253264 100644 --- a/toolkit/devtools/server/actors/webbrowser.js +++ b/toolkit/devtools/server/actors/webbrowser.js @@ -978,7 +978,6 @@ TabActor.prototype = { }); this._extraActors = null; - this._styleSheetActors.clear(); this._exited = true; }, @@ -1325,6 +1324,10 @@ 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) { @@ -1642,12 +1645,6 @@ 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) {