Commit a81e8d16 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by V8 LUCI CQ

[inspector] Correct location for inline scripts with sourceURL.

Previously the `Debugger.CallFrame`s in `Debugger.paused` events would
report locations relative to the surrounding document in case of inline
scripts with `//@ sourceURL` annotations (while `Runtime.CallFrame` was
already fixed previously as part of crrev.com/c/3069289). With this CL
the locations in `Debugger.CallFrame` are also appropriately adjusted.

Drive-by-fix: Several inspector tests were (incorrectly) relying on this
wrong treatment, and were also unnecessarily using //# sourceURL
annotations. So part of this CL also addresses that problem and makes
the tests more robust, using addInlineScript() helper.

Fixed: chromium:1283049
Bug: chromium:1183990, chromium:578269
Change-Id: I6e3b215d951c3453c0a9cfc9bccf3dc3d5e92fd6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3359619
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78450}
parent 09dc239a
...@@ -505,6 +505,10 @@ Location Script::GetSourceLocation(int offset) const { ...@@ -505,6 +505,10 @@ Location Script::GetSourceLocation(int offset) const {
i::Handle<i::Script> script = Utils::OpenHandle(this); i::Handle<i::Script> script = Utils::OpenHandle(this);
i::Script::PositionInfo info; i::Script::PositionInfo info;
i::Script::GetPositionInfo(script, offset, &info, i::Script::WITH_OFFSET); i::Script::GetPositionInfo(script, offset, &info, i::Script::WITH_OFFSET);
if (script->HasSourceURLComment()) {
info.line -= script->line_offset();
if (info.line == 0) info.column -= script->column_offset();
}
return Location(info.line, info.column); return Location(info.line, info.column);
} }
......
...@@ -9,12 +9,12 @@ test (test.js:21:2) ...@@ -9,12 +9,12 @@ test (test.js:21:2)
foo (test.js:10:2) foo (test.js:10:2)
-- Promise.then -- -- Promise.then --
test (test.js:12:14) test (test.js:19:14)
(anonymous) (expr1.js:0:0) (anonymous) (expr1.js:0:0)
foo (test.js:12:2) foo (test.js:12:2)
-- Promise.then -- -- Promise.then --
test (test.js:12:14) test (test.js:19:14)
(anonymous) (expr1.js:0:0) (anonymous) (expr1.js:0:0)
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
let {session, contextGroup, Protocol} = InspectorTest.start('Checks async instrumentation enabled in the middle.'); let {session, contextGroup, Protocol} = InspectorTest.start('Checks async instrumentation enabled in the middle.');
contextGroup.addScript(` contextGroup.addInlineScript(
`
function foo() { function foo() {
// asyncTaskStarted // asyncTaskStarted
debugger; debugger;
...@@ -20,9 +21,8 @@ function test() { ...@@ -20,9 +21,8 @@ function test() {
resolve1(); // asyncTaskScheduled resolve1(); // asyncTaskScheduled
debugger; debugger;
return p2; return p2;
} }`,
'test.js');
//# sourceURL=test.js`, 7, 26);
session.setupScriptMap(); session.setupScriptMap();
Protocol.Debugger.onPaused(message => { Protocol.Debugger.onPaused(message => {
......
Checks async stack for late .then handlers with gc Checks async stack for late .then handlers with gc
foo1 (test.js:11:2) foo1 (test.js:11:2)
-- Promise.then -- -- Promise.then --
test (test.js:10:14) test (test.js:18:14)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
foo1 (test.js:11:2) foo1 (test.js:11:2)
-- Promise.then -- -- Promise.then --
test (test.js:14:14) test (test.js:22:14)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
foo1 (test.js:11:2) foo1 (test.js:11:2)
-- Promise.then -- -- Promise.then --
test (test.js:16:14) test (test.js:24:14)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
let {session, contextGroup, Protocol} = InspectorTest.start('Checks async stack for late .then handlers with gc'); let {session, contextGroup, Protocol} = InspectorTest.start('Checks async stack for late .then handlers with gc');
contextGroup.addScript(` contextGroup.addInlineScript(
`
function foo1() { function foo1() {
gc(); gc();
debugger; debugger;
...@@ -24,8 +25,8 @@ function test() { ...@@ -24,8 +25,8 @@ function test() {
var p4 = p1.then(foo1); var p4 = p1.then(foo1);
gc(); gc();
return Promise.all([p2,p3,p4]); return Promise.all([p2,p3,p4]);
} }`,
//# sourceURL=test.js`, 8, 26); 'test.js');
session.setupScriptMap(); session.setupScriptMap();
Protocol.Debugger.onPaused(message => { Protocol.Debugger.onPaused(message => {
......
...@@ -2,10 +2,10 @@ Checks that async stack contains setTimeout ...@@ -2,10 +2,10 @@ Checks that async stack contains setTimeout
inner1 (test.js:11:4) inner1 (test.js:11:4)
foo1 (test.js:14:2) foo1 (test.js:14:2)
-- setTimeout -- -- setTimeout --
inner2 (test.js:11:4) inner2 (test.js:18:4)
foo2 (test.js:13:2) foo2 (test.js:20:2)
-- setTimeout -- -- setTimeout --
inner3 (test.js:18:4) inner3 (test.js:25:4)
foo3 (test.js:20:2) foo3 (test.js:27:2)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that async stack contains setTimeout'); let {session, contextGroup, Protocol} = InspectorTest.start('Checks that async stack contains setTimeout');
contextGroup.addScript(` contextGroup.addInlineScript(
`
var resolveCallback; var resolveCallback;
function foo1() { function foo1() {
function inner1() { function inner1() {
...@@ -26,8 +27,8 @@ function foo3() { ...@@ -26,8 +27,8 @@ function foo3() {
} }
inner3(); inner3();
return promise; return promise;
} }`,
//# sourceURL=test.js`, 7, 26); 'test.js');
session.setupScriptMap(); session.setupScriptMap();
Protocol.Debugger.onPaused(message => { Protocol.Debugger.onPaused(message => {
......
...@@ -3,78 +3,78 @@ Checks created frame for async call chain ...@@ -3,78 +3,78 @@ Checks created frame for async call chain
Running test: testPromise Running test: testPromise
foo1 (test.js:10:2) foo1 (test.js:10:2)
-- Promise.then -- -- Promise.then --
promise (test.js:12:14) promise (test.js:20:14)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Running test: testPromiseThen Running test: testPromiseThen
foo1 (test.js:10:2) foo1 (test.js:10:2)
-- Promise.then -- -- Promise.then --
promiseThen (test.js:20:14) promiseThen (test.js:28:14)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
foo2 (test.js:14:2) foo2 (test.js:14:2)
-- Promise.then -- -- Promise.then --
promiseThen (test.js:21:14) promiseThen (test.js:29:14)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Running test: testPromiseThenThen Running test: testPromiseThenThen
foo1 (test.js:10:2) foo1 (test.js:10:2)
-- Promise.then -- -- Promise.then --
promiseThenThen (test.js:29:14) promiseThenThen (test.js:37:14)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
foo1 (test.js:10:2) foo1 (test.js:10:2)
-- Promise.then -- -- Promise.then --
promiseThenThen (test.js:30:14) promiseThenThen (test.js:38:14)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
foo2 (test.js:14:2) foo2 (test.js:14:2)
-- Promise.then -- -- Promise.then --
promiseThenThen (test.js:29:25) promiseThenThen (test.js:37:25)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Running test: testPromiseResolve Running test: testPromiseResolve
foo1 (test.js:10:2) foo1 (test.js:10:2)
-- Promise.then -- -- Promise.then --
promiseResolve (test.js:36:27) promiseResolve (test.js:44:27)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Running test: testPromiseReject Running test: testPromiseReject
foo1 (test.js:10:2) foo1 (test.js:10:2)
-- Promise.catch -- -- Promise.catch --
promiseReject (test.js:40:31) promiseReject (test.js:48:31)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Running test: testPromiseAll Running test: testPromiseAll
foo1 (test.js:10:2) foo1 (test.js:10:2)
-- Promise.then -- -- Promise.then --
promiseAll (test.js:44:44) promiseAll (test.js:52:44)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Running test: testPromiseRace Running test: testPromiseRace
foo1 (test.js:10:2) foo1 (test.js:10:2)
-- Promise.then -- -- Promise.then --
promiseRace (test.js:48:45) promiseRace (test.js:56:45)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Running test: testThenableJob1 Running test: testThenableJob1
foo1 (test.js:10:2) foo1 (test.js:10:2)
-- Promise.then -- -- Promise.then --
thenableJob1 (test.js:52:72) thenableJob1 (test.js:60:72)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Running test: testThenableJob2 Running test: testThenableJob2
foo1 (test.js:10:2) foo1 (test.js:10:2)
-- Promise.then -- -- Promise.then --
thenableJob2 (test.js:56:57) thenableJob2 (test.js:64:57)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
...@@ -82,10 +82,10 @@ Running test: testSetTimeouts ...@@ -82,10 +82,10 @@ Running test: testSetTimeouts
foo1 (test.js:10:2) foo1 (test.js:10:2)
(anonymous) (test.js:72:25) (anonymous) (test.js:72:25)
-- setTimeout -- -- setTimeout --
(anonymous) (test.js:64:6) (anonymous) (test.js:72:6)
-- setTimeout -- -- setTimeout --
(anonymous) (test.js:63:4) (anonymous) (test.js:71:4)
-- setTimeout -- -- setTimeout --
setTimeouts (test.js:62:2) setTimeouts (test.js:70:2)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// TODO(kozyatinskiy): fix this test. // TODO(kozyatinskiy): fix this test.
let {session, contextGroup, Protocol} = InspectorTest.start('Checks created frame for async call chain'); let {session, contextGroup, Protocol} = InspectorTest.start('Checks created frame for async call chain');
contextGroup.addScript( contextGroup.addInlineScript(
` `
function foo1() { function foo1() {
debugger; debugger;
...@@ -72,10 +72,8 @@ function setTimeouts() { ...@@ -72,10 +72,8 @@ function setTimeouts() {
setTimeout(() => setTimeout(() =>
setTimeout(() => { foo1(); resolve(); }, 0), 0), 0); setTimeout(() => { foo1(); resolve(); }, 0), 0), 0);
return p; return p;
} }`,
'test.js');
//# sourceURL=test.js`,
8, 4);
session.setupScriptMap(); session.setupScriptMap();
Protocol.Debugger.onPaused(message => { Protocol.Debugger.onPaused(message => {
......
...@@ -3,94 +3,94 @@ Checks that async chains for promises are correct. ...@@ -3,94 +3,94 @@ Checks that async chains for promises are correct.
Running test: testPromise Running test: testPromise
foo1 (test.js:9:2) foo1 (test.js:9:2)
-- Promise.then -- -- Promise.then --
promise (test.js:12:14) promise (test.js:19:14)
(anonymous) (testPromise.js:0:0) (anonymous) (testPromise.js:0:0)
Running test: testPromiseResolvedBySetTimeout Running test: testPromiseResolvedBySetTimeout
foo1 (test.js:9:2) foo1 (test.js:9:2)
-- Promise.then -- -- Promise.then --
promiseResolvedBySetTimeout (test.js:20:14) promiseResolvedBySetTimeout (test.js:27:14)
(anonymous) (testPromiseResolvedBySetTimeout.js:0:0) (anonymous) (testPromiseResolvedBySetTimeout.js:0:0)
Running test: testPromiseAll Running test: testPromiseAll
foo1 (test.js:9:2) foo1 (test.js:9:2)
-- Promise.then -- -- Promise.then --
promiseAll (test.js:30:35) promiseAll (test.js:37:35)
(anonymous) (testPromiseAll.js:0:0) (anonymous) (testPromiseAll.js:0:0)
Running test: testPromiseAllReverseOrder Running test: testPromiseAllReverseOrder
foo1 (test.js:9:2) foo1 (test.js:9:2)
-- Promise.then -- -- Promise.then --
promiseAllReverseOrder (test.js:41:35) promiseAllReverseOrder (test.js:48:35)
(anonymous) (testPromiseAllReverseOrder.js:0:0) (anonymous) (testPromiseAllReverseOrder.js:0:0)
Running test: testPromiseRace Running test: testPromiseRace
foo1 (test.js:9:2) foo1 (test.js:9:2)
-- Promise.then -- -- Promise.then --
promiseRace (test.js:52:36) promiseRace (test.js:59:36)
(anonymous) (testPromiseRace.js:0:0) (anonymous) (testPromiseRace.js:0:0)
Running test: testTwoChainedCallbacks Running test: testTwoChainedCallbacks
foo1 (test.js:9:2) foo1 (test.js:9:2)
-- Promise.then -- -- Promise.then --
twoChainedCallbacks (test.js:61:14) twoChainedCallbacks (test.js:68:14)
(anonymous) (testTwoChainedCallbacks.js:0:0) (anonymous) (testTwoChainedCallbacks.js:0:0)
foo2 (test.js:13:2) foo2 (test.js:13:2)
-- Promise.then -- -- Promise.then --
twoChainedCallbacks (test.js:61:25) twoChainedCallbacks (test.js:68:25)
(anonymous) (testTwoChainedCallbacks.js:0:0) (anonymous) (testTwoChainedCallbacks.js:0:0)
Running test: testPromiseResolve Running test: testPromiseResolve
foo1 (test.js:9:2) foo1 (test.js:9:2)
-- Promise.then -- -- Promise.then --
promiseResolve (test.js:67:27) promiseResolve (test.js:74:27)
(anonymous) (testPromiseResolve.js:0:0) (anonymous) (testPromiseResolve.js:0:0)
foo2 (test.js:13:2) foo2 (test.js:13:2)
-- Promise.then -- -- Promise.then --
promiseResolve (test.js:67:38) promiseResolve (test.js:74:38)
(anonymous) (testPromiseResolve.js:0:0) (anonymous) (testPromiseResolve.js:0:0)
Running test: testThenableJobResolvedInSetTimeout Running test: testThenableJobResolvedInSetTimeout
foo1 (test.js:9:2) foo1 (test.js:9:2)
-- Promise.then -- -- Promise.then --
thenableJobResolvedInSetTimeout (test.js:79:40) thenableJobResolvedInSetTimeout (test.js:86:40)
(anonymous) (testThenableJobResolvedInSetTimeout.js:0:0) (anonymous) (testThenableJobResolvedInSetTimeout.js:0:0)
Running test: testThenableJobResolvedInSetTimeoutWithStack Running test: testThenableJobResolvedInSetTimeoutWithStack
foo1 (test.js:9:2) foo1 (test.js:9:2)
-- Promise.then -- -- Promise.then --
thenableJobResolvedInSetTimeoutWithStack (test.js:97:40) thenableJobResolvedInSetTimeoutWithStack (test.js:104:40)
(anonymous) (testThenableJobResolvedInSetTimeoutWithStack.js:0:0) (anonymous) (testThenableJobResolvedInSetTimeoutWithStack.js:0:0)
Running test: testThenableJobResolvedByPromise Running test: testThenableJobResolvedByPromise
foo1 (test.js:9:2) foo1 (test.js:9:2)
-- Promise.then -- -- Promise.then --
thenableJobResolvedByPromise (test.js:111:40) thenableJobResolvedByPromise (test.js:118:40)
(anonymous) (testThenableJobResolvedByPromise.js:0:0) (anonymous) (testThenableJobResolvedByPromise.js:0:0)
Running test: testThenableJobResolvedByPromiseWithStack Running test: testThenableJobResolvedByPromiseWithStack
foo1 (test.js:9:2) foo1 (test.js:9:2)
-- Promise.then -- -- Promise.then --
thenableJobResolvedByPromiseWithStack (test.js:129:40) thenableJobResolvedByPromiseWithStack (test.js:136:40)
(anonymous) (testThenableJobResolvedByPromiseWithStack.js:0:0) (anonymous) (testThenableJobResolvedByPromiseWithStack.js:0:0)
Running test: testLateThenCallback Running test: testLateThenCallback
foo1 (test.js:9:2) foo1 (test.js:9:2)
-- Promise.then -- -- Promise.then --
lateThenCallback (test.js:138:12) lateThenCallback (test.js:145:12)
(anonymous) (testLateThenCallback.js:0:0) (anonymous) (testLateThenCallback.js:0:0)
...@@ -98,36 +98,36 @@ Running test: testComplex ...@@ -98,36 +98,36 @@ Running test: testComplex
inner1 (test.js:154:6) inner1 (test.js:154:6)
foo1 (test.js:156:4) foo1 (test.js:156:4)
-- Promise.then -- -- Promise.then --
complex (test.js:195:5) complex (test.js:202:5)
(anonymous) (testComplex.js:0:0) (anonymous) (testComplex.js:0:0)
(anonymous) (test.js:207:8) (anonymous) (test.js:207:8)
-- Promise.then -- -- Promise.then --
(anonymous) (test.js:199:8) (anonymous) (test.js:206:8)
-- Promise.then -- -- Promise.then --
(anonymous) (test.js:198:6) (anonymous) (test.js:205:6)
-- setTimeout -- -- setTimeout --
complex (test.js:197:2) complex (test.js:204:2)
(anonymous) (testComplex.js:0:0) (anonymous) (testComplex.js:0:0)
Running test: testReject Running test: testReject
foo1 (test.js:9:2) foo1 (test.js:9:2)
-- Promise.catch -- -- Promise.catch --
reject (test.js:210:31) reject (test.js:217:31)
(anonymous) (testReject.js:0:0) (anonymous) (testReject.js:0:0)
Running test: testFinally1 Running test: testFinally1
foo1 (test.js:9:2) foo1 (test.js:9:2)
-- Promise.finally -- -- Promise.finally --
finally1 (test.js:214:33) finally1 (test.js:221:33)
(anonymous) (testFinally1.js:0:0) (anonymous) (testFinally1.js:0:0)
Running test: testFinally2 Running test: testFinally2
foo1 (test.js:9:2) foo1 (test.js:9:2)
-- Promise.finally -- -- Promise.finally --
finally2 (test.js:218:34) finally2 (test.js:225:34)
(anonymous) (testFinally2.js:0:0) (anonymous) (testFinally2.js:0:0)
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that async chains for promises are correct.'); let {session, contextGroup, Protocol} = InspectorTest.start('Checks that async chains for promises are correct.');
contextGroup.addScript(` contextGroup.addInlineScript(
`
function foo1() { function foo1() {
debugger; debugger;
} }
...@@ -223,8 +224,8 @@ function finally1() { ...@@ -223,8 +224,8 @@ function finally1() {
function finally2() { function finally2() {
return Promise.resolve().finally(foo1); return Promise.resolve().finally(foo1);
} }`,
//# sourceURL=test.js`, 7, 26); 'test.js');
session.setupScriptMap(); session.setupScriptMap();
Protocol.Debugger.onPaused(message => { Protocol.Debugger.onPaused(message => {
......
...@@ -8,9 +8,9 @@ asyncFact (test.js:9:2) ...@@ -8,9 +8,9 @@ asyncFact (test.js:9:2)
asyncFact (test.js:11:2) asyncFact (test.js:11:2)
-- await -- -- await --
asyncFact (test.js:3:20) asyncFact (test.js:10:20)
asyncFact (test.js:3:20) asyncFact (test.js:10:20)
asyncFact (test.js:3:20) asyncFact (test.js:10:20)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
let {session, contextGroup, Protocol} = InspectorTest.start('Check that continue-to-location works with different strategies.'); let {session, contextGroup, Protocol} = InspectorTest.start('Check that continue-to-location works with different strategies.');
contextGroup.addScript(` contextGroup.addInlineScript(
`
async function asyncFact(n) { async function asyncFact(n) {
if (n == 0) return 1; if (n == 0) return 1;
let r = n * await asyncFact(n - 1); let r = n * await asyncFact(n - 1);
...@@ -20,15 +21,18 @@ function fact(n) { ...@@ -20,15 +21,18 @@ function fact(n) {
} }
function topLevel() { function topLevel() {
eval(` + '`' + ` eval(` +
'`' +
`
var a = 1; var a = 1;
var b = 2; var b = 2;
fact(3); fact(3);
console.log(a + b); console.log(a + b);
` + '`' + `); ` +
} '`' +
`);
//# sourceURL=test.js`, 7, 26); }`,
'test.js');
session.setupScriptMap(); session.setupScriptMap();
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
......
...@@ -20,7 +20,7 @@ throwUncaughtError (framework.js:21:2) ...@@ -20,7 +20,7 @@ throwUncaughtError (framework.js:21:2)
Running test: testUncaughtExceptionWithInlinedFrame Running test: testUncaughtExceptionWithInlinedFrame
> mixed top frame in framework: > mixed top frame in framework:
throwUserException (user.js:66:2) throwUserException (user.js:76:2)
inlinedWrapper (framework.js:56:4) inlinedWrapper (framework.js:56:4)
throwInlinedUncaughtError (framework.js:60:2) throwInlinedUncaughtError (framework.js:60:2)
(anonymous) (framework.js:0:0) (anonymous) (framework.js:0:0)
...@@ -50,7 +50,7 @@ syncDOMBreakpoint (framework.js:33:12) ...@@ -50,7 +50,7 @@ syncDOMBreakpoint (framework.js:33:12)
Running test: testSyncDOMBreakpointWithInlinedUserFrame Running test: testSyncDOMBreakpointWithInlinedUserFrame
> mixed, top frame in framework: > mixed, top frame in framework:
syncDOMBreakpoint (framework.js:33:12) syncDOMBreakpoint (framework.js:33:12)
userFunction (user.js:70:2) userFunction (user.js:80:2)
inlinedWrapper (framework.js:65:4) inlinedWrapper (framework.js:65:4)
syncDOMBreakpointWithInlinedUserFrame (framework.js:69:2) syncDOMBreakpointWithInlinedUserFrame (framework.js:69:2)
(anonymous) (framework.js:0:0) (anonymous) (framework.js:0:0)
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that breaks in framework code correctly processed.'); let {session, contextGroup, Protocol} = InspectorTest.start('Checks that breaks in framework code correctly processed.');
contextGroup.addScript(` contextGroup.addInlineScript(
`
function frameworkAssert() { function frameworkAssert() {
console.assert(false); console.assert(false);
} }
...@@ -67,20 +68,19 @@ function syncDOMBreakpointWithInlinedUserFrame() { ...@@ -67,20 +68,19 @@ function syncDOMBreakpointWithInlinedUserFrame() {
%PrepareFunctionForOptimization(inlinedWrapper); %PrepareFunctionForOptimization(inlinedWrapper);
%OptimizeFunctionOnNextCall(inlinedWrapper); %OptimizeFunctionOnNextCall(inlinedWrapper);
inlinedWrapper(); inlinedWrapper();
} }`,
'framework.js');
//# sourceURL=framework.js`, 8, 26);
contextGroup.addScript(` contextGroup.addInlineScript(
`
function throwUserException() { function throwUserException() {
throw new Error(); throw new Error();
} }
function userFunction() { function userFunction() {
syncDOMBreakpoint(); syncDOMBreakpoint();
} }`,
'user.js');
//# sourceURL=user.js`, 64, 26)
session.setupScriptMap(); session.setupScriptMap();
Protocol.Debugger.onPaused(message => { Protocol.Debugger.onPaused(message => {
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
let {session, contextGroup, Protocol} = InspectorTest.start('Checks nested scheduled break in framework code.'); let {session, contextGroup, Protocol} = InspectorTest.start('Checks nested scheduled break in framework code.');
contextGroup.addScript(` contextGroup.addInlineScript(
`
function frameworkCall(callback) { function frameworkCall(callback) {
inspector.callWithScheduledBreak(doFrameworkWork.bind(null, callback), inspector.callWithScheduledBreak(doFrameworkWork.bind(null, callback),
'top-framework-scheduled-break', 'top-framework-scheduled-break',
...@@ -18,11 +19,11 @@ function doFrameworkWork(callback) { ...@@ -18,11 +19,11 @@ function doFrameworkWork(callback) {
function doFrameworkBreak() { function doFrameworkBreak() {
inspector.breakProgram('framework-break', JSON.stringify({ data: 'data for framework-break' })); inspector.breakProgram('framework-break', JSON.stringify({ data: 'data for framework-break' }));
} }`,
'framework.js');
//# sourceURL=framework.js`, 7, 26);
contextGroup.addScript(` contextGroup.addInlineScript(
`
function testFunction() { function testFunction() {
inspector.callWithScheduledBreak(frameworkCall.bind(null, callback), inspector.callWithScheduledBreak(frameworkCall.bind(null, callback),
'top-scheduled-break', ''); 'top-scheduled-break', '');
...@@ -31,9 +32,8 @@ function testFunction() { ...@@ -31,9 +32,8 @@ function testFunction() {
function callback() { function callback() {
inspector.breakProgram('user-break', JSON.stringify({ data: 'data for user-break' })); inspector.breakProgram('user-break', JSON.stringify({ data: 'data for user-break' }));
return 42; return 42;
} }`,
'user.js');
//# sourceURL=user.js`, 25, 26);
session.setupScriptMap(); session.setupScriptMap();
Protocol.Debugger.onPaused(message => { Protocol.Debugger.onPaused(message => {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
let {session, contextGroup, Protocol} = InspectorTest.start('Checks framework debugging with blackboxed ranges.'); let {session, contextGroup, Protocol} = InspectorTest.start('Checks framework debugging with blackboxed ranges.');
contextGroup.addScript( contextGroup.addInlineScript(
` `
function foo() { function foo() {
return boo(); return boo();
...@@ -14,9 +14,8 @@ function boo() { ...@@ -14,9 +14,8 @@ function boo() {
} }
function testFunction() { function testFunction() {
foo(); foo();
} }`,
//# sourceURL=test.js`, 'test.js');
7, 26);
session.setupScriptMap(); session.setupScriptMap();
Protocol.Debugger.onPaused(message => { Protocol.Debugger.onPaused(message => {
......
...@@ -5,21 +5,21 @@ Running test: testStepIntoFromUser ...@@ -5,21 +5,21 @@ Running test: testStepIntoFromUser
Executing stepInto... Executing stepInto...
Executing stepInto... Executing stepInto...
userFoo (user.js:23:2) userFoo (user.js:21:2)
frameworkCall (framework.js:10:23) frameworkCall (framework.js:9:23)
testStepFromUser (user.js:31:2) testStepFromUser (user.js:29:2)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Executing stepInto... Executing stepInto...
Executing stepInto... Executing stepInto...
userBoo (user.js:27:2) userBoo (user.js:25:2)
frameworkCall (framework.js:10:23) frameworkCall (framework.js:9:23)
testStepFromUser (user.js:31:2) testStepFromUser (user.js:29:2)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Executing stepInto... Executing stepInto...
Executing stepInto... Executing stepInto...
testStepFromUser (user.js:32:0) testStepFromUser (user.js:30:0)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Executing resume... Executing resume...
...@@ -29,21 +29,21 @@ Running test: testStepOverFromUser ...@@ -29,21 +29,21 @@ Running test: testStepOverFromUser
Executing stepInto... Executing stepInto...
Executing stepInto... Executing stepInto...
userFoo (user.js:23:2) userFoo (user.js:21:2)
frameworkCall (framework.js:10:23) frameworkCall (framework.js:9:23)
testStepFromUser (user.js:31:2) testStepFromUser (user.js:29:2)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Executing stepOver... Executing stepOver...
Executing stepOver... Executing stepOver...
userBoo (user.js:27:2) userBoo (user.js:25:2)
frameworkCall (framework.js:10:23) frameworkCall (framework.js:9:23)
testStepFromUser (user.js:31:2) testStepFromUser (user.js:29:2)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Executing stepOver... Executing stepOver...
Executing stepOver... Executing stepOver...
testStepFromUser (user.js:32:0) testStepFromUser (user.js:30:0)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Executing resume... Executing resume...
...@@ -53,50 +53,50 @@ Running test: testStepOutFromUser ...@@ -53,50 +53,50 @@ Running test: testStepOutFromUser
Executing stepInto... Executing stepInto...
Executing stepInto... Executing stepInto...
userFoo (user.js:23:2) userFoo (user.js:21:2)
frameworkCall (framework.js:10:23) frameworkCall (framework.js:9:23)
testStepFromUser (user.js:31:2) testStepFromUser (user.js:29:2)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Executing stepOut... Executing stepOut...
userBoo (user.js:27:2) userBoo (user.js:25:2)
frameworkCall (framework.js:10:23) frameworkCall (framework.js:9:23)
testStepFromUser (user.js:31:2) testStepFromUser (user.js:29:2)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Executing resume... Executing resume...
Running test: testStepIntoFromFramework Running test: testStepIntoFromFramework
frameworkBreakAndCall (framework.js:14:12) frameworkBreakAndCall (framework.js:13:12)
testStepFromFramework (user.js:35:2) testStepFromFramework (user.js:33:2)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Executing stepInto... Executing stepInto...
userFoo (user.js:23:2) userFoo (user.js:21:2)
frameworkBreakAndCall (framework.js:15:23) frameworkBreakAndCall (framework.js:14:23)
testStepFromFramework (user.js:35:2) testStepFromFramework (user.js:33:2)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Executing resume... Executing resume...
Running test: testStepOverFromFramework Running test: testStepOverFromFramework
frameworkBreakAndCall (framework.js:14:12) frameworkBreakAndCall (framework.js:13:12)
testStepFromFramework (user.js:35:2) testStepFromFramework (user.js:33:2)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Executing stepOver... Executing stepOver...
testStepFromFramework (user.js:36:0) testStepFromFramework (user.js:34:0)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Executing resume... Executing resume...
Running test: testStepOutFromFramework Running test: testStepOutFromFramework
frameworkBreakAndCall (framework.js:14:12) frameworkBreakAndCall (framework.js:13:12)
testStepFromFramework (user.js:35:2) testStepFromFramework (user.js:33:2)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Executing stepOut... Executing stepOut...
testStepFromFramework (user.js:36:0) testStepFromFramework (user.js:34:0)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
Executing resume... Executing resume...
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
let {session, contextGroup, Protocol} = InspectorTest.start('Checks stepping with blackboxed frames on stack'); let {session, contextGroup, Protocol} = InspectorTest.start('Checks stepping with blackboxed frames on stack');
contextGroup.addScript( contextGroup.addInlineScript(
` `
function frameworkCall(funcs) { function frameworkCall(funcs) {
for (var f of funcs) f(); for (var f of funcs) f();
...@@ -13,11 +13,10 @@ function frameworkCall(funcs) { ...@@ -13,11 +13,10 @@ function frameworkCall(funcs) {
function frameworkBreakAndCall(funcs) { function frameworkBreakAndCall(funcs) {
inspector.breakProgram('', ''); inspector.breakProgram('', '');
for (var f of funcs) f(); for (var f of funcs) f();
} }`,
//# sourceURL=framework.js`, 'framework.js');
8, 4);
contextGroup.addScript( contextGroup.addInlineScript(
` `
function userFoo() { function userFoo() {
return 1; return 1;
...@@ -33,9 +32,8 @@ function testStepFromUser() { ...@@ -33,9 +32,8 @@ function testStepFromUser() {
function testStepFromFramework() { function testStepFromFramework() {
frameworkBreakAndCall([userFoo, userBoo]); frameworkBreakAndCall([userFoo, userBoo]);
} }`,
//# sourceURL=user.js`, 'user.js');
21, 4);
session.setupScriptMap(); session.setupScriptMap();
......
...@@ -8,7 +8,7 @@ let {session, contextGroup, Protocol} = ...@@ -8,7 +8,7 @@ let {session, contextGroup, Protocol} =
(async function test() { (async function test() {
session.setupScriptMap(); session.setupScriptMap();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
contextGroup.addScript(`debugger;//# sourceURL=test.js`, -3, -3); contextGroup.addScript(`debugger;`, -3, -3, 'test.js');
let {params:{callFrames}} = await Protocol.Debugger.oncePaused(); let {params:{callFrames}} = await Protocol.Debugger.oncePaused();
session.logCallFrames(callFrames); session.logCallFrames(callFrames);
InspectorTest.completeTest(); InspectorTest.completeTest();
......
...@@ -8,7 +8,7 @@ test (foo.js:12:2) ...@@ -8,7 +8,7 @@ test (foo.js:12:2)
(anonymous) (timeout1.js:0:8) (anonymous) (timeout1.js:0:8)
foo (timeout2.js:2:2) foo (timeout2.js:19:2)
(anonymous) (timeout3.js:0:8) (anonymous) (timeout3.js:0:8)
...@@ -28,9 +28,9 @@ test (foo.js:13:0) ...@@ -28,9 +28,9 @@ test (foo.js:13:0)
(anonymous) (timeout1.js:0:35) (anonymous) (timeout1.js:0:35)
foo (timeout2.js:2:2) foo (timeout2.js:19:2)
foo (timeout2.js:2:12) foo (timeout2.js:19:12)
(anonymous) (timeout3.js:0:8) (anonymous) (timeout3.js:0:8)
...@@ -61,9 +61,9 @@ test (foo.js:13:0) ...@@ -61,9 +61,9 @@ test (foo.js:13:0)
(anonymous) (timeout1.js:0:35) (anonymous) (timeout1.js:0:35)
foo (timeout2.js:2:2) foo (timeout2.js:19:2)
foo (timeout2.js:2:12) foo (timeout2.js:19:12)
(anonymous) (timeout3.js:0:8) (anonymous) (timeout3.js:0:8)
......
...@@ -4,20 +4,22 @@ ...@@ -4,20 +4,22 @@
let {session, contextGroup, Protocol} = InspectorTest.start('Debugger breaks in next script after stepOut from previous one.'); let {session, contextGroup, Protocol} = InspectorTest.start('Debugger breaks in next script after stepOut from previous one.');
contextGroup.addScript(` contextGroup.addInlineScript(
`
function test() { function test() {
setTimeout('var a = 1;//# sourceURL=timeout1.js', 0); setTimeout('var a = 1;//# sourceURL=timeout1.js', 0);
setTimeout(foo, 0); setTimeout(foo, 0);
setTimeout('var a = 3;//# sourceURL=timeout3.js', 0); setTimeout('var a = 3;//# sourceURL=timeout3.js', 0);
debugger; debugger;
} }`,
//# sourceURL=foo.js`, 7, 26); 'foo.js');
contextGroup.addScript(` contextGroup.addInlineScript(
`
function foo() { function foo() {
return 42; return 42;
} }`,
//# sourceURL=timeout2.js`) 'timeout2.js');
session.setupScriptMap(); session.setupScriptMap();
var stepAction; var stepAction;
......
Regression test for crbug/1283049
Running test: test
foo (foo.js:0:17)
(anonymous) (:0:0)
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
const {session, contextGroup, Protocol} =
InspectorTest.start('Regression test for crbug/1283049');
session.setupScriptMap();
contextGroup.addInlineScript(
`function foo() { debugger; }
//# sourceURL=foo.js`,
'regress-crbug-1283049.js');
InspectorTest.runAsyncTestSuite([async function test() {
await Promise.all([
Protocol.Runtime.enable(),
Protocol.Debugger.enable(),
]);
const evalPromise = Protocol.Runtime.evaluate({expression: 'foo()'});
const {params: {callFrames}} = await Protocol.Debugger.oncePaused();
session.logCallFrames(callFrames);
await Promise.all([
Protocol.Debugger.resume(),
evalPromise,
Protocol.Runtime.disable(),
Protocol.Debugger.disable(),
]);
}]);
...@@ -35,12 +35,12 @@ Evaluating debugger in 1 ...@@ -35,12 +35,12 @@ Evaluating debugger in 1
Paused in 1: Paused in 1:
reason: other reason: other
hit breakpoints: hit breakpoints:
location: bar@25 location: bar@26
data: null data: null
Paused in 2: Paused in 2:
reason: other reason: other
hit breakpoints: hit breakpoints:
location: bar@25 location: bar@26
data: null data: null
Resuming in 2 Resuming in 2
Resumed in 1 Resumed in 1
...@@ -77,12 +77,12 @@ Evaluating debugger in 2 ...@@ -77,12 +77,12 @@ Evaluating debugger in 2
Paused in 1: Paused in 1:
reason: other reason: other
hit breakpoints: hit breakpoints:
location: bar@25 location: bar@26
data: null data: null
Paused in 2: Paused in 2:
reason: other reason: other
hit breakpoints: hit breakpoints:
location: bar@25 location: bar@26
data: null data: null
Resuming in 2 Resuming in 2
Resumed in 1 Resumed in 1
...@@ -187,7 +187,7 @@ Evaluating bar() in 2 ...@@ -187,7 +187,7 @@ Evaluating bar() in 2
Paused in 1: Paused in 1:
reason: other reason: other
hit breakpoints: hit breakpoints:
location: bar@25 location: bar@26
data: null data: null
Resuming in 1 Resuming in 1
Resumed in 1 Resumed in 1
......
...@@ -6,7 +6,8 @@ InspectorTest.log('Tests how multiple sessions interact while pausing, stepping, ...@@ -6,7 +6,8 @@ InspectorTest.log('Tests how multiple sessions interact while pausing, stepping,
var contextGroup = new InspectorTest.ContextGroup(); var contextGroup = new InspectorTest.ContextGroup();
contextGroup.addScript(` contextGroup.addInlineScript(
`
function foo() { function foo() {
return 1; return 1;
} }
...@@ -17,14 +18,15 @@ function stepping() { ...@@ -17,14 +18,15 @@ function stepping() {
debugger; debugger;
var a = 1; var a = 1;
var b = 1; var b = 1;
} }`,
//# sourceURL=test.js`, 9, 25); 'test.js');
contextGroup.addScript(` contextGroup.addInlineScript(
`
function bar() { function bar() {
debugger; debugger;
} }`,
//# sourceURL=test2.js`, 23, 25); 'test2.js');
(async function test() { (async function test() {
InspectorTest.log('Connecting session 1'); InspectorTest.log('Connecting session 1');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment