Bug 1440093 - Breakpoints at the end of a line are missed. r=jimb

This commit is contained in:
Jason Laster 2018-02-22 12:28:00 +02:00
Родитель b741bb7d3c
Коммит 134c4753f6
6 изменённых файлов: 118 добавлений и 101 удалений

Просмотреть файл

@ -928,14 +928,20 @@ let SourceActor = ActorClassWithSpec(sourceSpec, {
} }
} }
// If we don't find any matching entrypoints, then // If we don't find any matching entrypoints,
// we should check to see if the breakpoint is to the left of the first offset. // then we should see if the breakpoint comes before or after the column offsets.
if (entryPoints.length === 0) { if (entryPoints.length === 0) {
for (let [script, columnToOffsetMap] of columnToOffsetMaps) { for (let [script, columnToOffsetMap] of columnToOffsetMaps) {
if (columnToOffsetMap.length > 0) { if (columnToOffsetMap.length > 0) {
let { columnNumber: column, offset } = columnToOffsetMap[0]; const firstColumnOffset = columnToOffsetMap[0];
if (generatedColumn < column) { const lastColumnOffset = columnToOffsetMap[columnToOffsetMap.length - 1];
entryPoints.push({ script, offsets: [offset] });
if (generatedColumn < firstColumnOffset.columnNumber) {
entryPoints.push({ script, offsets: [firstColumnOffset.offset] });
}
if (generatedColumn > lastColumnOffset.columnNumber) {
entryPoints.push({ script, offsets: [lastColumnOffset.offset] });
} }
} }
} }

Просмотреть файл

@ -1,6 +0,0 @@
"use strict";
function f() {
var a = 1; var b = 2;
var c = 3;
}

Просмотреть файл

@ -2,63 +2,58 @@
var SOURCE_URL = getFileUrl("setBreakpoint-on-column.js"); var SOURCE_URL = getFileUrl("setBreakpoint-on-column.js");
function run_test() { async function run_test() {
return async function () { do_test_pending();
do_test_pending(); DebuggerServer.registerModule("xpcshell-test/testactors");
DebuggerServer.init(() => true);
let global = createTestGlobal("test");
DebuggerServer.addTestGlobal(global);
DebuggerServer.registerModule("xpcshell-test/testactors"); let client = new DebuggerClient(DebuggerServer.connectPipe());
DebuggerServer.init(() => true); await connect(client);
let global = createTestGlobal("test"); let { tabs } = await listTabs(client);
DebuggerServer.addTestGlobal(global); let tab = findTab(tabs, "test");
let [, tabClient] = await attachTab(client, tab);
let [, threadClient] = await attachThread(tabClient);
await resume(threadClient);
let client = new DebuggerClient(DebuggerServer.connectPipe()); let promise = waitForNewSource(threadClient, SOURCE_URL);
await connect(client); loadSubScript(SOURCE_URL, global);
let { source } = await promise;
let sourceClient = threadClient.source(source);
let { tabs } = await listTabs(client); let location = { line: 4, column: 2 };
let tab = findTab(tabs, "test"); let [packet, breakpointClient] = await setBreakpoint(
let [, tabClient] = await attachTab(client, tab); sourceClient,
let [, threadClient] = await attachThread(tabClient); location
await resume(threadClient); );
let promise = waitForNewSource(threadClient, SOURCE_URL); Assert.ok(!packet.isPending);
loadSubScript(SOURCE_URL, global); Assert.equal(false, "actualLocation" in packet);
let { source } = await promise;
let sourceClient = threadClient.source(source);
let location = { line: 4, column: 2 }; packet = await executeOnNextTickAndWaitForPause(function () {
let [packet, breakpointClient] = await setBreakpoint( Cu.evalInSandbox("f()", global);
sourceClient, }, client);
location
);
Assert.ok(!packet.isPending); Assert.equal(packet.type, "paused");
Assert.equal(false, "actualLocation" in packet); let why = packet.why;
Assert.equal(why.type, "breakpoint");
Assert.equal(why.actors.length, 1);
Assert.equal(why.actors[0], breakpointClient.actor);
packet = await executeOnNextTickAndWaitForPause(function () { let frame = packet.frame;
Cu.evalInSandbox("f()", global); let where = frame.where;
}, client); Assert.equal(where.source.actor, source.actor);
Assert.equal(where.line, location.line);
Assert.equal(where.column, 6);
Assert.equal(packet.type, "paused"); let variables = frame.environment.bindings.variables;
let why = packet.why; Assert.equal(variables.a.value.type, "undefined");
Assert.equal(why.type, "breakpoint"); Assert.equal(variables.b.value.type, "undefined");
Assert.equal(why.actors.length, 1); Assert.equal(variables.c.value.type, "undefined");
Assert.equal(why.actors[0], breakpointClient.actor);
let frame = packet.frame; await resume(threadClient);
let where = frame.where; await close(client);
Assert.equal(where.source.actor, source.actor); do_test_finished();
Assert.equal(where.line, location.line);
Assert.equal(where.column, 6);
let variables = frame.environment.bindings.variables;
Assert.equal(variables.a.value.type, "undefined");
Assert.equal(variables.b.value.type, "undefined");
Assert.equal(variables.c.value.type, "undefined");
await resume(threadClient);
await close(client);
do_test_finished();
};
} }

Просмотреть файл

@ -0,0 +1,62 @@
"use strict";
var SOURCE_URL = getFileUrl("setBreakpoint-on-column.js");
async function run_test() {
do_test_pending();
DebuggerServer.registerModule("xpcshell-test/testactors");
DebuggerServer.init(() => true);
let global = createTestGlobal("test");
DebuggerServer.addTestGlobal(global);
let client = new DebuggerClient(DebuggerServer.connectPipe());
await connect(client);
let { tabs } = await listTabs(client);
let tab = findTab(tabs, "test");
let [, tabClient] = await attachTab(client, tab);
let [, threadClient] = await attachThread(tabClient);
await resume(threadClient);
let promise = waitForNewSource(threadClient, SOURCE_URL);
loadSubScript(SOURCE_URL, global);
let { source } = await promise;
let sourceClient = threadClient.source(source);
let location = { line: 4, column: 42 };
let [packet, breakpointClient] = await setBreakpoint(
sourceClient,
location
);
Assert.ok(!packet.isPending);
Assert.equal(false, "actualLocation" in packet);
packet = await executeOnNextTickAndWaitForPause(function () {
Cu.evalInSandbox("f()", global);
}, client);
Assert.equal(packet.type, "paused");
let why = packet.why;
Assert.equal(why.type, "breakpoint");
Assert.equal(why.actors.length, 1);
Assert.equal(why.actors[0], breakpointClient.actor);
let frame = packet.frame;
let where = frame.where;
Assert.equal(where.source.actor, source.actor);
Assert.equal(where.line, location.line);
Assert.equal(where.column, 28);
let variables = frame.environment.bindings.variables;
Assert.equal(variables.a.value, 1);
Assert.equal(variables.b.value, 2);
Assert.equal(variables.c.value.type, "undefined");
await resume(threadClient);
await close(client);
do_test_finished();
}

Просмотреть файл

@ -1,39 +0,0 @@
"use strict";
var SOURCE_URL = getFileUrl("setBreakpoint-on-column-with-no-offsets-at-end-of-line.js");
function run_test() {
return (async function () {
do_test_pending();
DebuggerServer.registerModule("xpcshell-test/testactors");
DebuggerServer.init(() => true);
let global = createTestGlobal("test");
DebuggerServer.addTestGlobal(global);
let client = new DebuggerClient(DebuggerServer.connectPipe());
await connect(client);
let { tabs } = await listTabs(client);
let tab = findTab(tabs, "test");
let [, tabClient] = await attachTab(client, tab);
let [, threadClient] = await attachThread(tabClient);
await resume(threadClient);
let promise = waitForNewSource(threadClient, SOURCE_URL);
loadSubScript(SOURCE_URL, global);
let { source } = await promise;
let sourceClient = threadClient.source(source);
let location = { line: 4, column: 23 };
let [packet, ] = await setBreakpoint(sourceClient, location);
Assert.ok(packet.isPending);
Assert.equal(false, "actualLocation" in packet);
Cu.evalInSandbox("f()", global);
await close(client);
do_test_finished();
})();
}

Просмотреть файл

@ -21,7 +21,6 @@ support-files =
setBreakpoint-on-column.js setBreakpoint-on-column.js
setBreakpoint-on-column-in-gcd-script.js setBreakpoint-on-column-in-gcd-script.js
setBreakpoint-on-column-with-no-offsets.js setBreakpoint-on-column-with-no-offsets.js
setBreakpoint-on-column-with-no-offsets-at-end-of-line.js
setBreakpoint-on-column-with-no-offsets-in-gcd-script.js setBreakpoint-on-column-with-no-offsets-in-gcd-script.js
setBreakpoint-on-line.js setBreakpoint-on-line.js
setBreakpoint-on-line-in-gcd-script.js setBreakpoint-on-line-in-gcd-script.js
@ -223,9 +222,9 @@ reason = bug 937197
[test_xpcshell_debugging.js] [test_xpcshell_debugging.js]
support-files = xpcshell_debugging_script.js support-files = xpcshell_debugging_script.js
[test_setBreakpoint-at-the-beginning-of-a-line.js] [test_setBreakpoint-at-the-beginning-of-a-line.js]
[test_setBreakpoint-at-the-end-of-a-line.js]
[test_setBreakpoint-on-column.js] [test_setBreakpoint-on-column.js]
[test_setBreakpoint-on-column-in-gcd-script.js] [test_setBreakpoint-on-column-in-gcd-script.js]
[test_setBreakpoint-on-column-with-no-offsets-at-end-of-line.js]
[test_setBreakpoint-on-line.js] [test_setBreakpoint-on-line.js]
[test_setBreakpoint-on-line-in-gcd-script.js] [test_setBreakpoint-on-line-in-gcd-script.js]
[test_setBreakpoint-on-line-with-multiple-offsets.js] [test_setBreakpoint-on-line-with-multiple-offsets.js]