wasm-12.js (988B)
1 // |jit-test| test-also=--wasm-compiler=optimizing; skip-if: !wasmDebuggingEnabled() 2 3 // Tests that wasm module scripts have special URLs. 4 5 var g = newGlobal({newCompartment: true}); 6 var dbg = new Debugger(g); 7 g.eval(` 8 function initWasm(s) { return new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(s))); } 9 o1 = initWasm('(module (func) (export "" (func 0)))'); 10 o2 = initWasm('(module (func) (func) (export "" (func 1)))'); 11 `); 12 13 function isWasm(script) { return script.format === "wasm"; } 14 15 function isValidWasmURL(url) { 16 // The URLs will have the following format: 17 // wasm: [<uri-encoded-filename-of-host> ":"] <64-bit-hash> 18 return /^wasm:(?:[^:]*:)*?[0-9a-f]{16}$/.test(url); 19 } 20 21 var foundScripts = dbg.findScripts().filter(isWasm); 22 assertEq(foundScripts.length, 2); 23 assertEq(isValidWasmURL(foundScripts[0].source.url), true); 24 assertEq(isValidWasmURL(foundScripts[1].source.url), true); 25 assertEq(foundScripts[0].source.url != foundScripts[1].source.url, true);