From: ager@chromium.org Date: Mon, 2 May 2011 14:20:34 +0000 (+0000) Subject: Use JSON.parse instead of eval for the debugger JSON protocol. X-Git-Tag: upstream/4.7.83~19524 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ccafbca61d726d02f0fd3ab59e16fd93bfda4778;p=platform%2Fupstream%2Fv8.git Use JSON.parse instead of eval for the debugger JSON protocol. R=sgjesse@chromium.org BUG= TEST= Review URL: http://codereview.chromium.org/6903172 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7748 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/debug-debugger.js b/src/debug-debugger.js index bc0f966fb..908fcd212 100644 --- a/src/debug-debugger.js +++ b/src/debug-debugger.js @@ -1335,7 +1335,7 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(json_request) try { try { // Convert the JSON string to an object. - request = %CompileString('(' + json_request + ')')(); + request = JSON.parse(json_request); // Create an initial response. response = this.createResponse(request); diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc index 9847c891e..852c6d4db 100644 --- a/test/cctest/test-debug.cc +++ b/test/cctest/test-debug.cc @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -6313,8 +6313,7 @@ static void ExecuteScriptForContextCheck() { v8::Persistent context_1; v8::Handle global_template = v8::Handle(); - v8::Handle global_object = v8::Handle(); - context_1 = v8::Context::New(NULL, global_template, global_object); + context_1 = v8::Context::New(NULL, global_template); // Default data value is undefined. CHECK(context_1->GetData()->IsUndefined()); @@ -6379,11 +6378,11 @@ static void DebugEvalContextCheckMessageHandler( const int kBufferSize = 1000; uint16_t buffer[kBufferSize]; const char* eval_command = - "{\"seq\":0," - "\"type\":\"request\"," - "\"command\":\"evaluate\"," - "arguments:{\"expression\":\"debugger;\"," - "\"global\":true,\"disable_break\":false}}"; + "{\"seq\":0," + "\"type\":\"request\"," + "\"command\":\"evaluate\"," + "\"arguments\":{\"expression\":\"debugger;\"," + "\"global\":true,\"disable_break\":false}}"; // Send evaluate command. v8::Debug::SendCommand(buffer, AsciiToUtf16(eval_command, buffer)); diff --git a/test/mjsunit/debug-evaluate.js b/test/mjsunit/debug-evaluate.js index 182e2ac96..accf656d6 100644 --- a/test/mjsunit/debug-evaluate.js +++ b/test/mjsunit/debug-evaluate.js @@ -91,24 +91,24 @@ function listener(event, exec_state, event_data, data) { // parameter is passed. testRequest( dcp, - '{"expression":"this.longString","global":true,maxStringLength:-1}', + '{"expression":"this.longString","global":true,"maxStringLength":-1}', true, longString); testRequest( dcp, - '{"expression":"this.longString","global":true,maxStringLength:' + + '{"expression":"this.longString","global":true,"maxStringLength":' + longString.length + '}', true, longString); var truncatedStringSuffix = '... (length: ' + longString.length + ')'; testRequest( dcp, - '{"expression":"this.longString","global":true,maxStringLength:0}', + '{"expression":"this.longString","global":true,"maxStringLength":0}', true, truncatedStringSuffix); testRequest( dcp, - '{"expression":"this.longString","global":true,maxStringLength:1}', + '{"expression":"this.longString","global":true,"maxStringLength":1}', true, longString.charAt(0) + truncatedStringSuffix); // Test that by default string is truncated to first 80 chars. diff --git a/test/mjsunit/debug-scripts-request.js b/test/mjsunit/debug-scripts-request.js index 41bff0e80..faa732e14 100644 --- a/test/mjsunit/debug-scripts-request.js +++ b/test/mjsunit/debug-scripts-request.js @@ -71,7 +71,7 @@ function listener(event, exec_state, event_data, data) { testArguments(dcp, '{"types":2}', true); testArguments(dcp, '{"types":4}', true); testArguments(dcp, '{"types":7}', true); - testArguments(dcp, '{"types":0xFF}', true); + testArguments(dcp, '{"types":255}', true); // Test request for all scripts. var request = '{' + base_request + '}'