Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Unified Diff: test/cctest/test-api.cc

Issue 17694002: Restore message when rethrowing in TryCatch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/isolate.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « src/isolate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698