browser/devtools/debugger/test/browser_dbg_iframes.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:d59b61d610e9
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Tests that iframes can be added as debuggees.
6 */
7
8 const TAB_URL = EXAMPLE_URL + "doc_iframes.html";
9
10 function test() {
11 let gTab, gDebuggee, gPanel, gDebugger;
12 let gIframe, gEditor, gSources, gFrames;
13
14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
15 gTab = aTab;
16 gDebuggee = aDebuggee;
17 gPanel = aPanel;
18 gDebugger = gPanel.panelWin;
19 gIframe = gDebuggee.frames[0];
20 gEditor = gDebugger.DebuggerView.editor;
21 gSources = gDebugger.DebuggerView.Sources;
22 gFrames = gDebugger.DebuggerView.StackFrames;
23
24 waitForSourceShown(gPanel, "inline-debugger-statement.html")
25 .then(checkIframeSource)
26 .then(checkIframePause)
27 .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
28 .then(null, aError => {
29 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
30 });
31 });
32
33 function checkIframeSource() {
34 is(gDebugger.gThreadClient.paused, false,
35 "Should be running after starting the test.");
36
37 ok(isCaretPos(gPanel, 1),
38 "The source editor caret position was incorrect.");
39 is(gFrames.itemCount, 0,
40 "Should have only no frames.");
41
42 is(gSources.itemCount, 1,
43 "Found the expected number of entries in the sources widget.");
44 is(gEditor.getText().indexOf("debugger"), 348,
45 "The correct source was loaded initially.");
46 is(gSources.selectedValue, EXAMPLE_URL + "doc_inline-debugger-statement.html",
47 "The currently selected source value is incorrect (0).");
48 is(gSources.selectedValue, gSources.values[0],
49 "The currently selected source value is incorrect (1).");
50 }
51
52 function checkIframePause() {
53 // Spin the event loop before causing the debuggee to pause, to allow
54 // this function to return first.
55 executeSoon(() => gIframe.runDebuggerStatement());
56
57 return waitForCaretAndScopes(gPanel, 16).then(() => {
58 is(gDebugger.gThreadClient.paused, true,
59 "Should be paused after an interrupt request.");
60
61 ok(isCaretPos(gPanel, 16),
62 "The source editor caret position was incorrect.");
63 is(gFrames.itemCount, 1,
64 "Should have only one frame.");
65 });
66 }
67 }

mercurial