| 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 2655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2666 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource)); | 2666 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource)); |
| 2667 const char* extension_names[] = { "simpletest" }; | 2667 const char* extension_names[] = { "simpletest" }; |
| 2668 v8::ExtensionConfiguration extensions(1, extension_names); | 2668 v8::ExtensionConfiguration extensions(1, extension_names); |
| 2669 v8::Handle<Context> context = Context::New(&extensions); | 2669 v8::Handle<Context> context = Context::New(&extensions); |
| 2670 Context::Scope lock(context); | 2670 Context::Scope lock(context); |
| 2671 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); | 2671 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); |
| 2672 CHECK_EQ(result, v8::Integer::New(4)); | 2672 CHECK_EQ(result, v8::Integer::New(4)); |
| 2673 } | 2673 } |
| 2674 | 2674 |
| 2675 | 2675 |
| 2676 static const char* kEvalExtensionSource = | 2676 static const char* kEvalExtensionSource1 = |
| 2677 "function UseEval() {" | 2677 "function UseEval1() {" |
| 2678 " var x = 42;" | 2678 " var x = 42;" |
| 2679 " return eval('x');" | 2679 " return eval('x');" |
| 2680 "}"; | 2680 "}"; |
| 2681 | 2681 |
| 2682 | 2682 |
| 2683 static const char* kEvalExtensionSource2 = |
| 2684 "(function() {" |
| 2685 " var x = 42;" |
| 2686 " function e() {" |
| 2687 " return eval('x');" |
| 2688 " }" |
| 2689 " this.UseEval2 = e;" |
| 2690 "})()"; |
| 2691 |
| 2692 |
| 2683 THREADED_TEST(UseEvalFromExtension) { | 2693 THREADED_TEST(UseEvalFromExtension) { |
| 2684 v8::HandleScope handle_scope; | 2694 v8::HandleScope handle_scope; |
| 2685 v8::RegisterExtension(new Extension("evaltest", kEvalExtensionSource)); | 2695 v8::RegisterExtension(new Extension("evaltest1", kEvalExtensionSource1)); |
| 2686 const char* extension_names[] = { "evaltest" }; | 2696 v8::RegisterExtension(new Extension("evaltest2", kEvalExtensionSource2)); |
| 2687 v8::ExtensionConfiguration extensions(1, extension_names); | 2697 const char* extension_names[] = { "evaltest1", "evaltest2" }; |
| 2698 v8::ExtensionConfiguration extensions(2, extension_names); |
| 2688 v8::Handle<Context> context = Context::New(&extensions); | 2699 v8::Handle<Context> context = Context::New(&extensions); |
| 2689 Context::Scope lock(context); | 2700 Context::Scope lock(context); |
| 2690 v8::Handle<Value> result = Script::Compile(v8_str("UseEval()"))->Run(); | 2701 v8::Handle<Value> result = Script::Compile(v8_str("UseEval1()"))->Run(); |
| 2702 CHECK_EQ(result, v8::Integer::New(42)); |
| 2703 result = Script::Compile(v8_str("UseEval2()"))->Run(); |
| 2691 CHECK_EQ(result, v8::Integer::New(42)); | 2704 CHECK_EQ(result, v8::Integer::New(42)); |
| 2692 } | 2705 } |
| 2693 | 2706 |
| 2694 | 2707 |
| 2695 static const char* kWithExtensionSource = | 2708 static const char* kWithExtensionSource1 = |
| 2696 "function UseWith() {" | 2709 "function UseWith1() {" |
| 2697 " var x = 42;" | 2710 " var x = 42;" |
| 2698 " with({x:87}) { return x; }" | 2711 " with({x:87}) { return x; }" |
| 2699 "}"; | 2712 "}"; |
| 2700 | 2713 |
| 2701 | 2714 |
| 2715 |
| 2716 static const char* kWithExtensionSource2 = |
| 2717 "(function() {" |
| 2718 " var x = 42;" |
| 2719 " function e() {" |
| 2720 " with ({x:87}) { return x; }" |
| 2721 " }" |
| 2722 " this.UseWith2 = e;" |
| 2723 "})()"; |
| 2724 |
| 2725 |
| 2702 THREADED_TEST(UseWithFromExtension) { | 2726 THREADED_TEST(UseWithFromExtension) { |
| 2703 v8::HandleScope handle_scope; | 2727 v8::HandleScope handle_scope; |
| 2704 v8::RegisterExtension(new Extension("withtest", kWithExtensionSource)); | 2728 v8::RegisterExtension(new Extension("withtest1", kWithExtensionSource1)); |
| 2705 const char* extension_names[] = { "withtest" }; | 2729 v8::RegisterExtension(new Extension("withtest2", kWithExtensionSource2)); |
| 2706 v8::ExtensionConfiguration extensions(1, extension_names); | 2730 const char* extension_names[] = { "withtest1", "withtest2" }; |
| 2731 v8::ExtensionConfiguration extensions(2, extension_names); |
| 2707 v8::Handle<Context> context = Context::New(&extensions); | 2732 v8::Handle<Context> context = Context::New(&extensions); |
| 2708 Context::Scope lock(context); | 2733 Context::Scope lock(context); |
| 2709 v8::Handle<Value> result = Script::Compile(v8_str("UseWith()"))->Run(); | 2734 v8::Handle<Value> result = Script::Compile(v8_str("UseWith1()"))->Run(); |
| 2735 CHECK_EQ(result, v8::Integer::New(87)); |
| 2736 result = Script::Compile(v8_str("UseWith2()"))->Run(); |
| 2710 CHECK_EQ(result, v8::Integer::New(87)); | 2737 CHECK_EQ(result, v8::Integer::New(87)); |
| 2711 } | 2738 } |
| 2712 | 2739 |
| 2713 | 2740 |
| 2714 THREADED_TEST(AutoExtensions) { | 2741 THREADED_TEST(AutoExtensions) { |
| 2715 v8::HandleScope handle_scope; | 2742 v8::HandleScope handle_scope; |
| 2716 Extension* extension = new Extension("autotest", kSimpleExtensionSource); | 2743 Extension* extension = new Extension("autotest", kSimpleExtensionSource); |
| 2717 extension->set_auto_enable(true); | 2744 extension->set_auto_enable(true); |
| 2718 v8::RegisterExtension(extension); | 2745 v8::RegisterExtension(extension); |
| 2719 v8::Handle<Context> context = Context::New(); | 2746 v8::Handle<Context> context = Context::New(); |
| (...skipping 5125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7845 CHECK(strstr(*stack, "at foo (stack-trace-test") != NULL); | 7872 CHECK(strstr(*stack, "at foo (stack-trace-test") != NULL); |
| 7846 } | 7873 } |
| 7847 | 7874 |
| 7848 | 7875 |
| 7849 // Test that idle notification can be handled when V8 has not yet been | 7876 // Test that idle notification can be handled when V8 has not yet been |
| 7850 // set up. | 7877 // set up. |
| 7851 THREADED_TEST(IdleNotification) { | 7878 THREADED_TEST(IdleNotification) { |
| 7852 for (int i = 0; i < 100; i++) v8::V8::IdleNotification(true); | 7879 for (int i = 0; i < 100; i++) v8::V8::IdleNotification(true); |
| 7853 for (int i = 0; i < 100; i++) v8::V8::IdleNotification(false); | 7880 for (int i = 0; i < 100; i++) v8::V8::IdleNotification(false); |
| 7854 } | 7881 } |
| OLD | NEW |