Author: [email protected]
Date: Wed May 13 23:39:47 2009
New Revision: 1941
Modified:
branches/bleeding_edge/src/debug-delay.js
branches/bleeding_edge/test/mjsunit/debug-scripts-request.js
Log:
Add parameter that allows to request data for scripts by their ids. It's
going to be used e.g. to request script sources by their ids.
Review URL: http://codereview.chromium.org/113335
Modified: branches/bleeding_edge/src/debug-delay.js
==============================================================================
--- branches/bleeding_edge/src/debug-delay.js (original)
+++ branches/bleeding_edge/src/debug-delay.js Wed May 13 23:39:47 2009
@@ -1588,6 +1588,12 @@
return response.failed('Argument "handles" missing');
}
+ // Set 'includeSource' option for script lookup.
+ if (!IS_UNDEFINED(request.arguments.includeSource)) {
+ includeSource = %ToBoolean(request.arguments.includeSource);
+ response.setOption('includeSource', includeSource);
+ }
+
// Lookup handles.
var mirrors = {};
for (var i = 0; i < handles.length; i++) {
@@ -1684,6 +1690,7 @@
DebugCommandProcessor.prototype.scriptsRequest_ = function(request,
response) {
var types = ScriptTypeFlag(Debug.ScriptType.Normal);
var includeSource = false;
+ var idsToInclude = null;
if (request.arguments) {
// Pull out arguments.
if (!IS_UNDEFINED(request.arguments.types)) {
@@ -1697,6 +1704,14 @@
includeSource = %ToBoolean(request.arguments.includeSource);
response.setOption('includeSource', includeSource);
}
+
+ if (IS_ARRAY(request.arguments.ids)) {
+ idsToInclude = {};
+ var ids = request.arguments.ids;
+ for (var i = 0; i < ids.length; i++) {
+ idsToInclude[ids[i]] = true;
+ }
+ }
}
// Collect all scripts in the heap.
@@ -1705,6 +1720,9 @@
response.body = [];
for (var i = 0; i < scripts.length; i++) {
+ if (idsToInclude && !idsToInclude[scripts[i].id]) {
+ continue;
+ }
if (types & ScriptTypeFlag(scripts[i].type)) {
response.body.push(MakeMirror(scripts[i]));
}
Modified: branches/bleeding_edge/test/mjsunit/debug-scripts-request.js
==============================================================================
--- branches/bleeding_edge/test/mjsunit/debug-scripts-request.js
(original)
+++ branches/bleeding_edge/test/mjsunit/debug-scripts-request.js Wed May
13
23:39:47 2009
@@ -66,9 +66,6 @@
testArguments(dcp, '{"types":"xx"}', false);
// Test legal scripts requests.
- var request = '{' + base_request + '}'
- var response = safeEval(dcp.processDebugJSONRequest(request));
- assertTrue(response.success);
testArguments(dcp, '{}', true);
testArguments(dcp, '{"types":1}', true);
testArguments(dcp, '{"types":2}', true);
@@ -76,6 +73,21 @@
testArguments(dcp, '{"types":7}', true);
testArguments(dcp, '{"types":0xFF}', true);
+ // Test request for all scripts.
+ var request = '{' + base_request + '}'
+ var response = safeEval(dcp.processDebugJSONRequest(request));
+ assertTrue(response.success);
+
+ // Test filtering by id.
+ assertEquals(2, response.body.length);
+ var script = response.body[0];
+ var request = '{' + base_request + ',"arguments":{"ids":[' +
+ script.id + ']}}';
+ var response = safeEval(dcp.processDebugJSONRequest(request));
+ assertTrue(response.success);
+ assertEquals(1, response.body.length);
+ assertEquals(script.id, response.body[0].id);
+
// Indicate that all was processed.
listenerComplete = true;
}
@@ -91,5 +103,6 @@
debugger;
// Make sure that the debug event listener vas invoked with no exceptions.
-assertTrue(listenerComplete, "listener did not run to completion");
+assertTrue(listenerComplete,
+ "listener did not run to completion, exception: " + exception);
assertFalse(exception, "exception in listener")
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---