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

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

Issue 2536763002: [inspector] [wasm] Implement GetPossibleBreakpoints (Closed)
Patch Set: Rebase Created 4 years, 1 month 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 9f11c2995473449de37fb8cea78ed1bbda49429c..ba138eb6d6fdd792395da67c640a429a775afb60 100644
--- a/test/inspector/debugger/wasm-get-breakable-locations.js
+++ b/test/inspector/debugger/wasm-get-breakable-locations.js
@@ -55,10 +55,12 @@ InspectorTest.addScript('var module_bytes = ' + JSON.stringify(module_bytes));
Protocol.Debugger.enable();
Protocol.Debugger.onScriptParsed(handleScriptParsed);
+Protocol.Debugger.onPaused(handlePaused);
InspectorTest.log('Running testFunction...');
Protocol.Runtime.evaluate({'expression': 'testFunction(module_bytes)'});
var numScripts = 0;
+var wasmScripts = [];
function handleScriptParsed(messageObject) {
var scriptId = messageObject.params.scriptId;
var url = messageObject.params.url;
@@ -66,11 +68,78 @@ function handleScriptParsed(messageObject) {
++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);
+ 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) {
kozy 2016/11/30 17:38:16 You can improve this test by adding two steps afte
Clemens Hammacher 2016/11/30 17:52:19 Breakpoint support is not there yet, but is a P1 f
+ 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 handlePaused() {
+ InspectorTest.log('Paused on \'debugger\'.');
+ var promise = Promise.resolve();
+ for (var wasmScriptNr = 0; wasmScriptNr < wasmScripts.length;
+ ++wasmScriptNr) {
+ promise = promise.then(checkGetBreakableLocations.bind(null, wasmScriptNr));
+ }
+ promise.then(() => InspectorTest.log('Finished!'))
+ .then(InspectorTest.completeTest);
+}
« 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