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

Side by Side Diff: test/cctest/test-api.cc

Issue 321763002: Don't clear exception pending message if we have externally TryCatch and finally on top of stack. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 6 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 unified diff | Download patch
« no previous file with comments | « src/isolate.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 8344 matching lines...) Expand 10 before | Expand all | Expand 10 after
8355 "})()"); 8355 "})()");
8356 CHECK(!try_catch.HasCaught()); 8356 CHECK(!try_catch.HasCaught());
8357 CompileRun( 8357 CompileRun(
8358 "(function()" 8358 "(function()"
8359 " { try { throw ''; } finally { throw 0; }" 8359 " { try { throw ''; } finally { throw 0; }"
8360 "})()"); 8360 "})()");
8361 CHECK(try_catch.HasCaught()); 8361 CHECK(try_catch.HasCaught());
8362 } 8362 }
8363 8363
8364 8364
8365 void CEvaluate(const v8::FunctionCallbackInfo<v8::Value>& args) {
8366 v8::HandleScope scope(args.GetIsolate());
8367 CompileRun(args[0]->ToString());
8368 }
8369
8370
8371 TEST(TryCatchFinallyStoresMessageUsingTryCatchHandler) {
8372 v8::Isolate* isolate = CcTest::isolate();
8373 v8::HandleScope scope(isolate);
8374 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
8375 templ->Set(v8_str("CEvaluate"),
8376 v8::FunctionTemplate::New(isolate, CEvaluate));
8377 LocalContext context(0, templ);
8378 v8::TryCatch try_catch;
8379 CompileRun("try {"
8380 " CEvaluate('throw 1;');"
8381 "} finally {"
8382 "}");
8383 CHECK(try_catch.HasCaught());
8384 CHECK(!try_catch.Message().IsEmpty());
8385 String::Utf8Value exception_value(try_catch.Exception());
8386 CHECK_EQ(*exception_value, "1");
8387 try_catch.Reset();
8388 CompileRun("try {"
8389 " CEvaluate('throw 1;');"
8390 "} finally {"
8391 " throw 2;"
8392 "}");
8393 CHECK(try_catch.HasCaught());
8394 CHECK(!try_catch.Message().IsEmpty());
8395 String::Utf8Value finally_exception_value(try_catch.Exception());
8396 CHECK_EQ(*finally_exception_value, "2");
8397 }
8398
8399
8365 // For use within the TestSecurityHandler() test. 8400 // For use within the TestSecurityHandler() test.
8366 static bool g_security_callback_result = false; 8401 static bool g_security_callback_result = false;
8367 static bool NamedSecurityTestCallback(Local<v8::Object> global, 8402 static bool NamedSecurityTestCallback(Local<v8::Object> global,
8368 Local<Value> name, 8403 Local<Value> name,
8369 v8::AccessType type, 8404 v8::AccessType type,
8370 Local<Value> data) { 8405 Local<Value> data) {
8371 printf("a\n"); 8406 printf("a\n");
8372 // Always allow read access. 8407 // Always allow read access.
8373 if (type == v8::ACCESS_GET) 8408 if (type == v8::ACCESS_GET)
8374 return true; 8409 return true;
(...skipping 14297 matching lines...) Expand 10 before | Expand all | Expand 10 after
22672 Local<Script> script = v8::ScriptCompiler::Compile( 22707 Local<Script> script = v8::ScriptCompiler::Compile(
22673 isolate, &script_source); 22708 isolate, &script_source);
22674 Local<Value> script_name = script->GetUnboundScript()->GetScriptName(); 22709 Local<Value> script_name = script->GetUnboundScript()->GetScriptName();
22675 CHECK(!script_name.IsEmpty()); 22710 CHECK(!script_name.IsEmpty());
22676 CHECK(script_name->IsString()); 22711 CHECK(script_name->IsString());
22677 String::Utf8Value utf8_name(script_name); 22712 String::Utf8Value utf8_name(script_name);
22678 CHECK_EQ(url, *utf8_name); 22713 CHECK_EQ(url, *utf8_name);
22679 int line_number = script->GetUnboundScript()->GetLineNumber(0); 22714 int line_number = script->GetUnboundScript()->GetLineNumber(0);
22680 CHECK_EQ(13, line_number); 22715 CHECK_EQ(13, line_number);
22681 } 22716 }
OLDNEW
« 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