|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests that anonymous functions appear in the stack frame list with either |
|
6 * their displayName property or a SpiderMonkey-inferred name. |
|
7 */ |
|
8 |
|
9 const TAB_URL = EXAMPLE_URL + "doc_function-display-name.html"; |
|
10 |
|
11 let gTab, gDebuggee, gPanel, gDebugger; |
|
12 |
|
13 function test() { |
|
14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
15 gTab = aTab; |
|
16 gDebuggee = aDebuggee; |
|
17 gPanel = aPanel; |
|
18 gDebugger = gPanel.panelWin; |
|
19 |
|
20 testAnonCall(); |
|
21 }); |
|
22 } |
|
23 |
|
24 function testAnonCall() { |
|
25 waitForSourceAndCaretAndScopes(gPanel, ".html", 15).then(() => { |
|
26 ok(isCaretPos(gPanel, 15), |
|
27 "The source editor caret position was incorrect."); |
|
28 is(gDebugger.gThreadClient.state, "paused", |
|
29 "Should only be getting stack frames while paused."); |
|
30 is(gDebugger.document.querySelectorAll(".dbg-stackframe").length, 3, |
|
31 "Should have three frames."); |
|
32 is(gDebugger.document.querySelector("#stackframe-0 .dbg-stackframe-title").getAttribute("value"), |
|
33 "anonFunc", "Frame name should be 'anonFunc'."); |
|
34 |
|
35 testInferredName(); |
|
36 }); |
|
37 |
|
38 gDebuggee.evalCall(); |
|
39 } |
|
40 |
|
41 function testInferredName() { |
|
42 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => { |
|
43 ok(isCaretPos(gPanel, 15), |
|
44 "The source editor caret position was incorrect."); |
|
45 is(gDebugger.gThreadClient.state, "paused", |
|
46 "Should only be getting stack frames while paused."); |
|
47 is(gDebugger.document.querySelectorAll(".dbg-stackframe").length, 3, |
|
48 "Should have three frames."); |
|
49 is(gDebugger.document.querySelector("#stackframe-0 .dbg-stackframe-title").getAttribute("value"), |
|
50 "a/<", "Frame name should be 'a/<'."); |
|
51 |
|
52 resumeDebuggerThenCloseAndFinish(gPanel); |
|
53 }); |
|
54 |
|
55 gDebugger.gThreadClient.resume(); |
|
56 } |
|
57 |
|
58 registerCleanupFunction(function() { |
|
59 gTab = null; |
|
60 gDebuggee = null; |
|
61 gPanel = null; |
|
62 gDebugger = null; |
|
63 }); |