Commit cad99884 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[inspector][wasm] Stop relying on `//# sourceURL` annotation.

These tests unnecessarily rely on the `//# sourceURL` annotation. This
is preparatory work to eventually move the treatment of `sourceURL` to
the DevTools front-end.

Bug: chromium:1183990
Change-Id: I934eb1580f503b7b9f8d97c250b7c798bc67e268
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2814568
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73878}
parent a3c143f4
...@@ -20,6 +20,7 @@ Protocol.Debugger.onPaused(async msg => { ...@@ -20,6 +20,7 @@ Protocol.Debugger.onPaused(async msg => {
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
async function test() { async function test() {
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log('Instantiating.'); InspectorTest.log('Instantiating.');
// Spawn asynchronously: // Spawn asynchronously:
......
...@@ -50,6 +50,7 @@ Protocol.Debugger.onPaused(async msg => { ...@@ -50,6 +50,7 @@ Protocol.Debugger.onPaused(async msg => {
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
async function test() { async function test() {
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log('Instantiating.'); InspectorTest.log('Instantiating.');
// Spawn asynchronously: // Spawn asynchronously:
......
...@@ -47,6 +47,7 @@ InspectorTest.runAsyncTestSuite([ ...@@ -47,6 +47,7 @@ InspectorTest.runAsyncTestSuite([
async function test() { async function test() {
breakCount = 0; breakCount = 0;
breakpointId = 0; breakpointId = 0;
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
WasmInspectorTest.instantiate(module_bytes); WasmInspectorTest.instantiate(module_bytes);
await waitForWasmScript(); await waitForWasmScript();
......
...@@ -196,6 +196,7 @@ Protocol.Debugger.onPaused(async msg => { ...@@ -196,6 +196,7 @@ Protocol.Debugger.onPaused(async msg => {
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
async function test() { async function test() {
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log('Instantiating.'); InspectorTest.log('Instantiating.');
// Spawn asynchronously: // Spawn asynchronously:
......
...@@ -6,5 +6,7 @@ GC triggered ...@@ -6,5 +6,7 @@ GC triggered
Debugger.resume Debugger.resume
Hello World (v8://test/instantiate:11:36) Hello World (v8://test/instantiate:11:36)
at bar (v8://test/instantiate:11:36) at bar (v8://test/instantiate:11:36)
at wasm_A (wasm://wasm/38e28046:1:54)
at test (test.js:4:20)
at (anonymous function) (:1:1)
exports.main returned! exports.main returned!
...@@ -36,11 +36,11 @@ contextGroup.addScript(` ...@@ -36,11 +36,11 @@ contextGroup.addScript(`
function test() { function test() {
debug(instance.exports.main); debug(instance.exports.main);
instance.exports.main({val: "Hello World"}); instance.exports.main({val: "Hello World"});
} }`, 0, 0, 'test.js');
//# sourceURL=test.js`);
InspectorTest.runAsyncTestSuite([async function test() { InspectorTest.runAsyncTestSuite([async function test() {
utils.setLogConsoleApiMessageCalls(true); utils.setLogConsoleApiMessageCalls(true);
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
await WasmInspectorTest.instantiate( await WasmInspectorTest.instantiate(
module_bytes, 'instance', '{foo: {bar: (x) => console.log(x.val)}}'); module_bytes, 'instance', '{foo: {bar: (x) => console.log(x.val)}}');
......
...@@ -32,6 +32,7 @@ builder.addFunction('main', kSig_v_i) ...@@ -32,6 +32,7 @@ builder.addFunction('main', kSig_v_i)
var module_bytes = builder.toArray(); var module_bytes = builder.toArray();
Protocol.Runtime.enable();
Protocol.Debugger.enable(); Protocol.Debugger.enable();
Protocol.Debugger.onScriptParsed(handleScriptParsed); Protocol.Debugger.onScriptParsed(handleScriptParsed);
......
...@@ -39,7 +39,8 @@ function instantiate(bytes, imp) { ...@@ -39,7 +39,8 @@ function instantiate(bytes, imp) {
session.setupScriptMap(); session.setupScriptMap();
// Main promise chain: // Main promise chain:
Protocol.Debugger.enable() Protocol.Runtime.enable()
.then(() => Protocol.Debugger.enable())
.then(() => InspectorTest.log('Installing code and global variable.')) .then(() => InspectorTest.log('Installing code and global variable.'))
.then( .then(
() => WasmInspectorTest.evalWithUrl( () => WasmInspectorTest.evalWithUrl(
......
...@@ -98,6 +98,7 @@ async function testConfig(config) { ...@@ -98,6 +98,7 @@ async function testConfig(config) {
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
async function test() { async function test() {
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
for (let config in configs) { for (let config in configs) {
await testConfig(config); await testConfig(config);
......
...@@ -24,6 +24,7 @@ InspectorTest.runAsyncTestSuite([ ...@@ -24,6 +24,7 @@ InspectorTest.runAsyncTestSuite([
const start_fn = builder.addFunction('start', kSig_v_v).addBody([kExprNop]); const start_fn = builder.addFunction('start', kSig_v_v).addBody([kExprNop]);
builder.addStart(start_fn.index); builder.addStart(start_fn.index);
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log('Setting instrumentation breakpoint'); InspectorTest.log('Setting instrumentation breakpoint');
InspectorTest.logMessage( InspectorTest.logMessage(
...@@ -40,6 +41,7 @@ InspectorTest.runAsyncTestSuite([ ...@@ -40,6 +41,7 @@ InspectorTest.runAsyncTestSuite([
'new WebAssembly.Instance(module)', 'instantiate2'); 'new WebAssembly.Instance(module)', 'instantiate2');
InspectorTest.log('Done.'); InspectorTest.log('Done.');
await Protocol.Debugger.disable(); await Protocol.Debugger.disable();
await Protocol.Runtime.disable();
}, },
// If we compile twice, we get two instrumentation breakpoints (which might or // If we compile twice, we get two instrumentation breakpoints (which might or
...@@ -49,6 +51,7 @@ InspectorTest.runAsyncTestSuite([ ...@@ -49,6 +51,7 @@ InspectorTest.runAsyncTestSuite([
const start_fn = builder.addFunction('start', kSig_v_v).addBody([kExprNop]); const start_fn = builder.addFunction('start', kSig_v_v).addBody([kExprNop]);
builder.addStart(start_fn.index); builder.addStart(start_fn.index);
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log('Setting instrumentation breakpoint'); InspectorTest.log('Setting instrumentation breakpoint');
InspectorTest.logMessage( InspectorTest.logMessage(
...@@ -61,6 +64,7 @@ InspectorTest.runAsyncTestSuite([ ...@@ -61,6 +64,7 @@ InspectorTest.runAsyncTestSuite([
await WasmInspectorTest.instantiate(builder.toArray()); await WasmInspectorTest.instantiate(builder.toArray());
InspectorTest.log('Done.'); InspectorTest.log('Done.');
await Protocol.Debugger.disable(); await Protocol.Debugger.disable();
await Protocol.Runtime.disable();
}, },
async function testBreakInExportedFunction() { async function testBreakInExportedFunction() {
...@@ -68,6 +72,7 @@ InspectorTest.runAsyncTestSuite([ ...@@ -68,6 +72,7 @@ InspectorTest.runAsyncTestSuite([
const func = const func =
builder.addFunction('func', kSig_v_v).addBody([kExprNop]).exportFunc(); builder.addFunction('func', kSig_v_v).addBody([kExprNop]).exportFunc();
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log('Setting instrumentation breakpoint'); InspectorTest.log('Setting instrumentation breakpoint');
InspectorTest.logMessage( InspectorTest.logMessage(
...@@ -84,6 +89,7 @@ InspectorTest.runAsyncTestSuite([ ...@@ -84,6 +89,7 @@ InspectorTest.runAsyncTestSuite([
await WasmInspectorTest.evalWithUrl('instance.exports.func()', 'call_func'); await WasmInspectorTest.evalWithUrl('instance.exports.func()', 'call_func');
InspectorTest.log('Done.'); InspectorTest.log('Done.');
await Protocol.Debugger.disable(); await Protocol.Debugger.disable();
await Protocol.Runtime.disable();
}, },
async function testBreakOnlyWithSourceMap() { async function testBreakOnlyWithSourceMap() {
...@@ -94,6 +100,7 @@ InspectorTest.runAsyncTestSuite([ ...@@ -94,6 +100,7 @@ InspectorTest.runAsyncTestSuite([
builder.addCustomSection('sourceMappingURL', [3, 97, 98, 99]); builder.addCustomSection('sourceMappingURL', [3, 97, 98, 99]);
const bytes_with_source_map = builder.toArray(); const bytes_with_source_map = builder.toArray();
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log( InspectorTest.log(
'Setting instrumentation breakpoint for source maps only'); 'Setting instrumentation breakpoint for source maps only');
...@@ -114,6 +121,7 @@ InspectorTest.runAsyncTestSuite([ ...@@ -114,6 +121,7 @@ InspectorTest.runAsyncTestSuite([
await WasmInspectorTest.evalWithUrl('instance.exports.func()', 'call_func'); await WasmInspectorTest.evalWithUrl('instance.exports.func()', 'call_func');
InspectorTest.log('Done.'); InspectorTest.log('Done.');
await Protocol.Debugger.disable(); await Protocol.Debugger.disable();
await Protocol.Runtime.disable();
}, },
]); ]);
...@@ -43,11 +43,11 @@ contextGroup.addScript(` ...@@ -43,11 +43,11 @@ contextGroup.addScript(`
function test() { function test() {
instance.exports.main(1); instance.exports.main(1);
instance.exports.main(1); instance.exports.main(1);
} }`, 0, 0, 'test.js');
//# sourceURL=test.js`);
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
async function Test() { async function Test() {
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log('Calling instantiate function.'); InspectorTest.log('Calling instantiate function.');
WasmInspectorTest.instantiate(module_bytes); WasmInspectorTest.instantiate(module_bytes);
......
...@@ -388,10 +388,10 @@ at (anonymous) (0:17): ...@@ -388,10 +388,10 @@ at (anonymous) (0:17):
-- skipped globals -- skipped globals
Paused: Paused:
instance.exports.main(42) instance.exports.main(42)#
Scope: Scope:
at (anonymous) (1:31): at (anonymous) (0:25):
- scope (global): - scope (global):
-- skipped globals -- skipped globals
......
...@@ -11,6 +11,7 @@ utils.load('test/inspector/wasm-inspector-test.js'); ...@@ -11,6 +11,7 @@ utils.load('test/inspector/wasm-inspector-test.js');
let {session, contextGroup, Protocol} = InspectorTest.start( let {session, contextGroup, Protocol} = InspectorTest.start(
'Test retrieving scope information from compiled Liftoff frames'); 'Test retrieving scope information from compiled Liftoff frames');
session.setupScriptMap(); session.setupScriptMap();
Protocol.Runtime.enable();
Protocol.Debugger.enable(); Protocol.Debugger.enable();
Protocol.Debugger.onPaused(printPauseLocationsAndContinue); Protocol.Debugger.onPaused(printPauseLocationsAndContinue);
......
...@@ -30,6 +30,7 @@ builder.addFunction('main', kSig_v_i) ...@@ -30,6 +30,7 @@ builder.addFunction('main', kSig_v_i)
// clang-format on // clang-format on
var module_bytes = builder.toArray(); var module_bytes = builder.toArray();
Protocol.Runtime.enable();
Protocol.Debugger.enable(); Protocol.Debugger.enable();
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
......
...@@ -86,6 +86,7 @@ Protocol.Debugger.onPaused(async msg => { ...@@ -86,6 +86,7 @@ Protocol.Debugger.onPaused(async msg => {
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
async function test() { async function test() {
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log('Instantiating.'); InspectorTest.log('Instantiating.');
// Spawn asynchronously: // Spawn asynchronously:
......
...@@ -37,6 +37,7 @@ function instantiate(bytes, imports) { ...@@ -37,6 +37,7 @@ function instantiate(bytes, imports) {
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
async function testPauseAndStep() { async function testPauseAndStep() {
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log('Instantiate'); InspectorTest.log('Instantiate');
const instantiate_code = `var instance = (${instantiate})(${JSON.stringify(module_bytes)}, {'imports': {'pause': () => { %ScheduleBreak() } }});`; const instantiate_code = `var instance = (${instantiate})(${JSON.stringify(module_bytes)}, {'imports': {'pause': () => { %ScheduleBreak() } }});`;
......
...@@ -33,6 +33,7 @@ Protocol.Debugger.onPaused(msg => { ...@@ -33,6 +33,7 @@ Protocol.Debugger.onPaused(msg => {
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
async function test() { async function test() {
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log('Setting up global instance variable.'); InspectorTest.log('Setting up global instance variable.');
WasmInspectorTest.instantiate(module_bytes); WasmInspectorTest.instantiate(module_bytes);
......
...@@ -64,6 +64,7 @@ contextGroup.addScript(call_div.toString()); ...@@ -64,6 +64,7 @@ contextGroup.addScript(call_div.toString());
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
async function test() { async function test() {
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
await Protocol.Debugger.setPauseOnExceptions({state: 'all'}); await Protocol.Debugger.setPauseOnExceptions({state: 'all'});
InspectorTest.log('Instantiating.'); InspectorTest.log('Instantiating.');
......
...@@ -26,6 +26,7 @@ InspectorTest.runAsyncTestSuite([ ...@@ -26,6 +26,7 @@ InspectorTest.runAsyncTestSuite([
InspectorTest.logProtocolCommandCalls('Debugger.stepInto'); InspectorTest.logProtocolCommandCalls('Debugger.stepInto');
InspectorTest.logProtocolCommandCalls('Debugger.resume'); InspectorTest.logProtocolCommandCalls('Debugger.resume');
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log('Setting up global instance variable.'); InspectorTest.log('Setting up global instance variable.');
WasmInspectorTest.instantiate(module_bytes); WasmInspectorTest.instantiate(module_bytes);
......
...@@ -41,11 +41,11 @@ contextGroup.addScript(` ...@@ -41,11 +41,11 @@ contextGroup.addScript(`
function test() { function test() {
debugger; debugger;
instance.exports.main(1); instance.exports.main(1);
} }`, 0, 0, 'test.js');
//# sourceURL=test.js`);
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
async function test() { async function test() {
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log('Calling instantiate function.'); InspectorTest.log('Calling instantiate function.');
WasmInspectorTest.instantiate(module_bytes); WasmInspectorTest.instantiate(module_bytes);
......
...@@ -23,6 +23,7 @@ Protocol.Debugger.onPaused(printPauseLocationAndStep); ...@@ -23,6 +23,7 @@ Protocol.Debugger.onPaused(printPauseLocationAndStep);
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
async function test() { async function test() {
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
WasmInspectorTest.instantiate(module_bytes); WasmInspectorTest.instantiate(module_bytes);
[, {params: {scriptId: wasm_script_id}}] = await Protocol.Debugger.onceScriptParsed(2); [, {params: {scriptId: wasm_script_id}}] = await Protocol.Debugger.onceScriptParsed(2);
......
...@@ -34,6 +34,7 @@ function pauseAlternating() { ...@@ -34,6 +34,7 @@ function pauseAlternating() {
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
async function test() { async function test() {
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log('Instantiating.'); InspectorTest.log('Instantiating.');
const instantiate_code = const instantiate_code =
......
...@@ -58,11 +58,11 @@ function test() { ...@@ -58,11 +58,11 @@ function test() {
instance.exports.main(); instance.exports.main();
var x = 1; var x = 1;
x++; x++;
} }`, 0, 0, 'test.js');
//# sourceURL=test.js`);
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
async function test() { async function test() {
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log('Calling instantiate function.'); InspectorTest.log('Calling instantiate function.');
WasmInspectorTest.instantiate(module_bytes); WasmInspectorTest.instantiate(module_bytes);
......
...@@ -46,6 +46,7 @@ const func_a_end_offset = func_a_start_offset + 2; ...@@ -46,6 +46,7 @@ const func_a_end_offset = func_a_start_offset + 2;
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
async function test() { async function test() {
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log('Setting up global instance variable'); InspectorTest.log('Setting up global instance variable');
WasmInspectorTest.instantiate(module_bytes); WasmInspectorTest.instantiate(module_bytes);
......
...@@ -41,6 +41,7 @@ InspectorTest.runAsyncTestSuite([ ...@@ -41,6 +41,7 @@ InspectorTest.runAsyncTestSuite([
for (const action of ['stepInto', 'stepOver', 'stepOut', 'resume']) for (const action of ['stepInto', 'stepOver', 'stepOut', 'resume'])
InspectorTest.logProtocolCommandCalls('Debugger.' + action); InspectorTest.logProtocolCommandCalls('Debugger.' + action);
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
WasmInspectorTest.instantiate(module_bytes); WasmInspectorTest.instantiate(module_bytes);
const [, {params: wasmScript}] = await Protocol.Debugger.onceScriptParsed(2); const [, {params: wasmScript}] = await Protocol.Debugger.onceScriptParsed(2);
......
...@@ -59,6 +59,7 @@ InspectorTest.runAsyncTestSuite([ ...@@ -59,6 +59,7 @@ InspectorTest.runAsyncTestSuite([
for (const action of ['stepInto', 'stepOver', 'stepOut', 'resume']) for (const action of ['stepInto', 'stepOver', 'stepOut', 'resume'])
InspectorTest.logProtocolCommandCalls('Debugger.' + action); InspectorTest.logProtocolCommandCalls('Debugger.' + action);
await Protocol.Runtime.enable();
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log('Setting up global instance variable.'); InspectorTest.log('Setting up global instance variable.');
WasmInspectorTest.instantiate(module_bytes); WasmInspectorTest.instantiate(module_bytes);
......
...@@ -7,9 +7,12 @@ utils.load('test/mjsunit/wasm/wasm-module-builder.js'); ...@@ -7,9 +7,12 @@ utils.load('test/mjsunit/wasm/wasm-module-builder.js');
WasmInspectorTest = {} WasmInspectorTest = {}
InspectorTest.getWasmOpcodeName = getOpcodeName; InspectorTest.getWasmOpcodeName = getOpcodeName;
WasmInspectorTest.evalWithUrl = async function(code, url) { WasmInspectorTest.evalWithUrl = async function(expression, url) {
const sourceURL = `v8://test/${url}`;
const {result: {scriptId}} = await Protocol.Runtime.compileScript({
expression, sourceURL, persistScript: true}).then(printIfFailure);
return await Protocol.Runtime return await Protocol.Runtime
.evaluate({'expression': code + '\n//# sourceURL=v8://test/' + url}) .runScript({scriptId})
.then(printIfFailure); .then(printIfFailure);
}; };
......
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