| OLD | NEW |
| 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 4914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4925 " this.name = 'MyError'; " | 4925 " this.name = 'MyError'; " |
| 4926 " this.message = msg; " | 4926 " this.message = msg; " |
| 4927 "} " | 4927 "} " |
| 4928 "MyError.prototype = Object.create(Error.prototype); " | 4928 "MyError.prototype = Object.create(Error.prototype); " |
| 4929 "throw new MyError('my message'); "); | 4929 "throw new MyError('my message'); "); |
| 4930 | 4930 |
| 4931 v8::V8::RemoveMessageListeners(check_custom_error_message); | 4931 v8::V8::RemoveMessageListeners(check_custom_error_message); |
| 4932 } | 4932 } |
| 4933 | 4933 |
| 4934 | 4934 |
| 4935 static void check_custom_rethrowing_message(v8::Handle<v8::Message> message, |
| 4936 v8::Handle<v8::Value> data) { |
| 4937 const char* uncaught_error = "Uncaught exception"; |
| 4938 CHECK(message->Get()->Equals(v8_str(uncaught_error))); |
| 4939 } |
| 4940 |
| 4941 |
| 4942 TEST(CustomErrorRethrowsOnToString) { |
| 4943 LocalContext context; |
| 4944 v8::HandleScope scope(context->GetIsolate()); |
| 4945 v8::V8::AddMessageListener(check_custom_rethrowing_message); |
| 4946 |
| 4947 CompileRun( |
| 4948 "var e = { toString: function() { throw e; } };" |
| 4949 "try { throw e; } finally {}"); |
| 4950 |
| 4951 v8::V8::RemoveMessageListeners(check_custom_rethrowing_message); |
| 4952 } |
| 4953 |
| 4954 |
| 4935 static void receive_message(v8::Handle<v8::Message> message, | 4955 static void receive_message(v8::Handle<v8::Message> message, |
| 4936 v8::Handle<v8::Value> data) { | 4956 v8::Handle<v8::Value> data) { |
| 4937 message->Get(); | 4957 message->Get(); |
| 4938 message_received = true; | 4958 message_received = true; |
| 4939 } | 4959 } |
| 4940 | 4960 |
| 4941 | 4961 |
| 4942 TEST(APIThrowMessage) { | 4962 TEST(APIThrowMessage) { |
| 4943 message_received = false; | 4963 message_received = false; |
| 4944 v8::Isolate* isolate = CcTest::isolate(); | 4964 v8::Isolate* isolate = CcTest::isolate(); |
| (...skipping 16130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21075 // add the testExtraShouldReturnFive export | 21095 // add the testExtraShouldReturnFive export |
| 21076 v8::Local<v8::Object> exports = env->GetExtrasExportsObject(); | 21096 v8::Local<v8::Object> exports = env->GetExtrasExportsObject(); |
| 21077 | 21097 |
| 21078 auto func = | 21098 auto func = |
| 21079 exports->Get(v8_str("testExtraShouldReturnFive")).As<v8::Function>(); | 21099 exports->Get(v8_str("testExtraShouldReturnFive")).As<v8::Function>(); |
| 21080 auto undefined = v8::Undefined(isolate); | 21100 auto undefined = v8::Undefined(isolate); |
| 21081 auto result = func->Call(undefined, 0, {}).As<v8::Number>(); | 21101 auto result = func->Call(undefined, 0, {}).As<v8::Number>(); |
| 21082 | 21102 |
| 21083 CHECK(result->Value() == 5.0); | 21103 CHECK(result->Value() == 5.0); |
| 21084 } | 21104 } |
| OLD | NEW |