diff --git a/deps/v8/AUTHORS b/deps/v8/AUTHORS index c54cad02b2d15e..3bc767945cfdee 100644 --- a/deps/v8/AUTHORS +++ b/deps/v8/AUTHORS @@ -42,7 +42,7 @@ Alexis Campailla Andreas Anyuru Andrew Paprocki Andrei Kashcha -Anna Henningsen +Anna Henningsen Bangfu Tao Ben Noordhuis Benjamin Tan diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index ddecda5abe18c5..abbcc76c406b4d 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 6 #define V8_MINOR_VERSION 2 #define V8_BUILD_NUMBER 414 -#define V8_PATCH_LEVEL 61 +#define V8_PATCH_LEVEL 62 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/src/messages.cc b/deps/v8/src/messages.cc index 780198dac6b832..eb869ffcc8fc9c 100644 --- a/deps/v8/src/messages.cc +++ b/deps/v8/src/messages.cc @@ -114,6 +114,9 @@ void MessageHandler::ReportMessage(Isolate* isolate, const MessageLocation* loc, } if (!maybe_stringified.ToHandle(&stringified)) { + DCHECK(isolate->has_pending_exception()); + isolate->clear_pending_exception(); + isolate->set_external_caught_exception(false); stringified = isolate->factory()->NewStringFromAsciiChecked("exception"); } diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index b0e070a68a3046..2a5d48037fa47d 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -5747,23 +5747,55 @@ TEST(CustomErrorMessage) { static void check_custom_rethrowing_message(v8::Local message, v8::Local data) { + CHECK(data->IsExternal()); + int* callcount = static_cast(data.As()->Value()); + ++*callcount; + const char* uncaught_error = "Uncaught exception"; CHECK(message->Get() ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error)) .FromJust()); + // Test that compiling code inside a message handler works. + CHECK(CompileRunChecked(CcTest::isolate(), "(function(a) { return a; })(42)") + ->Equals(CcTest::isolate()->GetCurrentContext(), + v8::Integer::NewFromUnsigned(CcTest::isolate(), 42)) + .FromJust()); } TEST(CustomErrorRethrowsOnToString) { + int callcount = 0; LocalContext context; - v8::HandleScope scope(context->GetIsolate()); - context->GetIsolate()->AddMessageListener(check_custom_rethrowing_message); + v8::Isolate* isolate = context->GetIsolate(); + v8::HandleScope scope(isolate); + context->GetIsolate()->AddMessageListener( + check_custom_rethrowing_message, v8::External::New(isolate, &callcount)); + + CompileRun( + "var e = { toString: function() { throw e; } };" + "try { throw e; } finally {}"); + + CHECK_EQ(callcount, 1); + context->GetIsolate()->RemoveMessageListeners( + check_custom_rethrowing_message); +} + +TEST(CustomErrorRethrowsOnToStringInsideVerboseTryCatch) { + int callcount = 0; + LocalContext context; + v8::Isolate* isolate = context->GetIsolate(); + v8::HandleScope scope(isolate); + v8::TryCatch try_catch(isolate); + try_catch.SetVerbose(true); + context->GetIsolate()->AddMessageListener( + check_custom_rethrowing_message, v8::External::New(isolate, &callcount)); CompileRun( "var e = { toString: function() { throw e; } };" "try { throw e; } finally {}"); + CHECK_EQ(callcount, 1); context->GetIsolate()->RemoveMessageListeners( check_custom_rethrowing_message); }