Reviewers: Søren Gjesse, Description: 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.
Please review this at http://codereview.chromium.org/113335 SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M src/debug-delay.js M test/mjsunit/debug-scripts-request.js Index: test/mjsunit/debug-scripts-request.js =================================================================== --- test/mjsunit/debug-scripts-request.js (revision 1928) +++ test/mjsunit/debug-scripts-request.js (working copy) @@ -76,6 +76,16 @@ testArguments(dcp, '{"types":7}', true); testArguments(dcp, '{"types":0xFF}', true); + // 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 +101,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") Index: src/debug-delay.js =================================================================== --- src/debug-delay.js (revision 1928) +++ src/debug-delay.js (working copy) @@ -1582,6 +1582,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++) { @@ -1678,6 +1684,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)) { @@ -1691,6 +1698,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. @@ -1699,6 +1714,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])); } --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
