| 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 let {session, contextGroup, Protocol} = InspectorTest.start('Tests how wasm scri
pts are reported'); |
| 8 |
| 7 utils.load('test/mjsunit/wasm/wasm-constants.js'); | 9 utils.load('test/mjsunit/wasm/wasm-constants.js'); |
| 8 utils.load('test/mjsunit/wasm/wasm-module-builder.js'); | 10 utils.load('test/mjsunit/wasm/wasm-module-builder.js'); |
| 9 | 11 |
| 10 // Add two empty functions. Both should be registered as individual scripts at | 12 // Add two empty functions. Both should be registered as individual scripts at |
| 11 // module creation time. | 13 // module creation time. |
| 12 var builder = new WasmModuleBuilder(); | 14 var builder = new WasmModuleBuilder(); |
| 13 builder.addFunction('nopFunction', kSig_v_v).addBody([kExprNop]); | 15 builder.addFunction('nopFunction', kSig_v_v).addBody([kExprNop]); |
| 14 builder.addFunction('main', kSig_v_v) | 16 builder.addFunction('main', kSig_v_v) |
| 15 .addBody([kExprBlock, kWasmStmt, kExprI32Const, 2, kExprDrop, kExprEnd]) | 17 .addBody([kExprBlock, kWasmStmt, kExprI32Const, 2, kExprDrop, kExprEnd]) |
| 16 .exportAs('main'); | 18 .exportAs('main'); |
| 17 var module_bytes = builder.toArray(); | 19 var module_bytes = builder.toArray(); |
| 18 | 20 |
| 19 function testFunction(bytes) { | 21 function testFunction(bytes) { |
| 20 var buffer = new ArrayBuffer(bytes.length); | 22 var buffer = new ArrayBuffer(bytes.length); |
| 21 var view = new Uint8Array(buffer); | 23 var view = new Uint8Array(buffer); |
| 22 for (var i = 0; i < bytes.length; i++) { | 24 for (var i = 0; i < bytes.length; i++) { |
| 23 view[i] = bytes[i] | 0; | 25 view[i] = bytes[i] | 0; |
| 24 } | 26 } |
| 25 | 27 |
| 26 // Compilation triggers registration of wasm scripts. | 28 // Compilation triggers registration of wasm scripts. |
| 27 new WebAssembly.Module(buffer); | 29 new WebAssembly.Module(buffer); |
| 28 } | 30 } |
| 29 | 31 |
| 30 InspectorTest.addScript(testFunction.toString(), 0, 0, 'v8://test/testFunction')
; | 32 contextGroup.addScript(testFunction.toString(), 0, 0, 'v8://test/testFunction'); |
| 31 InspectorTest.addScript('var module_bytes = ' + JSON.stringify(module_bytes)); | 33 contextGroup.addScript('var module_bytes = ' + JSON.stringify(module_bytes)); |
| 32 | 34 |
| 33 Protocol.Debugger.enable(); | 35 Protocol.Debugger.enable(); |
| 34 Protocol.Debugger.onScriptParsed(handleScriptParsed); | 36 Protocol.Debugger.onScriptParsed(handleScriptParsed); |
| 35 InspectorTest.log( | 37 InspectorTest.log( |
| 36 'Check that inspector gets two wasm scripts at module creation time.'); | 38 'Check that inspector gets two wasm scripts at module creation time.'); |
| 37 Protocol.Runtime | 39 Protocol.Runtime |
| 38 .evaluate({ | 40 .evaluate({ |
| 39 'expression': '//# sourceURL=v8://test/runTestRunction\n' + | 41 'expression': '//# sourceURL=v8://test/runTestRunction\n' + |
| 40 'testFunction(module_bytes)' | 42 'testFunction(module_bytes)' |
| 41 }) | 43 }) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 61 InspectorTest.log("Source for " + url + ":"); | 63 InspectorTest.log("Source for " + url + ":"); |
| 62 InspectorTest.log(message.result.scriptSource); | 64 InspectorTest.log(message.result.scriptSource); |
| 63 --missing_sources; | 65 --missing_sources; |
| 64 } | 66 } |
| 65 | 67 |
| 66 Protocol.Debugger.getScriptSource({scriptId: messageObject.params.scriptId}) | 68 Protocol.Debugger.getScriptSource({scriptId: messageObject.params.scriptId}) |
| 67 .then(dumpScriptSource.bind(null)) | 69 .then(dumpScriptSource.bind(null)) |
| 68 .then(checkFinished); | 70 .then(checkFinished); |
| 69 } | 71 } |
| 70 } | 72 } |
| OLD | NEW |