michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Test that when we add 2 breakpoints to the same line at different columns and michael@0: * then remove one of them, we don't remove them both. michael@0: */ michael@0: michael@0: var gDebuggee; michael@0: var gClient; michael@0: var gThreadClient; michael@0: michael@0: function run_test() michael@0: { michael@0: initTestDebuggerServer(); michael@0: gDebuggee = addTestGlobal("test-breakpoints"); michael@0: gClient = new DebuggerClient(DebuggerServer.connectPipe()); michael@0: gClient.connect(function() { michael@0: attachTestTabAndResume(gClient, "test-breakpoints", function(aResponse, aTabClient, aThreadClient) { michael@0: gThreadClient = aThreadClient; michael@0: test_breakpoints_columns(); michael@0: }); michael@0: }); michael@0: do_test_pending(); michael@0: } michael@0: michael@0: const URL = "http://example.com/benderbendingrodriguez.js"; michael@0: michael@0: const code = michael@0: "(" + function (global) { michael@0: global.foo = function () { michael@0: Math.abs(-1); Math.log(0.5); michael@0: debugger; michael@0: }; michael@0: debugger; michael@0: } + "(this))"; michael@0: michael@0: const firstLocation = { michael@0: url: URL, michael@0: line: 3, michael@0: column: 4 michael@0: }; michael@0: michael@0: const secondLocation = { michael@0: url: URL, michael@0: line: 3, michael@0: column: 18 michael@0: }; michael@0: michael@0: function test_breakpoints_columns() { michael@0: gClient.addOneTimeListener("paused", set_breakpoints); michael@0: michael@0: Components.utils.evalInSandbox(code, gDebuggee, "1.8", URL, 1); michael@0: } michael@0: michael@0: function set_breakpoints() { michael@0: let first, second; michael@0: michael@0: gThreadClient.setBreakpoint(firstLocation, function ({ error, actualLocation }, michael@0: aBreakpointClient) { michael@0: do_check_true(!error, "Should not get an error setting the breakpoint"); michael@0: do_check_true(!actualLocation, "Should not get an actualLocation"); michael@0: first = aBreakpointClient; michael@0: michael@0: gThreadClient.setBreakpoint(secondLocation, function ({ error, actualLocation }, michael@0: aBreakpointClient) { michael@0: do_check_true(!error, "Should not get an error setting the breakpoint"); michael@0: do_check_true(!actualLocation, "Should not get an actualLocation"); michael@0: second = aBreakpointClient; michael@0: michael@0: test_different_actors(first, second); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function test_different_actors(aFirst, aSecond) { michael@0: do_check_neq(aFirst.actor, aSecond.actor, michael@0: "Each breakpoint should have a different actor"); michael@0: test_remove_one(aFirst, aSecond); michael@0: } michael@0: michael@0: function test_remove_one(aFirst, aSecond) { michael@0: aFirst.remove(function ({error}) { michael@0: do_check_true(!error, "Should not get an error removing a breakpoint"); michael@0: michael@0: let hitSecond; michael@0: gClient.addListener("paused", function _onPaused(aEvent, {why, frame}) { michael@0: if (why.type == "breakpoint") { michael@0: hitSecond = true; michael@0: do_check_eq(why.actors.length, 1, michael@0: "Should only be paused because of one breakpoint actor"); michael@0: do_check_eq(why.actors[0], aSecond.actor, michael@0: "Should be paused because of the correct breakpoint actor"); michael@0: do_check_eq(frame.where.line, secondLocation.line, michael@0: "Should be at the right line"); michael@0: do_check_eq(frame.where.column, secondLocation.column, michael@0: "Should be at the right column"); michael@0: gThreadClient.resume(); michael@0: return; michael@0: } michael@0: michael@0: if (why.type == "debuggerStatement") { michael@0: gClient.removeListener("paused", _onPaused); michael@0: do_check_true(hitSecond, michael@0: "We should still hit `second`, but not `first`."); michael@0: michael@0: finishClient(gClient); michael@0: return; michael@0: } michael@0: michael@0: do_check_true(false, "Should never get here"); michael@0: }); michael@0: michael@0: gThreadClient.resume(() => gDebuggee.foo()); michael@0: }); michael@0: }