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 we get a stack frame for each black boxed source, not a single one
6 * for all of them.
7 */
9 const TAB_URL = EXAMPLE_URL + "doc_blackboxing.html";
10 const BLACKBOXME_URL = EXAMPLE_URL + "code_blackboxing_blackboxme.js"
12 let gTab, gDebuggee, gPanel, gDebugger;
13 let gFrames;
15 function test() {
16 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
17 gTab = aTab;
18 gDebuggee = aDebuggee;
19 gPanel = aPanel;
20 gDebugger = gPanel.panelWin;
21 gFrames = gDebugger.DebuggerView.StackFrames;
23 waitForSourceShown(gPanel, BLACKBOXME_URL)
24 .then(blackBoxSources)
25 .then(testBlackBoxStack)
26 .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
27 .then(null, aError => {
28 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
29 });
30 });
31 }
33 function blackBoxSources() {
34 let finished = waitForThreadEvents(gPanel, "blackboxchange", 3);
35 toggleBlackBoxing(gPanel, EXAMPLE_URL + "code_blackboxing_one.js");
36 toggleBlackBoxing(gPanel, EXAMPLE_URL + "code_blackboxing_two.js");
37 toggleBlackBoxing(gPanel, EXAMPLE_URL + "code_blackboxing_three.js");
38 return finished;
39 }
41 function testBlackBoxStack() {
42 let finished = waitForSourceAndCaretAndScopes(gPanel, ".html", 21).then(() => {
43 is(gFrames.itemCount, 4,
44 "Should get 4 frames (one -> two -> three -> doDebuggerStatement).");
45 is(gDebugger.document.querySelectorAll(".dbg-stackframe-black-boxed").length, 3,
46 "And 'one', 'two', and 'three' should each have their own black boxed frame.");
47 });
49 // Spin the event loop before causing the debuggee to pause, to allow
50 // this function to return first.
51 executeSoon(() => gDebuggee.one());
52 return finished;
53 }
55 registerCleanupFunction(function() {
56 gTab = null;
57 gDebuggee = null;
58 gPanel = null;
59 gDebugger = null;
60 gFrames = null;
61 });