wasm-03.js (1010B)
1 // |jit-test| skip-if: !wasmDebuggingEnabled() 2 3 // Tests that wasm module scripts have synthesized sources. 4 5 load(libdir + "asserts.js"); 6 7 var g = newGlobal({newCompartment: true}); 8 var dbg = new Debugger(g); 9 10 var s; 11 dbg.onNewScript = (script) => { 12 s = script; 13 } 14 15 g.eval(`o = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary('(module (func) (export "" (func 0)))')));`); 16 assertEq(s.format, "wasm"); 17 18 var source = s.source; 19 20 assertEq(s.source, source); 21 assertEq(source.introductionType, "wasm"); 22 assertEq(source.introductionScript, s); 23 // Wasm sources shouldn't be considered source mapped. 24 assertEq(!source.sourceMapURL, true); 25 assertThrowsInstanceOf(() => source.sourceMapURL = 'foo', Error); 26 // We must have some text. 27 assertEq(!!source.text, true); 28 29 // TODOshu: Wasm is moving very fast and what we return for these values is 30 // currently not interesting to test. Instead, test that they do not throw. 31 source.url; 32 source.displayURL; 33 source.introductionOffset; 34 source.elementAttributeName;