Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index 8db3fcb438d9743f58845f4844526172d1a12331..eae682a0979c1404f2fa680e455ca9ff356046e5 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -3056,6 +3056,32 @@ TEST(APIThrowMessageOverwrittenToString) { |
} |
+static void check_custom_error_message( |
+ v8::Handle<v8::Message> message, |
+ v8::Handle<v8::Value> data) { |
+ const char* uncaught_error = "Uncaught MyError toString"; |
+ CHECK(message->Get()->Equals(v8_str(uncaught_error))); |
+} |
+ |
+ |
+TEST(CustomErrorToString) { |
+ v8::HandleScope scope; |
+ v8::V8::AddMessageListener(check_custom_error_message); |
+ LocalContext context; |
+ CompileRun( |
+ "function MyError(name, message) { " |
+ " this.name = name; " |
+ " this.message = message; " |
+ "} " |
+ "MyError.prototype = Object.create(Error.prototype); " |
+ "MyError.prototype.toString = function() { " |
+ " return 'MyError toString'; " |
+ "}; " |
+ "throw new MyError('my name', 'my message'); "); |
+ v8::V8::RemoveMessageListeners(check_custom_error_message); |
+} |
+ |
+ |
static void receive_message(v8::Handle<v8::Message> message, |
v8::Handle<v8::Value> data) { |
message->Get(); |