OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --expose-wasm |
| 6 |
| 7 load('test/mjsunit/wasm/wasm-constants.js'); |
| 8 load('test/mjsunit/wasm/wasm-module-builder.js'); |
| 9 |
| 10 // Add two empty functions. Both should be registered as individual scripts at |
| 11 // module creation time. |
| 12 var builder = new WasmModuleBuilder(); |
| 13 builder.addFunction('func0', kSig_v_v).addBody([]); |
| 14 builder.addFunction('func1', kSig_v_v).addBody([]).exportAs('main'); |
| 15 var module_bytes = builder.toArray(); |
| 16 |
| 17 function testFunction(bytes) { |
| 18 var buffer = new ArrayBuffer(bytes.length); |
| 19 var view = new Uint8Array(buffer); |
| 20 for (var i = 0; i < bytes.length; i++) { |
| 21 view[i] = bytes[i] | 0; |
| 22 } |
| 23 |
| 24 // Compilation triggers registration of wasm scripts. |
| 25 new WebAssembly.Module(buffer); |
| 26 } |
| 27 |
| 28 function addSourceUrl(code, url) { |
| 29 return '//# sourceURL=' + url + '\n' + code; |
| 30 } |
| 31 |
| 32 InspectorTest.addScript( |
| 33 addSourceUrl(testFunction.toString(), 'v8://test/testFunction')); |
| 34 InspectorTest.addScript('var module_bytes = ' + JSON.stringify(module_bytes)); |
| 35 |
| 36 Protocol.Debugger.enable(); |
| 37 Protocol.Debugger.onScriptParsed(handleScriptParsed); |
| 38 InspectorTest.log( |
| 39 'Check that inspector gets two wasm scripts at module creation time.'); |
| 40 Protocol.Runtime |
| 41 .evaluate({ |
| 42 'expression': addSourceUrl( |
| 43 'testFunction(module_bytes)', 'v8://test/runTestRunction') |
| 44 }) |
| 45 .then(InspectorTest.completeTest()); |
| 46 |
| 47 var num_scripts = 0; |
| 48 function handleScriptParsed(messageObject) |
| 49 { |
| 50 var url = messageObject.params.url; |
| 51 InspectorTest.log("Script #" + num_scripts + " parsed. URL: " + url); |
| 52 ++num_scripts; |
| 53 } |
OLD | NEW |