browser/devtools/debugger/test/browser_dbg_blackboxing-04.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:d6e3a854718a
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Test that we get a stack frame for each black boxed source, not a single one
6 * for all of them.
7 */
8
9 const TAB_URL = EXAMPLE_URL + "doc_blackboxing.html";
10 const BLACKBOXME_URL = EXAMPLE_URL + "code_blackboxing_blackboxme.js"
11
12 let gTab, gDebuggee, gPanel, gDebugger;
13 let gFrames;
14
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;
22
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 }
32
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 }
40
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 });
48
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 }
54
55 registerCleanupFunction(function() {
56 gTab = null;
57 gDebuggee = null;
58 gPanel = null;
59 gDebugger = null;
60 gFrames = null;
61 });

mercurial