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

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 b95f292b6e1c1763e1eefd64086ed7ebcbc8fe6d..186601883331eb221a0b8f085c0d5d2351c6bbe4 100755
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -4500,6 +4500,47 @@ TEST(TryCatchNested) {
}
+void TryCatchMixedNestingCheck(v8::TryCatch* try_catch) {
+ CHECK(try_catch->HasCaught());
+ Handle<Message> message = try_catch->Message();
+ Handle<Value> resource = message->GetScriptResourceName();
+ CHECK_EQ(0, strcmp(*v8::String::Utf8Value(resource), "inner"));
+ CHECK_EQ(0, strcmp(*v8::String::Utf8Value(message->Get()),
+ "Uncaught Error: a"));
+ CHECK_EQ(1, message->GetLineNumber());
+ CHECK_EQ(6, message->GetStartColumn());
+}
+
+
+void TryCatchMixedNestingHelper(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ ApiTestFuzzer::Fuzz();
+ v8::TryCatch try_catch;
+ CompileRunWithOrigin("throw new Error('a');\n", "inner", 0, 0);
+ CHECK(try_catch.HasCaught());
+ TryCatchMixedNestingCheck(&try_catch);
+ try_catch.ReThrow();
+}
+
+
+// This test ensures that an outer TryCatch in the following situation:
+// C++/TryCatch -> JS -> C++/TryCatch -> JS w/ SyntaxError
+// does not 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(TryCatchMixedNesting) {
+ v8::HandleScope scope(v8::Isolate::GetCurrent());
+ v8::V8::Initialize();
+ v8::TryCatch try_catch;
+ Local<ObjectTemplate> templ = ObjectTemplate::New();
+ templ->Set(v8_str("TryCatchMixedNestingHelper"),
+ v8::FunctionTemplate::New(TryCatchMixedNestingHelper));
+ LocalContext context(0, templ);
+ CompileRunWithOrigin("TryCatchMixedNestingHelper();\n", "outer", 1, 1);
+ TryCatchMixedNestingCheck(&try_catch);
+}
+
+
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