Chromium Code Reviews| Index: test/cctest/test-api.cc |
| diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
| index c39b4292b19d68109118832e79c9afc9329d001d..901da973d9c94aa3b06385d055a3aa7e007431f4 100755 |
| --- a/test/cctest/test-api.cc |
| +++ b/test/cctest/test-api.cc |
| @@ -4500,6 +4500,40 @@ TEST(TryCatchNested) { |
| } |
| +void TryCatchNestedSyntaxHelper( |
| + const v8::FunctionCallbackInfo<v8::Value>& 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()); |
| + Handle<Value> resource = try_catch.Message()->GetScriptResourceName(); |
| + CHECK_EQ(0, strcmp(*v8::String::Utf8Value(resource), "inner")); |
| + 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. |
|
apaprocki
2013/06/26 03:22:52
I meant to say "doesn't clobber" here.
|
| +// 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(); |