OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 8658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8669 CHECK(!i::Isolate::Current()->has_scheduled_exception()); | 8669 CHECK(!i::Isolate::Current()->has_scheduled_exception()); |
8670 return Undefined(); | 8670 return Undefined(); |
8671 } | 8671 } |
8672 | 8672 |
8673 | 8673 |
8674 static void WithTryCatch(Handle<Message> message, Handle<Value> data) { | 8674 static void WithTryCatch(Handle<Message> message, Handle<Value> data) { |
8675 TryCatch try_catch; | 8675 TryCatch try_catch; |
8676 } | 8676 } |
8677 | 8677 |
8678 | 8678 |
8679 static void ThrowFromJS(Handle<Message> message, Handle<Value> data) { | |
8680 CompileRun("throw 'ThrowInJS';"); | |
yurys
2011/04/11 07:52:36
Can we rewrite this listener to make it reenterabl
antonm
2011/04/11 16:19:18
No doubt.
| |
8681 } | |
8682 | |
8683 | |
8684 static void ThrowViaApi(Handle<Message> message, Handle<Value> data) { | |
8685 ThrowException(v8_str("ThrowViaApi")); | |
8686 } | |
8687 | |
8688 | |
8689 static void WebKitLike(Handle<Message> message, Handle<Value> data) { | 8679 static void WebKitLike(Handle<Message> message, Handle<Value> data) { |
8690 Handle<String> errorMessageString = message->Get(); | 8680 Handle<String> errorMessageString = message->Get(); |
8691 CHECK(!errorMessageString.IsEmpty()); | 8681 CHECK(!errorMessageString.IsEmpty()); |
8692 message->GetStackTrace(); | 8682 message->GetStackTrace(); |
8693 message->GetScriptResourceName(); | 8683 message->GetScriptResourceName(); |
8694 } | 8684 } |
8695 | 8685 |
8696 THREADED_TEST(ExceptionsDoNotPropagatePastTryCatch) { | 8686 THREADED_TEST(ExceptionsDoNotPropagatePastTryCatch) { |
8697 HandleScope scope; | 8687 HandleScope scope; |
8698 LocalContext context; | 8688 LocalContext context; |
8699 | 8689 |
8700 Local<Function> func = | 8690 Local<Function> func = |
8701 FunctionTemplate::New(ThrowingCallbackWithTryCatch)->GetFunction(); | 8691 FunctionTemplate::New(ThrowingCallbackWithTryCatch)->GetFunction(); |
8702 context->Global()->Set(v8_str("func"), func); | 8692 context->Global()->Set(v8_str("func"), func); |
8703 | 8693 |
8704 MessageCallback callbacks[] = | 8694 MessageCallback callbacks[] = |
8705 { NULL, WebKitLike, ThrowViaApi, ThrowFromJS, WithTryCatch }; | 8695 { NULL, WebKitLike, WithTryCatch }; |
8706 for (unsigned i = 0; i < sizeof(callbacks)/sizeof(callbacks[0]); i++) { | 8696 for (unsigned i = 0; i < sizeof(callbacks)/sizeof(callbacks[0]); i++) { |
8707 MessageCallback callback = callbacks[i]; | 8697 MessageCallback callback = callbacks[i]; |
8708 if (callback != NULL) { | 8698 if (callback != NULL) { |
8709 V8::AddMessageListener(callback); | 8699 V8::AddMessageListener(callback); |
8710 } | 8700 } |
8711 ExpectFalse( | 8701 ExpectFalse( |
8712 "var thrown = false;\n" | 8702 "var thrown = false;\n" |
8713 "try { func(); } catch(e) { thrown = true; }\n" | 8703 "try { func(); } catch(e) { thrown = true; }\n" |
8714 "thrown\n"); | 8704 "thrown\n"); |
8715 if (callback != NULL) { | 8705 if (callback != NULL) { |
(...skipping 5183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13899 CHECK(func2->CreationContext() == context2); | 13889 CHECK(func2->CreationContext() == context2); |
13900 CheckContextId(func2, 2); | 13890 CheckContextId(func2, 2); |
13901 CHECK(instance2->CreationContext() == context2); | 13891 CHECK(instance2->CreationContext() == context2); |
13902 CheckContextId(instance2, 2); | 13892 CheckContextId(instance2, 2); |
13903 } | 13893 } |
13904 | 13894 |
13905 context1.Dispose(); | 13895 context1.Dispose(); |
13906 context2.Dispose(); | 13896 context2.Dispose(); |
13907 context3.Dispose(); | 13897 context3.Dispose(); |
13908 } | 13898 } |
OLD | NEW |