OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 2990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3001 "try { throw ''; } finally { return; }" | 3001 "try { throw ''; } finally { return; }" |
3002 "})()"))->Run(); | 3002 "})()"))->Run(); |
3003 CHECK(!try_catch.HasCaught()); | 3003 CHECK(!try_catch.HasCaught()); |
3004 Script::Compile(v8_str("(function()" | 3004 Script::Compile(v8_str("(function()" |
3005 " { try { throw ''; } finally { throw 0; }" | 3005 " { try { throw ''; } finally { throw 0; }" |
3006 "})()"))->Run(); | 3006 "})()"))->Run(); |
3007 CHECK(try_catch.HasCaught()); | 3007 CHECK(try_catch.HasCaught()); |
3008 } | 3008 } |
3009 | 3009 |
3010 | 3010 |
| 3011 TEST(CompilationErrorUsingTryCatchHandler) { |
| 3012 v8::HandleScope scope; |
| 3013 LocalContext env; |
| 3014 v8::TryCatch try_catch; |
| 3015 Script::Compile(v8_str("This doesn't &*&@#$&*^ compile.")); |
| 3016 CHECK_NE(NULL, *try_catch.Exception()); |
| 3017 CHECK(try_catch.HasCaught()); |
| 3018 } |
| 3019 |
| 3020 |
3011 // SecurityHandler can't be run twice | 3021 // SecurityHandler can't be run twice |
3012 TEST(SecurityHandler) { | 3022 TEST(SecurityHandler) { |
3013 v8::HandleScope scope0; | 3023 v8::HandleScope scope0; |
3014 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 3024 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
3015 global_template->SetAccessCheckCallbacks(NamedSecurityTestCallback, | 3025 global_template->SetAccessCheckCallbacks(NamedSecurityTestCallback, |
3016 IndexedSecurityTestCallback); | 3026 IndexedSecurityTestCallback); |
3017 // Create an environment | 3027 // Create an environment |
3018 v8::Persistent<Context> context0 = | 3028 v8::Persistent<Context> context0 = |
3019 Context::New(NULL, global_template); | 3029 Context::New(NULL, global_template); |
3020 context0->Enter(); | 3030 context0->Enter(); |
(...skipping 2353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5374 CompileRun("for (var j = 0; j < 10; j++) new RegExp('');"); | 5384 CompileRun("for (var j = 0; j < 10; j++) new RegExp('');"); |
5375 } | 5385 } |
5376 // Test CallIC. | 5386 // Test CallIC. |
5377 for (int i = 0; i < 2; i++) { | 5387 for (int i = 0; i < 2; i++) { |
5378 LocalContext context; | 5388 LocalContext context; |
5379 context->Global()->Set(v8_str("tmp"), v8::True()); | 5389 context->Global()->Set(v8_str("tmp"), v8::True()); |
5380 context->Global()->Delete(v8_str("tmp")); | 5390 context->Global()->Delete(v8_str("tmp")); |
5381 CompileRun("for (var j = 0; j < 10; j++) RegExp('')"); | 5391 CompileRun("for (var j = 0; j < 10; j++) RegExp('')"); |
5382 } | 5392 } |
5383 } | 5393 } |
OLD | NEW |