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