1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_iframes.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests that iframes can be added as debuggees. 1.9 + */ 1.10 + 1.11 +const TAB_URL = EXAMPLE_URL + "doc_iframes.html"; 1.12 + 1.13 +function test() { 1.14 + let gTab, gDebuggee, gPanel, gDebugger; 1.15 + let gIframe, gEditor, gSources, gFrames; 1.16 + 1.17 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.18 + gTab = aTab; 1.19 + gDebuggee = aDebuggee; 1.20 + gPanel = aPanel; 1.21 + gDebugger = gPanel.panelWin; 1.22 + gIframe = gDebuggee.frames[0]; 1.23 + gEditor = gDebugger.DebuggerView.editor; 1.24 + gSources = gDebugger.DebuggerView.Sources; 1.25 + gFrames = gDebugger.DebuggerView.StackFrames; 1.26 + 1.27 + waitForSourceShown(gPanel, "inline-debugger-statement.html") 1.28 + .then(checkIframeSource) 1.29 + .then(checkIframePause) 1.30 + .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) 1.31 + .then(null, aError => { 1.32 + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); 1.33 + }); 1.34 + }); 1.35 + 1.36 + function checkIframeSource() { 1.37 + is(gDebugger.gThreadClient.paused, false, 1.38 + "Should be running after starting the test."); 1.39 + 1.40 + ok(isCaretPos(gPanel, 1), 1.41 + "The source editor caret position was incorrect."); 1.42 + is(gFrames.itemCount, 0, 1.43 + "Should have only no frames."); 1.44 + 1.45 + is(gSources.itemCount, 1, 1.46 + "Found the expected number of entries in the sources widget."); 1.47 + is(gEditor.getText().indexOf("debugger"), 348, 1.48 + "The correct source was loaded initially."); 1.49 + is(gSources.selectedValue, EXAMPLE_URL + "doc_inline-debugger-statement.html", 1.50 + "The currently selected source value is incorrect (0)."); 1.51 + is(gSources.selectedValue, gSources.values[0], 1.52 + "The currently selected source value is incorrect (1)."); 1.53 + } 1.54 + 1.55 + function checkIframePause() { 1.56 + // Spin the event loop before causing the debuggee to pause, to allow 1.57 + // this function to return first. 1.58 + executeSoon(() => gIframe.runDebuggerStatement()); 1.59 + 1.60 + return waitForCaretAndScopes(gPanel, 16).then(() => { 1.61 + is(gDebugger.gThreadClient.paused, true, 1.62 + "Should be paused after an interrupt request."); 1.63 + 1.64 + ok(isCaretPos(gPanel, 16), 1.65 + "The source editor caret position was incorrect."); 1.66 + is(gFrames.itemCount, 1, 1.67 + "Should have only one frame."); 1.68 + }); 1.69 + } 1.70 +}