| OLD | NEW |
| 1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 2888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2899 Extension* extension = new Extension("autotest", kSimpleExtensionSource); | 2899 Extension* extension = new Extension("autotest", kSimpleExtensionSource); |
| 2900 extension->set_auto_enable(true); | 2900 extension->set_auto_enable(true); |
| 2901 v8::RegisterExtension(extension); | 2901 v8::RegisterExtension(extension); |
| 2902 v8::Handle<Context> context = Context::New(); | 2902 v8::Handle<Context> context = Context::New(); |
| 2903 Context::Scope lock(context); | 2903 Context::Scope lock(context); |
| 2904 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); | 2904 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); |
| 2905 CHECK_EQ(result, v8::Integer::New(4)); | 2905 CHECK_EQ(result, v8::Integer::New(4)); |
| 2906 } | 2906 } |
| 2907 | 2907 |
| 2908 | 2908 |
| 2909 static const char* kSyntaxErrorInExtensionSource = |
| 2910 "["; |
| 2911 |
| 2912 |
| 2913 // Test that a syntax error in an extension does not cause a fatal |
| 2914 // error but results in an empty context. |
| 2915 THREADED_TEST(SyntaxErrorExtensions) { |
| 2916 v8::HandleScope handle_scope; |
| 2917 v8::RegisterExtension(new Extension("syntaxerror", |
| 2918 kSyntaxErrorInExtensionSource)); |
| 2919 const char* extension_names[] = { "syntaxerror" }; |
| 2920 v8::ExtensionConfiguration extensions(1, extension_names); |
| 2921 v8::Handle<Context> context = Context::New(&extensions); |
| 2922 CHECK(context.IsEmpty()); |
| 2923 } |
| 2924 |
| 2925 |
| 2926 static const char* kExceptionInExtensionSource = |
| 2927 "throw 42"; |
| 2928 |
| 2929 |
| 2930 // Test that an exception when installing an extension does not cause |
| 2931 // a fatal error but results in an empty context. |
| 2932 THREADED_TEST(ExceptionExtensions) { |
| 2933 v8::HandleScope handle_scope; |
| 2934 v8::RegisterExtension(new Extension("exception", |
| 2935 kExceptionInExtensionSource)); |
| 2936 const char* extension_names[] = { "exception" }; |
| 2937 v8::ExtensionConfiguration extensions(1, extension_names); |
| 2938 v8::Handle<Context> context = Context::New(&extensions); |
| 2939 CHECK(context.IsEmpty()); |
| 2940 } |
| 2941 |
| 2942 |
| 2909 static void CheckDependencies(const char* name, const char* expected) { | 2943 static void CheckDependencies(const char* name, const char* expected) { |
| 2910 v8::HandleScope handle_scope; | 2944 v8::HandleScope handle_scope; |
| 2911 v8::ExtensionConfiguration config(1, &name); | 2945 v8::ExtensionConfiguration config(1, &name); |
| 2912 LocalContext context(&config); | 2946 LocalContext context(&config); |
| 2913 CHECK_EQ(String::New(expected), context->Global()->Get(v8_str("loaded"))); | 2947 CHECK_EQ(String::New(expected), context->Global()->Get(v8_str("loaded"))); |
| 2914 } | 2948 } |
| 2915 | 2949 |
| 2916 | 2950 |
| 2917 /* | 2951 /* |
| 2918 * Configuration: | 2952 * Configuration: |
| (...skipping 5752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8671 " i++;" | 8705 " i++;" |
| 8672 " return s(o);" | 8706 " return s(o);" |
| 8673 " }" | 8707 " }" |
| 8674 " }" | 8708 " }" |
| 8675 "};" | 8709 "};" |
| 8676 "s(o);"); | 8710 "s(o);"); |
| 8677 CHECK(try_catch.HasCaught()); | 8711 CHECK(try_catch.HasCaught()); |
| 8678 v8::String::Utf8Value value(try_catch.Exception()); | 8712 v8::String::Utf8Value value(try_catch.Exception()); |
| 8679 CHECK_EQ(0, strcmp(*value, "Hey!")); | 8713 CHECK_EQ(0, strcmp(*value, "Hey!")); |
| 8680 } | 8714 } |
| OLD | NEW |