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 8653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8664 // external code. | 8664 // external code. |
8665 try_catch.SetVerbose(true); | 8665 try_catch.SetVerbose(true); |
8666 CompileRun("throw 'from JS';"); | 8666 CompileRun("throw 'from JS';"); |
8667 CHECK(try_catch.HasCaught()); | 8667 CHECK(try_catch.HasCaught()); |
8668 CHECK(!i::Isolate::Current()->has_pending_exception()); | 8668 CHECK(!i::Isolate::Current()->has_pending_exception()); |
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 int call_depth; | |
8675 | |
8676 | |
8674 static void WithTryCatch(Handle<Message> message, Handle<Value> data) { | 8677 static void WithTryCatch(Handle<Message> message, Handle<Value> data) { |
8675 TryCatch try_catch; | 8678 TryCatch try_catch; |
8676 } | 8679 } |
8677 | 8680 |
8678 | 8681 |
8679 static void ThrowFromJS(Handle<Message> message, Handle<Value> data) { | 8682 static void ThrowFromJS(Handle<Message> message, Handle<Value> data) { |
8680 CompileRun("throw 'ThrowInJS';"); | 8683 if (--call_depth) CompileRun("throw 'ThrowInJS';"); |
Vitaly Repeshko
2011/04/11 19:37:39
In case we re-entered this message callback, shoul
antonm
2011/04/15 12:15:34
I don't think it's important for the given test.
| |
8681 } | 8684 } |
8682 | 8685 |
8683 | 8686 |
8684 static void ThrowViaApi(Handle<Message> message, Handle<Value> data) { | 8687 static void ThrowViaApi(Handle<Message> message, Handle<Value> data) { |
8685 ThrowException(v8_str("ThrowViaApi")); | 8688 if (--call_depth) ThrowException(v8_str("ThrowViaApi")); |
8686 } | 8689 } |
8687 | 8690 |
8688 | 8691 |
8689 static void WebKitLike(Handle<Message> message, Handle<Value> data) { | 8692 static void WebKitLike(Handle<Message> message, Handle<Value> data) { |
8690 Handle<String> errorMessageString = message->Get(); | 8693 Handle<String> errorMessageString = message->Get(); |
8691 CHECK(!errorMessageString.IsEmpty()); | 8694 CHECK(!errorMessageString.IsEmpty()); |
8692 message->GetStackTrace(); | 8695 message->GetStackTrace(); |
8693 message->GetScriptResourceName(); | 8696 message->GetScriptResourceName(); |
8694 } | 8697 } |
8695 | 8698 |
8696 THREADED_TEST(ExceptionsDoNotPropagatePastTryCatch) { | 8699 THREADED_TEST(ExceptionsDoNotPropagatePastTryCatch) { |
8697 HandleScope scope; | 8700 HandleScope scope; |
8698 LocalContext context; | 8701 LocalContext context; |
8699 | 8702 |
8700 Local<Function> func = | 8703 Local<Function> func = |
8701 FunctionTemplate::New(ThrowingCallbackWithTryCatch)->GetFunction(); | 8704 FunctionTemplate::New(ThrowingCallbackWithTryCatch)->GetFunction(); |
8702 context->Global()->Set(v8_str("func"), func); | 8705 context->Global()->Set(v8_str("func"), func); |
8703 | 8706 |
8704 MessageCallback callbacks[] = | 8707 MessageCallback callbacks[] = |
8705 { NULL, WebKitLike, ThrowViaApi, ThrowFromJS, WithTryCatch }; | 8708 { NULL, WebKitLike, ThrowViaApi, ThrowFromJS, WithTryCatch }; |
8706 for (unsigned i = 0; i < sizeof(callbacks)/sizeof(callbacks[0]); i++) { | 8709 for (unsigned i = 0; i < sizeof(callbacks)/sizeof(callbacks[0]); i++) { |
8707 MessageCallback callback = callbacks[i]; | 8710 MessageCallback callback = callbacks[i]; |
8708 if (callback != NULL) { | 8711 if (callback != NULL) { |
8709 V8::AddMessageListener(callback); | 8712 V8::AddMessageListener(callback); |
8710 } | 8713 } |
8714 call_depth = 5; | |
Vitaly Repeshko
2011/04/11 19:37:39
5 is arbitrary here, right? In any case, it'd be n
antonm
2011/04/15 12:15:34
Done.
| |
8711 ExpectFalse( | 8715 ExpectFalse( |
8712 "var thrown = false;\n" | 8716 "var thrown = false;\n" |
8713 "try { func(); } catch(e) { thrown = true; }\n" | 8717 "try { func(); } catch(e) { thrown = true; }\n" |
8714 "thrown\n"); | 8718 "thrown\n"); |
8715 if (callback != NULL) { | 8719 if (callback != NULL) { |
8716 V8::RemoveMessageListeners(callback); | 8720 V8::RemoveMessageListeners(callback); |
8717 } | 8721 } |
8718 } | 8722 } |
8719 } | 8723 } |
8720 | 8724 |
(...skipping 5164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13885 CHECK(func2->CreationContext() == context2); | 13889 CHECK(func2->CreationContext() == context2); |
13886 CheckContextId(func2, 2); | 13890 CheckContextId(func2, 2); |
13887 CHECK(instance2->CreationContext() == context2); | 13891 CHECK(instance2->CreationContext() == context2); |
13888 CheckContextId(instance2, 2); | 13892 CheckContextId(instance2, 2); |
13889 } | 13893 } |
13890 | 13894 |
13891 context1.Dispose(); | 13895 context1.Dispose(); |
13892 context2.Dispose(); | 13896 context2.Dispose(); |
13893 context3.Dispose(); | 13897 context3.Dispose(); |
13894 } | 13898 } |
OLD | NEW |