зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 792fd0ab86d1 (bug 1503436) for failing damp at damp | debugger/custom.js on a CLOSED TREE
This commit is contained in:
Родитель
5b64e46782
Коммит
c27a20c873
|
@ -16,7 +16,6 @@ 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, "SourceMapConsumer", "source-map", true);
|
||||
loader.lazyRequireGetter(this, "SourceMapGenerator", "source-map", true);
|
||||
|
@ -979,20 +978,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
// 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]),
|
||||
generatedLine,
|
||||
generatedColumn,
|
||||
);
|
||||
|
||||
const columnToOffsetLookup = new Map(columnToOffsetMaps);
|
||||
for (const script of closestScripts) {
|
||||
const columnToOffsetMap = columnToOffsetLookup.get(script);
|
||||
|
||||
for (const [script, columnToOffsetMap] of columnToOffsetMaps) {
|
||||
if (columnToOffsetMap.length > 0) {
|
||||
const firstColumnOffset = columnToOffsetMap[0];
|
||||
const lastColumnOffset = columnToOffsetMap[columnToOffsetMap.length - 1];
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
/* 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;
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
/* 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";
|
||||
|
||||
/**
|
||||
* Get the source text offset equivalent to a given line/column pair.
|
||||
*
|
||||
* @param {Debugger.Source} source
|
||||
* @param {number} line The 1-based line number.
|
||||
* @param {number} column The 0-based column number.
|
||||
* @returns {number} The codepoint offset into the source's text.
|
||||
*/
|
||||
function findSourceOffset(source, line, column) {
|
||||
const offsets = getSourceLineOffsets(source);
|
||||
const offset = offsets[line - 1];
|
||||
|
||||
if (offset) {
|
||||
// Make sure that columns that technically don't exist in the line text
|
||||
// don't cause the offset to wrap to the next line.
|
||||
return Math.min(offset.start + column, offset.textEnd);
|
||||
}
|
||||
|
||||
return line < 0 ? 0 : offsets[offsets.length - 1].end;
|
||||
}
|
||||
exports.findSourceOffset = findSourceOffset;
|
||||
|
||||
const NEWLINE = /(\r?\n|\r|\u2028|\u2029)/g;
|
||||
const SOURCE_OFFSETS = new WeakMap();
|
||||
/**
|
||||
* Generate and cache line information for a given source to track what
|
||||
* text offsets mark the start and end of lines. Each entry in the array
|
||||
* represents a line in the source text.
|
||||
*
|
||||
* @param {Debugger.Source} source
|
||||
* @returns {Array<{ start, textEnd, end }>}
|
||||
* - start - The codepoint offset of the start of the line.
|
||||
* - textEnd - The codepoint offset just after the last non-newline character.
|
||||
* - end - The codepoint offset of the end of the line. This will be
|
||||
* be the same as the 'start' value of the next offset object,
|
||||
* and this includes the newlines for the line itself, where
|
||||
* 'textEnd' excludes newline characters.
|
||||
*/
|
||||
function getSourceLineOffsets(source) {
|
||||
const cached = SOURCE_OFFSETS.get(source);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const { text } = source;
|
||||
|
||||
const lines = text.split(NEWLINE);
|
||||
|
||||
const offsets = [];
|
||||
let offset = 0;
|
||||
for (let i = 0; i < lines.length; i += 2) {
|
||||
const line = lines[i];
|
||||
const start = offset;
|
||||
|
||||
// Calculate the end codepoint offset.
|
||||
let end = offset;
|
||||
for (const c of line) { // eslint-disable-line no-unused-vars
|
||||
end++;
|
||||
}
|
||||
const textEnd = end;
|
||||
|
||||
if (i + 1 < lines.length) {
|
||||
end += lines[i + 1].length;
|
||||
}
|
||||
|
||||
offsets.push(Object.freeze({ start, textEnd, end }));
|
||||
offset = end;
|
||||
}
|
||||
Object.freeze(offsets);
|
||||
|
||||
SOURCE_OFFSETS.set(source, offsets);
|
||||
return offsets;
|
||||
}
|
|
@ -12,9 +12,7 @@ DevToolsModules(
|
|||
'automation-timeline.js',
|
||||
'breakpoint-actor-map.js',
|
||||
'call-watcher.js',
|
||||
'closest-scripts.js',
|
||||
'css-grid-utils.js',
|
||||
'dbg-source.js',
|
||||
'event-loop.js',
|
||||
'function-call.js',
|
||||
'make-debugger.js',
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
function other(){ var a = 1; } function test(){ var a = 1; var b = 2; var c = 3; }
|
||||
|
||||
function f() {
|
||||
other();
|
||||
test();
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
var SOURCE_URL = getFileUrl("setBreakpoint-on-column-minified.js");
|
||||
|
||||
async function run_test() {
|
||||
do_test_pending();
|
||||
const { createRootActor } = require("xpcshell-test/testactors");
|
||||
DebuggerServer.setRootActor(createRootActor);
|
||||
DebuggerServer.init(() => true);
|
||||
const global = createTestGlobal("test");
|
||||
DebuggerServer.addTestGlobal(global);
|
||||
|
||||
const client = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
await connect(client);
|
||||
|
||||
const { tabs } = await listTabs(client);
|
||||
const tab = findTab(tabs, "test");
|
||||
const [, targetFront] = await attachTarget(client, tab);
|
||||
const [, threadClient] = await attachThread(targetFront);
|
||||
await resume(threadClient);
|
||||
|
||||
const promise = waitForNewSource(threadClient, SOURCE_URL);
|
||||
loadSubScript(SOURCE_URL, global);
|
||||
const { source } = await promise;
|
||||
const sourceClient = threadClient.source(source);
|
||||
|
||||
// Pause inside of the nested function so we can make sure that we don't
|
||||
// add any other breakpoints at other places on this line.
|
||||
const location = { line: 3, column: 47 };
|
||||
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");
|
||||
const why = packet.why;
|
||||
Assert.equal(why.type, "breakpoint");
|
||||
Assert.equal(why.actors.length, 1);
|
||||
Assert.equal(why.actors[0], breakpointClient.actor);
|
||||
|
||||
const frame = packet.frame;
|
||||
const where = frame.where;
|
||||
Assert.equal(where.source.actor, source.actor);
|
||||
Assert.equal(where.line, location.line);
|
||||
Assert.equal(where.column, 52);
|
||||
|
||||
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);
|
||||
await close(client);
|
||||
do_test_finished();
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
var SOURCE_URL = getFileUrl("setBreakpoint-on-column-minified.js");
|
||||
|
||||
async function run_test() {
|
||||
do_test_pending();
|
||||
const { createRootActor } = require("xpcshell-test/testactors");
|
||||
DebuggerServer.setRootActor(createRootActor);
|
||||
DebuggerServer.init(() => true);
|
||||
const global = createTestGlobal("test");
|
||||
DebuggerServer.addTestGlobal(global);
|
||||
|
||||
const client = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
await connect(client);
|
||||
|
||||
const { tabs } = await listTabs(client);
|
||||
const tab = findTab(tabs, "test");
|
||||
const [, targetFront] = await attachTarget(client, tab);
|
||||
const [, threadClient] = await attachThread(targetFront);
|
||||
await resume(threadClient);
|
||||
|
||||
const promise = waitForNewSource(threadClient, SOURCE_URL);
|
||||
loadSubScript(SOURCE_URL, global);
|
||||
const { source } = await promise;
|
||||
const sourceClient = threadClient.source(source);
|
||||
|
||||
// Pause inside of the nested function so we can make sure that we don't
|
||||
// add any other breakpoints at other places on this line.
|
||||
const location = { line: 3, column: 81 };
|
||||
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");
|
||||
const why = packet.why;
|
||||
Assert.equal(why.type, "breakpoint");
|
||||
Assert.equal(why.actors.length, 1);
|
||||
Assert.equal(why.actors[0], breakpointClient.actor);
|
||||
|
||||
const frame = packet.frame;
|
||||
const where = frame.where;
|
||||
Assert.equal(where.source.actor, source.actor);
|
||||
Assert.equal(where.line, location.line);
|
||||
Assert.equal(where.column, 81);
|
||||
|
||||
const variables = frame.environment.bindings.variables;
|
||||
Assert.equal(variables.a.value, 1);
|
||||
Assert.equal(variables.b.value, 2);
|
||||
Assert.equal(variables.c.value, 3);
|
||||
|
||||
await resume(threadClient);
|
||||
await close(client);
|
||||
do_test_finished();
|
||||
}
|
|
@ -19,7 +19,6 @@ support-files =
|
|||
hello-actor.js
|
||||
stepping.js
|
||||
setBreakpoint-on-column.js
|
||||
setBreakpoint-on-column-minified.js
|
||||
setBreakpoint-on-column-in-gcd-script.js
|
||||
setBreakpoint-on-column-with-no-offsets.js
|
||||
setBreakpoint-on-column-with-no-offsets-in-gcd-script.js
|
||||
|
@ -232,9 +231,7 @@ reason = bug 937197
|
|||
[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]
|
||||
[test_setBreakpoint-on-line.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче