browser/devtools/debugger/test/browser_dbg_iframes.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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

mercurial