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