Index: test/cctest/test-api.cc |
=================================================================== |
--- test/cctest/test-api.cc (revision 6298) |
+++ test/cctest/test-api.cc (working copy) |
@@ -2288,6 +2288,30 @@ |
} |
+static void check_reference_error_message( |
+ v8::Handle<v8::Message> message, |
+ v8::Handle<v8::Value> data) { |
+ const char* reference_error = "Uncaught ReferenceError: asdf is not defined"; |
+ CHECK(message->Get()->Equals(v8_str(reference_error))); |
+} |
+ |
+ |
+// Test that overwritten toString methods are not invoked on uncaught |
+// exception formatting. However, they are invoked when performing |
+// normal error string conversions. |
+THREADED_TEST(APIThrowMessageOverwrittenToString) { |
+ v8::HandleScope scope; |
+ v8::V8::AddMessageListener(check_reference_error_message); |
+ LocalContext context; |
+ CompileRun("ReferenceError.prototype.toString =" |
+ " function() { return 'Whoops' }"); |
+ CompileRun("asdf;"); |
+ v8::Handle<Value> string = CompileRun("try { asdf; } catch(e) { e + ''; }"); |
+ CHECK(string->Equals(v8_str("Whoops"))); |
+ v8::V8::RemoveMessageListeners(check_message); |
+} |
+ |
+ |
static void receive_message(v8::Handle<v8::Message> message, |
v8::Handle<v8::Value> data) { |
message->Get(); |