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