Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: test/inspector/debugger/wasm-get-breakable-locations.js

Issue 2536763002: [inspector] [wasm] Implement GetPossibleBreakpoints (Closed)
Patch Set: Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-objects.cc ('k') | test/inspector/debugger/wasm-get-breakable-locations-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index 3378aced3f6e9c6937770d405c1633a6fcc215b9..a78bc59c567f73f189566ebe53d15bdf33c2d229 100644
--- a/test/inspector/debugger/wasm-get-breakable-locations.js
+++ b/test/inspector/debugger/wasm-get-breakable-locations.js
@@ -37,22 +37,106 @@ function testFunction(bytes) {
}
var module = new WebAssembly.Module(buffer);
- var instance = new WebAssembly.Instance(module);
-
- instance.exports.main(1);
}
-InspectorTest.addScript(testFunction.toString());
+var addSourceUrl = (code, url) => '//# sourceURL=' + url + '\n' + code;
+
+InspectorTest.addScript(
+ addSourceUrl(testFunction.toString(), 'v8://test/testFunction'));
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)'})
+Protocol.Runtime
+ .evaluate({
+ 'expression': addSourceUrl(
+ 'testFunction(module_bytes)', 'v8://test/runTestFunction')
+ })
+ .then(getBreakableLocationsForAllWasmScripts)
+ .then(() => InspectorTest.log('Finished!'))
.then(InspectorTest.completeTest);
var numScripts = 0;
+var wasmScripts = [];
function handleScriptParsed(messageObject) {
- InspectorTest.logMessage(messageObject);
- // TODO(clemensh): Request breakable locations in http://crrev.com/2536763002.
+ 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 (nr ' + wasmScripts.length + ').');
+ wasmScripts.push(scriptId);
+ }
+}
+
+function printBreakableLocations(message, expectedScriptId, source) {
+ if (!message.result || !message.result.locations) {
+ InspectorTest.logMessage(message);
+ return;
+ }
+ var lines = source.split('\n');
+ var locations = message.result.locations;
+ InspectorTest.log(locations.length + ' breakable location(s):');
+ for (var i = 0; i < locations.length; ++i) {
+ if (locations[i].scriptId != expectedScriptId) {
+ InspectorTest.log(
+ 'SCRIPT ID MISMATCH!! ' + locations[i].scriptId + ' != ' +
+ expectedScriptId);
+ }
+ var line = locations[i].lineNumber < lines.length ?
+ lines[locations[i].lineNumber] :
+ '<illegal line number>';
+ InspectorTest.log(
+ '[' + i + '] ' + locations[i].lineNumber + ':' +
+ locations[i].columnNumber + ' || ' + line);
+ }
+}
+
+function getSourceFromMessage(message) {
+ if (!message.result || !message.result.scriptSource) {
+ InspectorTest.logMessage(message);
+ return '';
+ }
+ return message.result.scriptSource;
+}
+
+function checkGetBreakableLocations(wasmScriptNr) {
+ InspectorTest.log(
+ 'Requesting all breakable locations in wasm script ' + wasmScriptNr);
+ var scriptId = wasmScripts[wasmScriptNr];
+ var source;
+ return Protocol.Debugger.getScriptSource({scriptId: scriptId})
+ .then((message) => source = getSourceFromMessage(message))
+ .then(
+ () => Protocol.Debugger.getPossibleBreakpoints(
+ {start: {lineNumber: 0, columnNumber: 0, scriptId: scriptId}}))
+ .then((message) => printBreakableLocations(message, scriptId, source))
+ .then(
+ () =>
+ InspectorTest.log('Requesting breakable locations up to line 2'))
+ .then(() => Protocol.Debugger.getPossibleBreakpoints({
+ start: {lineNumber: 0, columnNumber: 0, scriptId: scriptId},
+ end: {lineNumber: 3, columnNumber: 0, scriptId: scriptId}
+ }))
+ .then((message) => printBreakableLocations(message, scriptId, source))
+ .then(
+ () =>
+ InspectorTest.log('Requesting breakable locations in lines 3-4'))
+ .then(() => Protocol.Debugger.getPossibleBreakpoints({
+ start: {lineNumber: 3, columnNumber: 0, scriptId: scriptId},
+ end: {lineNumber: 5, columnNumber: 0, scriptId: scriptId}
+ }))
+ .then((message) => printBreakableLocations(message, scriptId, source));
+}
+
+function getBreakableLocationsForAllWasmScripts() {
+ InspectorTest.log('Querying breakable locations for all wasm scripts now...');
+ var promise = Promise.resolve();
+ for (var wasmScriptNr = 0; wasmScriptNr < wasmScripts.length;
+ ++wasmScriptNr) {
+ promise = promise.then(checkGetBreakableLocations.bind(null, wasmScriptNr));
+ }
+ return promise;
}
« no previous file with comments | « src/wasm/wasm-objects.cc ('k') | test/inspector/debugger/wasm-get-breakable-locations-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698