OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --expose-wasm | 5 // Flags: --expose-wasm |
6 | 6 |
7 utils.load('test/mjsunit/wasm/wasm-constants.js'); | 7 utils.load('test/mjsunit/wasm/wasm-constants.js'); |
8 utils.load('test/mjsunit/wasm/wasm-module-builder.js'); | 8 utils.load('test/mjsunit/wasm/wasm-module-builder.js'); |
9 | 9 |
10 // Add two empty functions. Both should be registered as individual scripts at | 10 // Add two empty functions. Both should be registered as individual scripts at |
11 // module creation time. | 11 // module creation time. |
12 var builder = new WasmModuleBuilder(); | 12 var builder = new WasmModuleBuilder(); |
13 builder.addFunction('nopFunction', kSig_v_v).addBody([kExprNop]); | 13 builder.addFunction('nopFunction', kSig_v_v).addBody([kExprNop]); |
14 builder.addFunction('main', kSig_v_v) | 14 builder.addFunction('main', kSig_v_v) |
15 .addBody([kExprBlock, kWasmStmt, kExprI32Const, 2, kExprDrop, kExprEnd]) | 15 .addBody([kExprBlock, kWasmStmt, kExprI32Const, 2, kExprDrop, kExprEnd]) |
16 .exportAs('main'); | 16 .exportAs('main'); |
17 var module_bytes = builder.toArray(); | 17 var module_bytes = builder.toArray(); |
18 | 18 |
19 function testFunction(bytes) { | 19 function testFunction(bytes) { |
20 var buffer = new ArrayBuffer(bytes.length); | 20 var buffer = new ArrayBuffer(bytes.length); |
21 var view = new Uint8Array(buffer); | 21 var view = new Uint8Array(buffer); |
22 for (var i = 0; i < bytes.length; i++) { | 22 for (var i = 0; i < bytes.length; i++) { |
23 view[i] = bytes[i] | 0; | 23 view[i] = bytes[i] | 0; |
24 } | 24 } |
25 | 25 |
26 // Compilation triggers registration of wasm scripts. | 26 // Compilation triggers registration of wasm scripts. |
27 new WebAssembly.Module(buffer); | 27 new WebAssembly.Module(buffer); |
28 } | 28 } |
29 | 29 |
30 InspectorTest.addScriptWithUrl( | 30 InspectorTest.addScript(testFunction.toString(), 0, 0, 'v8://test/testFunction')
; |
31 testFunction.toString(), 'v8://test/testFunction'); | |
32 InspectorTest.addScript('var module_bytes = ' + JSON.stringify(module_bytes)); | 31 InspectorTest.addScript('var module_bytes = ' + JSON.stringify(module_bytes)); |
33 | 32 |
34 Protocol.Debugger.enable(); | 33 Protocol.Debugger.enable(); |
35 Protocol.Debugger.onScriptParsed(handleScriptParsed); | 34 Protocol.Debugger.onScriptParsed(handleScriptParsed); |
36 InspectorTest.log( | 35 InspectorTest.log( |
37 'Check that inspector gets two wasm scripts at module creation time.'); | 36 'Check that inspector gets two wasm scripts at module creation time.'); |
38 Protocol.Runtime | 37 Protocol.Runtime |
39 .evaluate({ | 38 .evaluate({ |
40 'expression': '//# sourceURL=v8://test/runTestRunction\n' + | 39 'expression': '//# sourceURL=v8://test/runTestRunction\n' + |
41 'testFunction(module_bytes)' | 40 'testFunction(module_bytes)' |
(...skipping 20 matching lines...) Expand all Loading... |
62 InspectorTest.log("Source for " + url + ":"); | 61 InspectorTest.log("Source for " + url + ":"); |
63 InspectorTest.log(message.result.scriptSource); | 62 InspectorTest.log(message.result.scriptSource); |
64 --missing_sources; | 63 --missing_sources; |
65 } | 64 } |
66 | 65 |
67 Protocol.Debugger.getScriptSource({scriptId: messageObject.params.scriptId}) | 66 Protocol.Debugger.getScriptSource({scriptId: messageObject.params.scriptId}) |
68 .then(dumpScriptSource.bind(null)) | 67 .then(dumpScriptSource.bind(null)) |
69 .then(checkFinished); | 68 .then(checkFinished); |
70 } | 69 } |
71 } | 70 } |
OLD | NEW |