1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/server/tests/unit/test_breakpoint-16.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,74 @@ 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 we can set breakpoints in columns, not just lines. 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-breakpoints"); 1.19 + gClient = new DebuggerClient(DebuggerServer.connectPipe()); 1.20 + gClient.connect(function () { 1.21 + attachTestTabAndResume(gClient, 1.22 + "test-breakpoints", 1.23 + function (aResponse, aTabClient, aThreadClient) { 1.24 + gThreadClient = aThreadClient; 1.25 + test_column_breakpoint(); 1.26 + }); 1.27 + }); 1.28 + do_test_pending(); 1.29 +} 1.30 + 1.31 +function test_column_breakpoint() 1.32 +{ 1.33 + const location = { 1.34 + url: "https://example.com/foo.js", 1.35 + line: 1, 1.36 + column: 55 1.37 + }; 1.38 + 1.39 + // Debugger statement 1.40 + gClient.addOneTimeListener("paused", function (aEvent, aPacket) { 1.41 + let timesBreakpointHit = 0; 1.42 + 1.43 + gThreadClient.setBreakpoint(location, function (aResponse, bpClient) { 1.44 + gThreadClient.addListener("paused", function _onPaused(aEvent, aPacket) { 1.45 + do_check_eq(aPacket.type, "paused"); 1.46 + do_check_eq(aPacket.why.type, "breakpoint"); 1.47 + do_check_eq(aPacket.why.actors[0], bpClient.actor); 1.48 + do_check_eq(aPacket.frame.where.url, location.url); 1.49 + do_check_eq(aPacket.frame.where.line, location.line); 1.50 + do_check_eq(aPacket.frame.where.column, location.column); 1.51 + 1.52 + do_check_eq(gDebuggee.acc, timesBreakpointHit); 1.53 + do_check_eq(aPacket.frame.environment.bindings.variables.i.value, 1.54 + timesBreakpointHit); 1.55 + 1.56 + if (++timesBreakpointHit === 3) { 1.57 + gThreadClient.removeListener("paused", _onPaused); 1.58 + bpClient.remove(function (aResponse) { 1.59 + gThreadClient.resume(() => finishClient(gClient)); 1.60 + }); 1.61 + } else { 1.62 + gThreadClient.resume(); 1.63 + } 1.64 + }); 1.65 + 1.66 + // Continue until the breakpoint is hit. 1.67 + gThreadClient.resume(); 1.68 + }); 1.69 + 1.70 + }); 1.71 + 1.72 + let code = 1.73 +"(function () { debugger; this.acc = 0; for (let i = 0; i < 3; i++) this.acc++; }());"; 1.74 + 1.75 + Components.utils.evalInSandbox(code, gDebuggee, "1.8", 1.76 + location.url, 1); 1.77 +}