Index: test/cctest/test-api.cc |
=================================================================== |
--- test/cctest/test-api.cc (revision 14909) |
+++ test/cctest/test-api.cc (working copy) |
@@ -4322,6 +4322,37 @@ |
} |
+v8::Handle<Value> TryCatchNestedSyntaxHelper(const v8::Arguments& args) { |
+ ApiTestFuzzer::Fuzz(); |
+ v8::TryCatch try_catch; |
+ v8::ScriptOrigin origin(v8::String::New("inner"), |
+ v8::Integer::New(1), v8::Integer::New(1)); |
+ v8::Script::Compile(v8::String::New("invalid ?= 1;\n"), &origin); |
+ CHECK(try_catch.HasCaught()); |
+ return try_catch.ReThrow(); |
+} |
+ |
+ |
+// This test ensures that an outer TryCatch in the following situation: |
+// C++/TryCatch -> JS -> C++/TryCatch -> JS w/ SyntaxError |
+// does clobber the Message object generated for the inner TryCatch. |
+// This exercises the ability of TryCatch.ReThrow() to restore the |
+// inner pending Message before throwing the exception again. |
+TEST(TryCatchNestedSyntax) { |
+ v8::HandleScope scope(v8::Isolate::GetCurrent()); |
+ v8::V8::Initialize(); |
+ v8::TryCatch try_catch; |
+ Local<ObjectTemplate> templ = ObjectTemplate::New(); |
+ templ->Set(v8_str("TryCatchNestedSyntaxHelper"), |
+ v8::FunctionTemplate::New(TryCatchNestedSyntaxHelper)); |
+ LocalContext context(0, templ); |
+ CompileRunWithOrigin("TryCatchNestedSyntaxHelper();\n", "outer", 1, 1); |
+ CHECK(try_catch.HasCaught()); |
+ Handle<Value> resource = try_catch.Message()->GetScriptResourceName(); |
+ CHECK_EQ(0, strcmp(*v8::String::Utf8Value(resource), "inner")); |
+} |
+ |
+ |
THREADED_TEST(Equality) { |
LocalContext context; |
v8::Isolate* isolate = context->GetIsolate(); |