summaryrefslogtreecommitdiff
path: root/deps/v8/test/inspector/debugger/wasm-scripts.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/inspector/debugger/wasm-scripts.js')
-rw-r--r--deps/v8/test/inspector/debugger/wasm-scripts.js41
1 files changed, 9 insertions, 32 deletions
diff --git a/deps/v8/test/inspector/debugger/wasm-scripts.js b/deps/v8/test/inspector/debugger/wasm-scripts.js
index 72d886b0e5..6a342922a8 100644
--- a/deps/v8/test/inspector/debugger/wasm-scripts.js
+++ b/deps/v8/test/inspector/debugger/wasm-scripts.js
@@ -38,7 +38,7 @@ function testFunction(bytes) {
contextGroup.addScript(testFunction.toString(), 0, 0, 'v8://test/testFunction');
InspectorTest.log(
- 'Check that each inspector gets two wasm scripts at module creation time.');
+ 'Check that each inspector gets a wasm script at module creation time.');
// Sample .debug_info section.
// Content doesn't matter, as we don't try to parse it in V8,
@@ -78,30 +78,6 @@ sessions[0].Protocol.Runtime
})
.then(() => InspectorTest.completeTest());
-function decodeBase64(base64) {
- const LOOKUP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
-
- const paddingLength = base64.match(/=*$/)[0].length;
- const bytesLength = base64.length * 0.75 - paddingLength;
-
- let bytes = new Uint8Array(bytesLength);
-
- for (let i = 0, p = 0; i < base64.length; i += 4, p += 3) {
- let bits = 0;
- for (let j = 0; j < 4; j++) {
- bits <<= 6;
- const c = base64[i + j];
- if (c !== '=') bits |= LOOKUP.indexOf(c);
- }
- for (let j = p + 2; j >= p; j--) {
- if (j < bytesLength) bytes[j] = bits;
- bits >>= 8;
- }
- }
-
- return bytes;
-}
-
function trackScripts(debuggerParams) {
let {id: sessionId, Protocol} = contextGroup.connect();
let scripts = [];
@@ -111,11 +87,14 @@ function trackScripts(debuggerParams) {
async function loadScript({url, scriptId, sourceMapURL}) {
InspectorTest.log(`Session #${sessionId}: Script #${scripts.length} parsed. URL: ${url}. Source map URL: ${sourceMapURL}`);
- let scriptSource;
- if (sourceMapURL) {
- let {result: {bytecode}} = await Protocol.Debugger.getWasmBytecode({scriptId});
+ let {result: {scriptSource, bytecode}} = await Protocol.Debugger.getScriptSource({scriptId});
+ if (bytecode) {
+ if (scriptSource) {
+ InspectorTest.log('Unexpected scriptSource with bytecode: ');
+ InspectorTest.log(scriptSource);
+ }
// Binary value is represented as base64 in JSON, decode it.
- bytecode = decodeBase64(bytecode);
+ bytecode = InspectorTest.decodeBase64(bytecode);
// Check that it can be parsed back to a WebAssembly module.
let module = new WebAssembly.Module(bytecode);
scriptSource = `
@@ -123,15 +102,13 @@ Raw: ${Array.from(bytecode, b => ('0' + b.toString(16)).slice(-2)).join(' ')}
Imports: [${WebAssembly.Module.imports(module).map(i => `${i.name}: ${i.kind} from "${i.module}"`).join(', ')}]
Exports: [${WebAssembly.Module.exports(module).map(e => `${e.name}: ${e.kind}`).join(', ')}]
`.trim();
- } else {
- ({result: {scriptSource}} = await Protocol.Debugger.getScriptSource({scriptId}));
}
InspectorTest.log(`Session #${sessionId}: Source for ${url}:`);
InspectorTest.log(scriptSource);
}
function handleScriptParsed({params}) {
- if (params.url.startsWith("wasm://")) {
+ if (params.url.startsWith('wasm://')) {
scripts.push(loadScript(params));
}
}