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 16750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16761 CheckInstanceCheckedAccessors(false); | 16761 CheckInstanceCheckedAccessors(false); |
16762 | 16762 |
16763 printf("Testing positive with modified prototype chain ...\n"); | 16763 printf("Testing positive with modified prototype chain ...\n"); |
16764 CompileRun("var obj = new f();" | 16764 CompileRun("var obj = new f();" |
16765 "var pro = {};" | 16765 "var pro = {};" |
16766 "pro.__proto__ = obj.__proto__;" | 16766 "pro.__proto__ = obj.__proto__;" |
16767 "obj.__proto__ = pro;"); | 16767 "obj.__proto__ = pro;"); |
16768 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj")))); | 16768 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj")))); |
16769 CheckInstanceCheckedAccessors(true); | 16769 CheckInstanceCheckedAccessors(true); |
16770 } | 16770 } |
16771 | |
16772 | |
16773 TEST(TryFinallyMessage) { | |
16774 v8::HandleScope scope; | |
16775 LocalContext context; | |
16776 { | |
16777 // Test that the original error message is not lost if there is a | |
16778 // recursive call into Javascript is done in the finally block, e.g. to | |
16779 // initialize an IC. (crbug.com/129171) | |
16780 TryCatch try_catch; | |
16781 const char* trigger_ic = | |
16782 "try { \n" | |
16783 " throw new Error('test'); \n" | |
16784 "} finally { \n" | |
16785 " var x = 0; \n" | |
16786 " x++; \n" // Trigger an IC initialization here. | |
16787 "} \n"; | |
16788 Local<Value> result = CompileRun(trigger_ic); | |
16789 CHECK(try_catch.HasCaught()); | |
16790 Local<Message> message = try_catch.Message(); | |
16791 CHECK(!message.IsEmpty()); | |
16792 CHECK_EQ(2, message->GetLineNumber()); | |
16793 } | |
16794 | |
16795 { | |
16796 // Test that the original exception message is indeed overwritten if | |
16797 // a new error is thrown in the finally block. | |
16798 TryCatch try_catch; | |
16799 const char* throw_again = | |
16800 "try { \n" | |
16801 " throw new Error('test'); \n" | |
16802 "} finally { \n" | |
16803 " var x = 0; \n" | |
16804 " x++; \n" | |
16805 " throw new Error('again'); \n" // This is the new uncaught error. | |
16806 "} \n"; | |
16807 Local<Value> result = CompileRun(throw_again); | |
16808 CHECK(try_catch.HasCaught()); | |
16809 Local<Message> message = try_catch.Message(); | |
16810 CHECK(!message.IsEmpty()); | |
16811 CHECK_EQ(6, message->GetLineNumber()); | |
16812 } | |
16813 } | |
OLD | NEW |