зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 3240b92c5566 (bug 1545103) for failures in test_setBreakpoint-at-the-beginning-of-a-minified-fn.js
This commit is contained in:
Родитель
fbd81b661b
Коммит
cf310dc4ad
|
@ -14,6 +14,7 @@ const DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
|||
const { assert, fetch } = DevToolsUtils;
|
||||
const { joinURI } = require("devtools/shared/path");
|
||||
const { sourceSpec } = require("devtools/shared/specs/source");
|
||||
const { findClosestScriptBySource } = require("devtools/server/actors/utils/closest-scripts");
|
||||
|
||||
loader.lazyRequireGetter(this, "arrayBufferGrip", "devtools/server/actors/array-buffer", true);
|
||||
|
||||
|
@ -432,14 +433,14 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
applyBreakpoint: function(actor) {
|
||||
const { line, column } = actor.location;
|
||||
|
||||
// Find all scripts that match the given source actor and line
|
||||
// number.
|
||||
let scripts = this._findDebuggeeScripts({ line });
|
||||
scripts = scripts.filter((script) => !actor.hasScript(script));
|
||||
|
||||
// Find all entry points that correspond to the given location.
|
||||
const entryPoints = [];
|
||||
if (column === undefined) {
|
||||
// Find all scripts that match the given source actor and line
|
||||
// number.
|
||||
const scripts = this._findDebuggeeScripts({ line })
|
||||
.filter((script) => !actor.hasScript(script));
|
||||
|
||||
// This is a line breakpoint, so we add a breakpoint on the first
|
||||
// breakpoint on the line.
|
||||
const lineMatches = [];
|
||||
|
@ -465,23 +466,54 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
// Find all scripts that match the given source actor, line,
|
||||
// and column number.
|
||||
const scripts = this._findDebuggeeScripts({ line, column })
|
||||
.filter((script) => !actor.hasScript(script));
|
||||
// Compute columnToOffsetMaps for each script so that we can
|
||||
// find matching entrypoints for the column breakpoint.
|
||||
const columnToOffsetMaps = scripts.map(script =>
|
||||
[
|
||||
script,
|
||||
script.getPossibleBreakpoints({ line }),
|
||||
]
|
||||
);
|
||||
|
||||
for (const script of scripts) {
|
||||
// Check to see if the script contains a breakpoint position at
|
||||
// this line and column.
|
||||
const possibleBreakpoint = script.getPossibleBreakpoints({
|
||||
// This is a column breakpoint, so we are interested in all column
|
||||
// offsets that correspond to the given line *and* column number.
|
||||
for (const [script, columnToOffsetMap] of columnToOffsetMaps) {
|
||||
for (const { columnNumber, offset } of columnToOffsetMap) {
|
||||
if (columnNumber >= column && columnNumber <= column + 1) {
|
||||
entryPoints.push({ script, offsets: [offset] });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we don't find any matching entrypoints,
|
||||
// then we should see if the breakpoint comes before or after the column offsets.
|
||||
if (entryPoints.length === 0) {
|
||||
// It's not entirely clear if the scripts that make it here can come
|
||||
// from a variety of sources. This function allows filtering by URL
|
||||
// so it seems like it may be possible and we are erring on the side
|
||||
// of caution by handling it here.
|
||||
const closestScripts = findClosestScriptBySource(
|
||||
columnToOffsetMaps.map(pair => pair[0]),
|
||||
line,
|
||||
minColumn: column,
|
||||
maxColumn: column + 1,
|
||||
}).pop();
|
||||
column,
|
||||
);
|
||||
|
||||
if (possibleBreakpoint) {
|
||||
const { offset } = possibleBreakpoint;
|
||||
entryPoints.push({ script, offsets: [offset] });
|
||||
const columnToOffsetLookup = new Map(columnToOffsetMaps);
|
||||
for (const script of closestScripts) {
|
||||
const columnToOffsetMap = columnToOffsetLookup.get(script);
|
||||
|
||||
if (columnToOffsetMap.length > 0) {
|
||||
const firstColumnOffset = columnToOffsetMap[0];
|
||||
const lastColumnOffset = columnToOffsetMap[columnToOffsetMap.length - 1];
|
||||
|
||||
if (column < firstColumnOffset.columnNumber) {
|
||||
entryPoints.push({ script, offsets: [firstColumnOffset.offset] });
|
||||
}
|
||||
|
||||
if (column > lastColumnOffset.columnNumber) {
|
||||
entryPoints.push({ script, offsets: [lastColumnOffset.offset] });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { findSourceOffset } = require("devtools/server/actors/utils/dbg-source");
|
||||
|
||||
function findClosestScriptBySource(scripts, generatedLine, generatedColumn) {
|
||||
const bySource = new Map();
|
||||
for (const script of scripts) {
|
||||
const { source } = script;
|
||||
if (script.format !== "js" || !source) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let sourceScripts = bySource.get(source);
|
||||
if (!sourceScripts) {
|
||||
sourceScripts = [];
|
||||
bySource.set(source, sourceScripts);
|
||||
}
|
||||
|
||||
sourceScripts.push(script);
|
||||
}
|
||||
|
||||
const closestScripts = [];
|
||||
for (const sourceScripts of bySource.values()) {
|
||||
const closest = findClosestScript(sourceScripts, generatedLine, generatedColumn);
|
||||
if (closest) {
|
||||
closestScripts.push(closest);
|
||||
}
|
||||
}
|
||||
return closestScripts;
|
||||
}
|
||||
exports.findClosestScriptBySource = findClosestScriptBySource;
|
||||
|
||||
function findClosestScript(scripts, generatedLine, generatedColumn) {
|
||||
if (scripts.length === 0) {
|
||||
return null;
|
||||
}
|
||||
const { source } = scripts[0];
|
||||
|
||||
const offset = findSourceOffset(
|
||||
source,
|
||||
generatedLine,
|
||||
generatedColumn,
|
||||
);
|
||||
|
||||
let closest = null;
|
||||
for (const script of scripts) {
|
||||
if (script.source !== source) {
|
||||
throw new Error("All scripts must be from a single source.");
|
||||
}
|
||||
|
||||
if (
|
||||
offset >= script.sourceStart &&
|
||||
offset < script.sourceStart + script.sourceLength &&
|
||||
(!closest || script.sourceLength < closest.sourceLength)
|
||||
) {
|
||||
closest = script;
|
||||
}
|
||||
}
|
||||
|
||||
return closest;
|
||||
}
|
|
@ -9,6 +9,7 @@ DevToolsModules(
|
|||
'actor-registry-utils.js',
|
||||
'actor-registry.js',
|
||||
'breakpoint-actor-map.js',
|
||||
'closest-scripts.js',
|
||||
'css-grid-utils.js',
|
||||
'dbg-source.js',
|
||||
'event-breakpoints.js',
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
"use strict";
|
||||
|
||||
const SOURCE_URL = getFileUrl("setBreakpoint-on-column.js");
|
||||
|
||||
add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
|
||||
const promise = waitForNewSource(threadClient, SOURCE_URL);
|
||||
loadSubScript(SOURCE_URL, debuggee);
|
||||
const { source } = await promise;
|
||||
|
||||
const location = { sourceUrl: source.url, line: 4, column: 2 };
|
||||
setBreakpoint(threadClient, location);
|
||||
|
||||
const packet = await executeOnNextTickAndWaitForPause(function() {
|
||||
Cu.evalInSandbox("f()", debuggee);
|
||||
}, client);
|
||||
|
||||
Assert.equal(packet.type, "paused");
|
||||
const why = packet.why;
|
||||
Assert.equal(why.type, "breakpoint");
|
||||
Assert.equal(why.actors.length, 1);
|
||||
|
||||
const frame = packet.frame;
|
||||
Assert.equal(frame.where.actor, source.actor);
|
||||
Assert.equal(frame.where.line, location.line);
|
||||
Assert.equal(frame.where.column, 10);
|
||||
|
||||
const 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);
|
||||
}, { doNotRunWorker: true }));
|
|
@ -0,0 +1,34 @@
|
|||
"use strict";
|
||||
|
||||
const SOURCE_URL = getFileUrl("setBreakpoint-on-column.js");
|
||||
|
||||
add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
|
||||
const promise = waitForNewSource(threadClient, SOURCE_URL);
|
||||
loadSubScript(SOURCE_URL, debuggee);
|
||||
const { source } = await promise;
|
||||
|
||||
const location = { sourceUrl: source.url, line: 4, column: 42 };
|
||||
setBreakpoint(threadClient, location);
|
||||
|
||||
const packet = await executeOnNextTickAndWaitForPause(function() {
|
||||
Cu.evalInSandbox("f()", debuggee);
|
||||
}, client);
|
||||
|
||||
Assert.equal(packet.type, "paused");
|
||||
const why = packet.why;
|
||||
Assert.equal(why.type, "breakpoint");
|
||||
Assert.equal(why.actors.length, 1);
|
||||
|
||||
const frame = packet.frame;
|
||||
const where = frame.where;
|
||||
Assert.equal(where.actor, source.actor);
|
||||
Assert.equal(where.line, location.line);
|
||||
Assert.equal(where.column, 32);
|
||||
|
||||
const 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);
|
||||
}, { doNotRunWorker: true }));
|
|
@ -220,7 +220,9 @@ reason = bug 937197
|
|||
[test_get-executable-lines.js]
|
||||
[test_xpcshell_debugging.js]
|
||||
support-files = xpcshell_debugging_script.js
|
||||
[test_setBreakpoint-at-the-beginning-of-a-line.js]
|
||||
[test_setBreakpoint-at-the-beginning-of-a-minified-fn.js]
|
||||
[test_setBreakpoint-at-the-end-of-a-line.js]
|
||||
[test_setBreakpoint-at-the-end-of-a-minified-fn.js]
|
||||
[test_setBreakpoint-on-column.js]
|
||||
[test_setBreakpoint-on-column-in-gcd-script.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче