michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Check that Ctrl-W closes the Browser Console and that Ctrl-W closes the michael@0: // current tab when using the Web Console - bug 871156. michael@0: michael@0: function test() michael@0: { michael@0: const TEST_URI = "data:text/html;charset=utf8,bug871156\n" + michael@0: "

hello world"; michael@0: let firstTab = gBrowser.selectedTab; michael@0: Services.prefs.setBoolPref("browser.tabs.animate", false); michael@0: michael@0: addTab(TEST_URI); michael@0: browser.addEventListener("load", function onLoad() { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: openConsole(null, consoleOpened); michael@0: }, true); michael@0: michael@0: function consoleOpened(hud) michael@0: { michael@0: ok(hud, "Web Console opened"); michael@0: michael@0: let tabClosed = promise.defer(); michael@0: let toolboxDestroyed = promise.defer(); michael@0: let tabSelected = promise.defer(); michael@0: michael@0: let pageWindow = firstTab.linkedBrowser.contentWindow; michael@0: let toolbox = gDevTools.getToolbox(hud.target); michael@0: michael@0: gBrowser.tabContainer.addEventListener("TabClose", function onTabClose() { michael@0: gBrowser.tabContainer.removeEventListener("TabClose", onTabClose); michael@0: info("tab closed"); michael@0: tabClosed.resolve(null); michael@0: }); michael@0: michael@0: gBrowser.tabContainer.addEventListener("TabSelect", function onTabSelect() { michael@0: gBrowser.tabContainer.removeEventListener("TabSelect", onTabSelect); michael@0: if (gBrowser.selectedTab == firstTab) { michael@0: info("tab selected"); michael@0: tabSelected.resolve(null); michael@0: } michael@0: }); michael@0: michael@0: toolbox.once("destroyed", () => { michael@0: info("toolbox destroyed"); michael@0: toolboxDestroyed.resolve(null); michael@0: }); michael@0: michael@0: promise.all([tabClosed.promise, toolboxDestroyed.promise, tabSelected.promise ]).then(() => { michael@0: info("promise.all resolved"); michael@0: waitForFocus(testBrowserConsole, pageWindow, true); michael@0: }); michael@0: michael@0: // Get out of the web console initialization. michael@0: executeSoon(() => { michael@0: EventUtils.synthesizeKey("w", { accelKey: true }); michael@0: }); michael@0: } michael@0: michael@0: function testBrowserConsole() michael@0: { michael@0: info("test the Browser Console"); michael@0: michael@0: HUDService.toggleBrowserConsole().then((hud) => { michael@0: ok(hud, "Browser Console opened"); michael@0: michael@0: Services.obs.addObserver(function onDestroy() { michael@0: Services.obs.removeObserver(onDestroy, "web-console-destroyed"); michael@0: ok(true, "the Browser Console closed"); michael@0: michael@0: Services.prefs.clearUserPref("browser.tabs.animate"); michael@0: waitForFocus(finish, content, true); michael@0: }, "web-console-destroyed", false); michael@0: michael@0: waitForFocus(() => { michael@0: EventUtils.synthesizeKey("w", { accelKey: true }, hud.iframeWindow); michael@0: }, hud.iframeWindow); michael@0: }); michael@0: } michael@0: }