Index: test/inspector/debugger/wasm-get-breakable-locations.js |
diff --git a/test/inspector/debugger/wasm-get-breakable-locations.js b/test/inspector/debugger/wasm-get-breakable-locations.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2d915864bc2240e1179d0d4b59c56f33b1fada02 |
--- /dev/null |
+++ b/test/inspector/debugger/wasm-get-breakable-locations.js |
@@ -0,0 +1,76 @@ |
+// Copyright 2016 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// Flags: --expose-wasm |
+ |
+load('test/mjsunit/wasm/wasm-constants.js'); |
+load('test/mjsunit/wasm/wasm-module-builder.js'); |
+ |
+var builder = new WasmModuleBuilder(); |
+ |
+var imported_idx = builder.addImport("func", kSig_v_v); |
+ |
+builder.addFunction("main", kSig_v_i) |
+ .addBody([ |
+ // @1 |
+ kExprNop, |
+ // @2 |
+ kExprGetLocal, 0, |
+ // @4 |
+ kExprIf, kAstStmt, |
+ // @6 |
+ kExprBlock, kAstStmt, |
+ // @8 |
+ kExprCallFunction, imported_idx, |
+ // @10 |
+ kExprEnd, |
+ // @11 |
+ kExprEnd |
+ ]).exportAs("main"); |
+ |
+var module_bytes = builder.toArray(); |
+ |
+function testFunction(bytes) { |
+ function call_debugger() { |
+ // Call to the debugger to trigger wasm translations for all functions on |
+ // the stack. |
+ debugger; |
+ } |
+ var buffer = new ArrayBuffer(bytes.length); |
+ var view = new Uint8Array(buffer); |
+ for (var i = 0; i < bytes.length; i++) { |
+ view[i] = bytes[i] | 0; |
+ } |
+ |
+ var module = new WebAssembly.Module(buffer); |
+ var instance = new WebAssembly.Instance(module, {'func': call_debugger}); |
+ |
+ instance.exports.main(1); |
+} |
+ |
+InspectorTest.addScript(testFunction.toString()); |
+InspectorTest.addScript('var module_bytes = ' + JSON.stringify(module_bytes)); |
+ |
+Protocol.Debugger.enable(); |
+Protocol.Debugger.onScriptParsed(handleScriptParsed); |
+InspectorTest.log('Running testFunction...'); |
+Protocol.Runtime.evaluate({'expression': 'testFunction(module_bytes)'}); |
+ |
+var numScripts = 0; |
+function handleScriptParsed(messageObject) |
+{ |
+ var scriptId = messageObject.params.scriptId; |
+ var url = messageObject.params.url; |
+ InspectorTest.log('Script nr ' + numScripts + ' parsed. URL: ' + url); |
+ ++numScripts; |
+ |
+ if (url.startsWith('wasm://')) { |
+ InspectorTest.log('This is a wasm script. Requesting breakable locations.'); |
+ Protocol.Debugger |
+ .getPossibleBreakpoints( |
+ {start: {lineNumber: 0, columnNumber: 0, scriptId: scriptId}}) |
+ .then(InspectorTest.logMessage) |
+ .then(InspectorTest.completeTest); |
+ } |
+} |