nodejs/deps/v8/test/inspector/regress/regress-crbug-349248170.js
Michaël Zasso 9d7cd9b864
deps: update V8 to 12.8.374.13
PR-URL: https://github.com/nodejs/node/pull/54077
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2024-08-16 16:03:01 +02:00

53 lines
1.6 KiB
JavaScript

// Copyright 2024 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.
// Adapted test from 'inspector/debugger/wasm-externref-global.js'
utils.load('test/inspector/wasm-inspector-test.js');
const {session, contextGroup, Protocol} =
InspectorTest.start('Don\'t crash when using non-zero line number to set WASM breakpoint');
(async () => {
let builder = new WasmModuleBuilder();
builder.addImportedGlobal('m', 'global', kWasmExternRef, false);
let func = builder.addFunction('func', kSig_v_v)
.addBody([
kExprGlobalGet, 0, //
kExprDrop, //
])
.exportAs('main');
let moduleBytes = JSON.stringify(builder.toArray());
function test(moduleBytes) {
let module = new WebAssembly.Module((new Uint8Array(moduleBytes)).buffer);
let global = 'hello, world';
instance = new WebAssembly.Instance(module, { m: { global } });
}
Protocol.Debugger.enable();
Protocol.Runtime.evaluate({
expression: `
let instance;
${test.toString()}
test(${moduleBytes});`
});
InspectorTest.log('Waiting for wasm script to be parsed.');
let scriptId;
while (true) {
let msg = await Protocol.Debugger.onceScriptParsed();
if (msg.params.url.startsWith('wasm://')) {
scriptId = msg.params.scriptId;
break;
}
}
InspectorTest.log('Setting breakpoint in wasm.');
InspectorTest.logMessage(await Protocol.Debugger.setBreakpoint(
{ location: { scriptId, lineNumber: 42, columnNumber: func.body_offset } }));
InspectorTest.completeTest();
})();