a81e8d16f4
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: Yang Guo <yangguo@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/main@{#78450}
178 lines
3.9 KiB
JavaScript
178 lines
3.9 KiB
JavaScript
// Copyright 2017 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.
|
|
|
|
// TODO(kozyatinskiy): fix this test.
|
|
let {session, contextGroup, Protocol} = InspectorTest.start('Checks created frame for async call chain');
|
|
|
|
contextGroup.addInlineScript(
|
|
`
|
|
function foo1() {
|
|
debugger;
|
|
}
|
|
|
|
function foo2() {
|
|
debugger;
|
|
}
|
|
|
|
function promise() {
|
|
var resolve;
|
|
var p1 = new Promise(r => resolve = r);
|
|
var p2 = p1.then(foo1);
|
|
resolve();
|
|
return p2;
|
|
}
|
|
|
|
function promiseThen() {
|
|
var resolve;
|
|
var p1 = new Promise(r => resolve = r);
|
|
var p2 = p1.then(foo1);
|
|
var p3 = p2.then(foo2);
|
|
resolve();
|
|
return p3;
|
|
}
|
|
|
|
function promiseThenThen() {
|
|
var resolve;
|
|
var p1 = new Promise(r => resolve = r);
|
|
var p2 = p1.then(foo1).then(foo2);
|
|
var p3 = p1.then(foo1);
|
|
resolve();
|
|
return p2;
|
|
}
|
|
|
|
function promiseResolve() {
|
|
return Promise.resolve().then(foo1);
|
|
}
|
|
|
|
function promiseReject() {
|
|
return Promise.reject().catch(foo1);
|
|
}
|
|
|
|
function promiseAll() {
|
|
return Promise.all([ Promise.resolve() ]).then(foo1);
|
|
}
|
|
|
|
function promiseRace() {
|
|
return Promise.race([ Promise.resolve() ]).then(foo1);
|
|
}
|
|
|
|
function thenableJob1() {
|
|
return Promise.resolve().then(() => Promise.resolve().then(() => 42)).then(foo1);
|
|
}
|
|
|
|
function thenableJob2() {
|
|
return Promise.resolve().then(() => Promise.resolve()).then(foo1);
|
|
}
|
|
|
|
function setTimeouts() {
|
|
var resolve;
|
|
var p = new Promise(r => resolve = r);
|
|
setTimeout(() =>
|
|
setTimeout(() =>
|
|
setTimeout(() => { foo1(); resolve(); }, 0), 0), 0);
|
|
return p;
|
|
}`,
|
|
'test.js');
|
|
|
|
session.setupScriptMap();
|
|
Protocol.Debugger.onPaused(message => {
|
|
session.logCallFrames(message.params.callFrames);
|
|
session.logAsyncStackTrace(message.params.asyncStackTrace);
|
|
InspectorTest.log('');
|
|
Protocol.Debugger.resume();
|
|
});
|
|
|
|
Protocol.Debugger.enable();
|
|
Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 128});
|
|
|
|
InspectorTest.runTestSuite([
|
|
function testPromise(next) {
|
|
Protocol.Runtime
|
|
.evaluate(
|
|
{expression: 'promise()//# sourceURL=expr.js', awaitPromise: true})
|
|
.then(next);
|
|
},
|
|
|
|
function testPromiseThen(next) {
|
|
Protocol.Runtime
|
|
.evaluate({
|
|
expression: 'promiseThen()//# sourceURL=expr.js',
|
|
awaitPromise: true
|
|
})
|
|
.then(next);
|
|
},
|
|
|
|
function testPromiseThenThen(next) {
|
|
Protocol.Runtime
|
|
.evaluate({
|
|
expression: 'promiseThenThen()//# sourceURL=expr.js',
|
|
awaitPromise: true
|
|
})
|
|
.then(next);
|
|
},
|
|
|
|
function testPromiseResolve(next) {
|
|
Protocol.Runtime
|
|
.evaluate({
|
|
expression: 'promiseResolve()//# sourceURL=expr.js',
|
|
awaitPromise: true
|
|
})
|
|
.then(next);
|
|
},
|
|
|
|
function testPromiseReject(next) {
|
|
Protocol.Runtime
|
|
.evaluate({
|
|
expression: 'promiseReject()//# sourceURL=expr.js',
|
|
awaitPromise: true
|
|
})
|
|
.then(next);
|
|
},
|
|
|
|
function testPromiseAll(next) {
|
|
Protocol.Runtime
|
|
.evaluate({
|
|
expression: 'promiseAll()//# sourceURL=expr.js',
|
|
awaitPromise: true
|
|
})
|
|
.then(next);
|
|
},
|
|
|
|
function testPromiseRace(next) {
|
|
Protocol.Runtime
|
|
.evaluate({
|
|
expression: 'promiseRace()//# sourceURL=expr.js',
|
|
awaitPromise: true
|
|
})
|
|
.then(next);
|
|
},
|
|
|
|
function testThenableJob1(next) {
|
|
Protocol.Runtime
|
|
.evaluate({
|
|
expression: 'thenableJob1()//# sourceURL=expr.js',
|
|
awaitPromise: true
|
|
})
|
|
.then(next);
|
|
},
|
|
|
|
function testThenableJob2(next) {
|
|
Protocol.Runtime
|
|
.evaluate({
|
|
expression: 'thenableJob2()//# sourceURL=expr.js',
|
|
awaitPromise: true
|
|
})
|
|
.then(next);
|
|
},
|
|
|
|
function testSetTimeouts(next) {
|
|
Protocol.Runtime
|
|
.evaluate({
|
|
expression: 'setTimeouts()//# sourceURL=expr.js',
|
|
awaitPromise: true
|
|
})
|
|
.then(next);
|
|
}
|
|
]);
|