1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_pretty-print-08.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,94 @@ 1.4 +/* -*- Mode: javascript; js-indent-level: 2; -*- */ 1.5 +/* Any copyright is dedicated to the Public Domain. 1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.7 + 1.8 +// Test stepping through pretty printed sources. 1.9 + 1.10 +let gTab, gDebuggee, gPanel, gClient, gThreadClient, gSource; 1.11 + 1.12 +const TAB_URL = EXAMPLE_URL + "doc_pretty-print-2.html"; 1.13 + 1.14 +function test() { 1.15 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.16 + gTab = aTab; 1.17 + gDebuggee = aDebuggee; 1.18 + gPanel = aPanel; 1.19 + gClient = gPanel.panelWin.gClient; 1.20 + gThreadClient = gPanel.panelWin.DebuggerController.activeThread; 1.21 + 1.22 + gDebuggee.noop = x => x; 1.23 + findSource(); 1.24 + }); 1.25 +} 1.26 + 1.27 +let CODE_URL; 1.28 + 1.29 +const BP_LOCATION = { 1.30 + line: 5, 1.31 + column: 11 1.32 +}; 1.33 + 1.34 +function findSource() { 1.35 + gThreadClient.getSources(({ error, sources }) => { 1.36 + ok(!error); 1.37 + sources = sources.filter(s => s.url.contains("code_ugly-3.js")); 1.38 + is(sources.length, 1); 1.39 + [gSource] = sources; 1.40 + CODE_URL = BP_LOCATION.url = gSource.url; 1.41 + 1.42 + prettyPrintSource(sources[0]); 1.43 + }); 1.44 +} 1.45 + 1.46 +function prettyPrintSource(source) { 1.47 + gThreadClient.source(gSource).prettyPrint(2, runCode); 1.48 +} 1.49 + 1.50 +function runCode({ error }) { 1.51 + ok(!error); 1.52 + gClient.addOneTimeListener("paused", testDbgStatement); 1.53 + gDebuggee.main3(); 1.54 +} 1.55 + 1.56 +function testDbgStatement(event, { why, frame }) { 1.57 + is(why.type, "debuggerStatement"); 1.58 + const { url, line, column } = frame.where; 1.59 + is(url, CODE_URL); 1.60 + is(line, 3); 1.61 + setBreakpoint(); 1.62 +} 1.63 + 1.64 +function setBreakpoint() { 1.65 + gThreadClient.setBreakpoint(BP_LOCATION, ({ error, actualLocation }) => { 1.66 + ok(!error); 1.67 + ok(!actualLocation); 1.68 + testStepping(); 1.69 + }); 1.70 +} 1.71 + 1.72 +function testStepping() { 1.73 + gClient.addOneTimeListener("paused", (event, { why, frame }) => { 1.74 + is(why.type, "resumeLimit"); 1.75 + const { url, line } = frame.where; 1.76 + is(url, CODE_URL); 1.77 + is(line, 4); 1.78 + testHitBreakpoint(); 1.79 + }); 1.80 + gThreadClient.stepIn(); 1.81 +} 1.82 + 1.83 +function testHitBreakpoint() { 1.84 + gClient.addOneTimeListener("paused", (event, { why, frame }) => { 1.85 + is(why.type, "breakpoint"); 1.86 + const { url, line } = frame.where; 1.87 + is(url, CODE_URL); 1.88 + is(line, BP_LOCATION.line); 1.89 + 1.90 + resumeDebuggerThenCloseAndFinish(gPanel); 1.91 + }); 1.92 + gThreadClient.resume(); 1.93 +} 1.94 + 1.95 +registerCleanupFunction(function() { 1.96 + gTab = gDebuggee = gPanel = gClient = gThreadClient = gSource = null; 1.97 +});