Commit 951f6b7a authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[V8] Report JSON parser script to DevTools

If JSON contains SyntaxError then V8 will report exception and won't report compile error.

LOG=Y
BUG=chromium:515382
R=yangguo@chromium.org,yurys@chromium.org

Review URL: https://codereview.chromium.org/1308123006

Cr-Commit-Position: refs/heads/master@{#30426}
parent 2ba2f40c
......@@ -7,6 +7,7 @@
#include "src/char-predicates.h"
#include "src/conversions.h"
#include "src/debug/debug.h"
#include "src/factory.h"
#include "src/messages.h"
#include "src/scanner.h"
......@@ -244,9 +245,11 @@ MaybeHandle<Object> JsonParser<seq_one_byte>::ParseJson() {
break;
}
MessageLocation location(factory->NewScript(source_),
position_,
position_ + 1);
Handle<Script> script(factory->NewScript(source_));
// We should sent compile error event because we compile JSON object in
// separated source file.
isolate()->debug()->OnCompileError(script);
MessageLocation location(script, position_, position_ + 1);
Handle<Object> error = factory->NewSyntaxError(message, argument);
return isolate()->template Throw<Object>(error, &location);
}
......
......@@ -6363,16 +6363,18 @@ TEST(SyntaxErrorMessageOnSyntaxException) {
v8::String::NewFromUtf8(env->GetIsolate(), "/sel\\/: \\"));
CHECK_EQ(2, compile_error_event_count);
v8::Script::Compile(
v8::String::NewFromUtf8(env->GetIsolate(), "JSON.parse('1234:')"));
v8::Local<v8::Script> script = v8::Script::Compile(
v8::String::NewFromUtf8(env->GetIsolate(), "JSON.parse('1234:')"));
CHECK_EQ(2, compile_error_event_count);
script->Run();
CHECK_EQ(3, compile_error_event_count);
v8::Script::Compile(
v8::String::NewFromUtf8(env->GetIsolate(), "new RegExp('/\\/\\\\');"));
CHECK_EQ(2, compile_error_event_count);
CHECK_EQ(3, compile_error_event_count);
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "throw 1;"));
CHECK_EQ(2, compile_error_event_count);
CHECK_EQ(3, compile_error_event_count);
}
......
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