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 pretty printing when the debugger is paused does not switch away |
michael@0 | 6 | * from the selected source. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | const TAB_URL = EXAMPLE_URL + "doc_pretty-print-on-paused.html"; |
michael@0 | 10 | |
michael@0 | 11 | let gTab, gDebuggee, gPanel, gDebugger, gThreadClient, gSources; |
michael@0 | 12 | |
michael@0 | 13 | const SECOND_SOURCE_VALUE = EXAMPLE_URL + "code_ugly-2.js"; |
michael@0 | 14 | |
michael@0 | 15 | function test(){ |
michael@0 | 16 | initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
michael@0 | 17 | gTab = aTab; |
michael@0 | 18 | gDebuggee = aDebuggee; |
michael@0 | 19 | gPanel = aPanel; |
michael@0 | 20 | gDebugger = gPanel.panelWin; |
michael@0 | 21 | gThreadClient = gDebugger.gThreadClient; |
michael@0 | 22 | gSources = gDebugger.DebuggerView.Sources; |
michael@0 | 23 | |
michael@0 | 24 | Task.spawn(function* () { |
michael@0 | 25 | try { |
michael@0 | 26 | yield ensureSourceIs(gPanel, "code_script-switching-02.js", true); |
michael@0 | 27 | |
michael@0 | 28 | yield doInterrupt(gPanel); |
michael@0 | 29 | yield rdpInvoke(gThreadClient, gThreadClient.setBreakpoint, { |
michael@0 | 30 | url: gSources.selectedValue, |
michael@0 | 31 | line: 6 |
michael@0 | 32 | }); |
michael@0 | 33 | yield doResume(gPanel); |
michael@0 | 34 | |
michael@0 | 35 | const bpHit = waitForCaretAndScopes(gPanel, 6); |
michael@0 | 36 | // Get the debuggee call off this tick so that we aren't accidentally |
michael@0 | 37 | // blocking the yielding of bpHit which causes a deadlock. |
michael@0 | 38 | executeSoon(() => gDebuggee.secondCall()); |
michael@0 | 39 | yield bpHit; |
michael@0 | 40 | |
michael@0 | 41 | info("Switch to the second source."); |
michael@0 | 42 | const sourceShown = waitForSourceShown(gPanel, SECOND_SOURCE_VALUE); |
michael@0 | 43 | gSources.selectedValue = SECOND_SOURCE_VALUE; |
michael@0 | 44 | yield sourceShown; |
michael@0 | 45 | |
michael@0 | 46 | info("Pretty print the source."); |
michael@0 | 47 | const prettyPrinted = waitForSourceShown(gPanel, SECOND_SOURCE_VALUE); |
michael@0 | 48 | gDebugger.document.getElementById("pretty-print").click(); |
michael@0 | 49 | yield prettyPrinted; |
michael@0 | 50 | |
michael@0 | 51 | yield resumeDebuggerThenCloseAndFinish(gPanel); |
michael@0 | 52 | } catch (e) { |
michael@0 | 53 | DevToolsUtils.reportException("browser_dbg_pretty-print-on-paused.js", e); |
michael@0 | 54 | ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e)); |
michael@0 | 55 | } |
michael@0 | 56 | }); |
michael@0 | 57 | }); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | registerCleanupFunction(function() { |
michael@0 | 61 | gTab = null; |
michael@0 | 62 | gDebuggee = null; |
michael@0 | 63 | gPanel = null; |
michael@0 | 64 | gDebugger = null; |
michael@0 | 65 | gThreadClient = null; |
michael@0 | 66 | gSources = null; |
michael@0 | 67 | }); |