browser/devtools/debugger/test/browser_dbg_pretty-print-08.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 /* -*- Mode: javascript; js-indent-level: 2; -*- */
michael@0 2 /* Any copyright is dedicated to the Public Domain.
michael@0 3 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 4
michael@0 5 // Test stepping through pretty printed sources.
michael@0 6
michael@0 7 let gTab, gDebuggee, gPanel, gClient, gThreadClient, gSource;
michael@0 8
michael@0 9 const TAB_URL = EXAMPLE_URL + "doc_pretty-print-2.html";
michael@0 10
michael@0 11 function test() {
michael@0 12 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
michael@0 13 gTab = aTab;
michael@0 14 gDebuggee = aDebuggee;
michael@0 15 gPanel = aPanel;
michael@0 16 gClient = gPanel.panelWin.gClient;
michael@0 17 gThreadClient = gPanel.panelWin.DebuggerController.activeThread;
michael@0 18
michael@0 19 gDebuggee.noop = x => x;
michael@0 20 findSource();
michael@0 21 });
michael@0 22 }
michael@0 23
michael@0 24 let CODE_URL;
michael@0 25
michael@0 26 const BP_LOCATION = {
michael@0 27 line: 5,
michael@0 28 column: 11
michael@0 29 };
michael@0 30
michael@0 31 function findSource() {
michael@0 32 gThreadClient.getSources(({ error, sources }) => {
michael@0 33 ok(!error);
michael@0 34 sources = sources.filter(s => s.url.contains("code_ugly-3.js"));
michael@0 35 is(sources.length, 1);
michael@0 36 [gSource] = sources;
michael@0 37 CODE_URL = BP_LOCATION.url = gSource.url;
michael@0 38
michael@0 39 prettyPrintSource(sources[0]);
michael@0 40 });
michael@0 41 }
michael@0 42
michael@0 43 function prettyPrintSource(source) {
michael@0 44 gThreadClient.source(gSource).prettyPrint(2, runCode);
michael@0 45 }
michael@0 46
michael@0 47 function runCode({ error }) {
michael@0 48 ok(!error);
michael@0 49 gClient.addOneTimeListener("paused", testDbgStatement);
michael@0 50 gDebuggee.main3();
michael@0 51 }
michael@0 52
michael@0 53 function testDbgStatement(event, { why, frame }) {
michael@0 54 is(why.type, "debuggerStatement");
michael@0 55 const { url, line, column } = frame.where;
michael@0 56 is(url, CODE_URL);
michael@0 57 is(line, 3);
michael@0 58 setBreakpoint();
michael@0 59 }
michael@0 60
michael@0 61 function setBreakpoint() {
michael@0 62 gThreadClient.setBreakpoint(BP_LOCATION, ({ error, actualLocation }) => {
michael@0 63 ok(!error);
michael@0 64 ok(!actualLocation);
michael@0 65 testStepping();
michael@0 66 });
michael@0 67 }
michael@0 68
michael@0 69 function testStepping() {
michael@0 70 gClient.addOneTimeListener("paused", (event, { why, frame }) => {
michael@0 71 is(why.type, "resumeLimit");
michael@0 72 const { url, line } = frame.where;
michael@0 73 is(url, CODE_URL);
michael@0 74 is(line, 4);
michael@0 75 testHitBreakpoint();
michael@0 76 });
michael@0 77 gThreadClient.stepIn();
michael@0 78 }
michael@0 79
michael@0 80 function testHitBreakpoint() {
michael@0 81 gClient.addOneTimeListener("paused", (event, { why, frame }) => {
michael@0 82 is(why.type, "breakpoint");
michael@0 83 const { url, line } = frame.where;
michael@0 84 is(url, CODE_URL);
michael@0 85 is(line, BP_LOCATION.line);
michael@0 86
michael@0 87 resumeDebuggerThenCloseAndFinish(gPanel);
michael@0 88 });
michael@0 89 gThreadClient.resume();
michael@0 90 }
michael@0 91
michael@0 92 registerCleanupFunction(function() {
michael@0 93 gTab = gDebuggee = gPanel = gClient = gThreadClient = gSource = null;
michael@0 94 });

mercurial