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.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 /**
5 * Test that closing a window with the debugger in a paused state exits cleanly.
6 */
8 let gDebuggee, gPanel, gDebugger, gWindow;
10 const TAB_URL = EXAMPLE_URL + "doc_inline-debugger-statement.html";
12 function test() {
13 addWindow(TAB_URL)
14 .then(win => initDebugger(TAB_URL, win))
15 .then(([aTab, aDebuggee, aPanel, aWindow]) => {
16 gDebuggee = aDebuggee;
17 gPanel = aPanel;
18 gDebugger = gPanel.panelWin;
19 gWindow = aWindow;
21 return testCleanExit();
22 })
23 .then(null, aError => {
24 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
25 });
26 }
28 function testCleanExit() {
29 let deferred = promise.defer();
31 ok(!!gWindow, "Second window created.");
33 gWindow.focus();
35 is(Services.wm.getMostRecentWindow("navigator:browser"), gWindow,
36 "The second window is on top.");
38 let isActive = promise.defer();
39 let isLoaded = promise.defer();
41 promise.all([isActive.promise, isLoaded.promise]).then(() => {
42 gWindow.BrowserChromeTest.runWhenReady(() => {
43 waitForSourceAndCaretAndScopes(gPanel, ".html", 16).then(() => {
44 is(gDebugger.gThreadClient.paused, true,
45 "Should be paused after the debugger statement.");
46 gWindow.close();
47 deferred.resolve();
48 finish();
49 });
51 gDebuggee.runDebuggerStatement();
52 });
53 });
55 let focusManager = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
56 if (focusManager.activeWindow != gWindow) {
57 gWindow.addEventListener("activate", function onActivate(aEvent) {
58 if (aEvent.target != gWindow) {
59 return;
60 }
61 gWindow.removeEventListener("activate", onActivate, true);
62 isActive.resolve();
63 }, true);
64 } else {
65 isActive.resolve();
66 }
68 if (gWindow.content.location.href != TAB_URL) {
69 gWindow.document.addEventListener("load", function onLoad(aEvent) {
70 if (aEvent.target.documentURI != TAB_URL) {
71 return;
72 }
73 gWindow.document.removeEventListener("load", onLoad, true);
74 isLoaded.resolve();
75 }, true);
76 } else {
77 isLoaded.resolve();
78 }
79 return deferred.promise;
80 }
82 registerCleanupFunction(function() {
83 gWindow = null;
84 gDebuggee = null;
85 gPanel = null;
86 gDebugger = null;
87 });