summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/wasm-12.js
blob: 18d3b574d8ab9df63522a5954d916e7857f51171 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Tests that wasm module scripts have special URLs.

if (!wasmIsSupported())
  quit();

var g = newGlobal();
g.eval(`
function initWasm(s) { return new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(s))); }
o = initWasm('(module (func) (export "" 0))');
o2 = initWasm('(module (func) (func) (export "" 1))');
`);

function isWasm(script) { return script.format === "wasm"; }

function isValidWasmURL(url) {
   // The URLs will have the following format:
   //   wasm: [<uri-econded-filename-of-host> ":"] <64-bit-hash>
   return /^wasm:(?:[^:]*:)*?[0-9a-f]{16}$/.test(url);
}

var dbg = new Debugger(g);
var foundScripts = dbg.findScripts().filter(isWasm);
assertEq(foundScripts.length, 2);
assertEq(isValidWasmURL(foundScripts[0].source.url), true);
assertEq(isValidWasmURL(foundScripts[1].source.url), true);
assertEq(foundScripts[0].source.url != foundScripts[1].source.url, true);