Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | * Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | * http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 4 | */ |
michael@0 | 5 | |
michael@0 | 6 | // Check that Ctrl-W closes the Browser Console and that Ctrl-W closes the |
michael@0 | 7 | // current tab when using the Web Console - bug 871156. |
michael@0 | 8 | |
michael@0 | 9 | function test() |
michael@0 | 10 | { |
michael@0 | 11 | const TEST_URI = "data:text/html;charset=utf8,<title>bug871156</title>\n" + |
michael@0 | 12 | "<p>hello world"; |
michael@0 | 13 | let firstTab = gBrowser.selectedTab; |
michael@0 | 14 | Services.prefs.setBoolPref("browser.tabs.animate", false); |
michael@0 | 15 | |
michael@0 | 16 | addTab(TEST_URI); |
michael@0 | 17 | browser.addEventListener("load", function onLoad() { |
michael@0 | 18 | browser.removeEventListener("load", onLoad, true); |
michael@0 | 19 | openConsole(null, consoleOpened); |
michael@0 | 20 | }, true); |
michael@0 | 21 | |
michael@0 | 22 | function consoleOpened(hud) |
michael@0 | 23 | { |
michael@0 | 24 | ok(hud, "Web Console opened"); |
michael@0 | 25 | |
michael@0 | 26 | let tabClosed = promise.defer(); |
michael@0 | 27 | let toolboxDestroyed = promise.defer(); |
michael@0 | 28 | let tabSelected = promise.defer(); |
michael@0 | 29 | |
michael@0 | 30 | let pageWindow = firstTab.linkedBrowser.contentWindow; |
michael@0 | 31 | let toolbox = gDevTools.getToolbox(hud.target); |
michael@0 | 32 | |
michael@0 | 33 | gBrowser.tabContainer.addEventListener("TabClose", function onTabClose() { |
michael@0 | 34 | gBrowser.tabContainer.removeEventListener("TabClose", onTabClose); |
michael@0 | 35 | info("tab closed"); |
michael@0 | 36 | tabClosed.resolve(null); |
michael@0 | 37 | }); |
michael@0 | 38 | |
michael@0 | 39 | gBrowser.tabContainer.addEventListener("TabSelect", function onTabSelect() { |
michael@0 | 40 | gBrowser.tabContainer.removeEventListener("TabSelect", onTabSelect); |
michael@0 | 41 | if (gBrowser.selectedTab == firstTab) { |
michael@0 | 42 | info("tab selected"); |
michael@0 | 43 | tabSelected.resolve(null); |
michael@0 | 44 | } |
michael@0 | 45 | }); |
michael@0 | 46 | |
michael@0 | 47 | toolbox.once("destroyed", () => { |
michael@0 | 48 | info("toolbox destroyed"); |
michael@0 | 49 | toolboxDestroyed.resolve(null); |
michael@0 | 50 | }); |
michael@0 | 51 | |
michael@0 | 52 | promise.all([tabClosed.promise, toolboxDestroyed.promise, tabSelected.promise ]).then(() => { |
michael@0 | 53 | info("promise.all resolved"); |
michael@0 | 54 | waitForFocus(testBrowserConsole, pageWindow, true); |
michael@0 | 55 | }); |
michael@0 | 56 | |
michael@0 | 57 | // Get out of the web console initialization. |
michael@0 | 58 | executeSoon(() => { |
michael@0 | 59 | EventUtils.synthesizeKey("w", { accelKey: true }); |
michael@0 | 60 | }); |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | function testBrowserConsole() |
michael@0 | 64 | { |
michael@0 | 65 | info("test the Browser Console"); |
michael@0 | 66 | |
michael@0 | 67 | HUDService.toggleBrowserConsole().then((hud) => { |
michael@0 | 68 | ok(hud, "Browser Console opened"); |
michael@0 | 69 | |
michael@0 | 70 | Services.obs.addObserver(function onDestroy() { |
michael@0 | 71 | Services.obs.removeObserver(onDestroy, "web-console-destroyed"); |
michael@0 | 72 | ok(true, "the Browser Console closed"); |
michael@0 | 73 | |
michael@0 | 74 | Services.prefs.clearUserPref("browser.tabs.animate"); |
michael@0 | 75 | waitForFocus(finish, content, true); |
michael@0 | 76 | }, "web-console-destroyed", false); |
michael@0 | 77 | |
michael@0 | 78 | waitForFocus(() => { |
michael@0 | 79 | EventUtils.synthesizeKey("w", { accelKey: true }, hud.iframeWindow); |
michael@0 | 80 | }, hud.iframeWindow); |
michael@0 | 81 | }); |
michael@0 | 82 | } |
michael@0 | 83 | } |