1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/server/tests/unit/test_breakpoint-06.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,76 @@ 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 + * Check that setting a breakpoint in a line without code in a deeply-nested 1.9 + * child script will skip forward. 1.10 + */ 1.11 + 1.12 +var gDebuggee; 1.13 +var gClient; 1.14 +var gThreadClient; 1.15 + 1.16 +function run_test() 1.17 +{ 1.18 + initTestDebuggerServer(); 1.19 + gDebuggee = addTestGlobal("test-stack"); 1.20 + gClient = new DebuggerClient(DebuggerServer.connectPipe()); 1.21 + gClient.connect(function () { 1.22 + attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { 1.23 + gThreadClient = aThreadClient; 1.24 + test_nested_breakpoint(); 1.25 + }); 1.26 + }); 1.27 + do_test_pending(); 1.28 +} 1.29 + 1.30 +function test_nested_breakpoint() 1.31 +{ 1.32 + gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { 1.33 + let path = getFilePath('test_breakpoint-06.js'); 1.34 + let location = { url: path, line: gDebuggee.line0 + 5}; 1.35 + gThreadClient.setBreakpoint(location, function (aResponse, bpClient) { 1.36 + // Check that the breakpoint has properly skipped forward one line. 1.37 + do_check_eq(aResponse.actualLocation.url, location.url); 1.38 + do_check_eq(aResponse.actualLocation.line, location.line + 1); 1.39 + gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { 1.40 + // Check the return value. 1.41 + do_check_eq(aPacket.type, "paused"); 1.42 + do_check_eq(aPacket.frame.where.url, path); 1.43 + do_check_eq(aPacket.frame.where.line, location.line + 1); 1.44 + do_check_eq(aPacket.why.type, "breakpoint"); 1.45 + do_check_eq(aPacket.why.actors[0], bpClient.actor); 1.46 + // Check that the breakpoint worked. 1.47 + do_check_eq(gDebuggee.a, 1); 1.48 + do_check_eq(gDebuggee.b, undefined); 1.49 + 1.50 + // Remove the breakpoint. 1.51 + bpClient.remove(function (aResponse) { 1.52 + gThreadClient.resume(function () { 1.53 + finishClient(gClient); 1.54 + }); 1.55 + }); 1.56 + 1.57 + }); 1.58 + // Continue until the breakpoint is hit. 1.59 + gThreadClient.resume(); 1.60 + 1.61 + }); 1.62 + 1.63 + }); 1.64 + 1.65 + gDebuggee.eval("var line0 = Error().lineNumber;\n" + 1.66 + "function foo() {\n" + // line0 + 1 1.67 + " function bar() {\n" + // line0 + 2 1.68 + " function baz() {\n" + // line0 + 3 1.69 + " this.a = 1;\n" + // line0 + 4 1.70 + " // A comment.\n" + // line0 + 5 1.71 + " this.b = 2;\n" + // line0 + 6 1.72 + " }\n" + // line0 + 7 1.73 + " baz();\n" + // line0 + 8 1.74 + " }\n" + // line0 + 9 1.75 + " bar();\n" + // line0 + 10 1.76 + "}\n" + // line0 + 11 1.77 + "debugger;\n" + // line0 + 12 1.78 + "foo();\n"); // line0 + 13 1.79 +}