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

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

Issue 15669003: Fix TryCatch.ReThrow() to not clobber Message. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 7 years, 7 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
===================================================================
--- 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();
« 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