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. |
| 11 var builder = new WasmModuleBuilder(); |
| 12 builder.addFunction('func0', kSig_v_v).addBody([]); |
| 13 builder.addFunction('func1', kSig_v_v).addBody([]).exportAs('main'); |
| 14 var module_bytes = builder.toArray(); |
| 15 |
| 16 function testFunction(bytes) { |
| 17 var buffer = new ArrayBuffer(bytes.length); |
| 18 var view = new Uint8Array(buffer); |
| 19 for (var i = 0; i < bytes.length; i++) { |
| 20 view[i] = bytes[i] | 0; |
| 21 } |
| 22 |
| 23 // Compilation triggers registration of wasm scripts. |
| 24 new WebAssembly.Module(buffer); |
| 25 } |
| 26 |
| 27 InspectorTest.addScript(testFunction.toString()); |
| 28 InspectorTest.addScript('var module_bytes = ' + JSON.stringify(module_bytes)); |
| 29 |
| 30 Protocol.Debugger.enable(); |
| 31 Protocol.Debugger.onScriptParsed(handleScriptParsed); |
| 32 InspectorTest.log('Check that inspector gets two wasm scripts'); |
| 33 Protocol.Runtime.evaluate({'expression': 'testFunction(module_bytes)'}) |
| 34 .then(InspectorTest.completeTest()); |
| 35 |
| 36 var num_scripts = 0; |
| 37 function handleScriptParsed(messageObject) |
| 38 { |
| 39 var url = messageObject.params.url; |
| 40 InspectorTest.log("Script #" + num_scripts + " parsed. URL: " + url); |
| 41 ++num_scripts; |
| 42 } |
OLD | NEW |