Commit 750a8391 authored by yurys@chromium.org's avatar yurys@chromium.org

Add parameter that allows to request data for scripts by their ids. It's going...

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1941 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 032681a0
......@@ -1588,6 +1588,12 @@ DebugCommandProcessor.prototype.lookupRequest_ = function(request, response) {
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.sourceRequest_ = function(request, response) {
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 @@ DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) {
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 @@ DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) {
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]));
}
......
......@@ -66,9 +66,6 @@ function listener(event, exec_state, event_data, data) {
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 @@ function listener(event, exec_state, event_data, data) {
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 @@ Debug.setListener(listener);
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")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment