| 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 6595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6606 Script::Compile(v8_str("JSNI_Log('LOG')"))->Run(); | 6606 Script::Compile(v8_str("JSNI_Log('LOG')"))->Run(); |
| 6607 } | 6607 } |
| 6608 | 6608 |
| 6609 | 6609 |
| 6610 static const char* kSimpleExtensionSource = | 6610 static const char* kSimpleExtensionSource = |
| 6611 "function Foo() {" | 6611 "function Foo() {" |
| 6612 " return 4;" | 6612 " return 4;" |
| 6613 "}"; | 6613 "}"; |
| 6614 | 6614 |
| 6615 | 6615 |
| 6616 THREADED_TEST(SimpleExtensions) { | 6616 TEST(SimpleExtensions) { |
| 6617 v8::HandleScope handle_scope(CcTest::isolate()); | 6617 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6618 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource)); | 6618 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource)); |
| 6619 const char* extension_names[] = { "simpletest" }; | 6619 const char* extension_names[] = { "simpletest" }; |
| 6620 v8::ExtensionConfiguration extensions(1, extension_names); | 6620 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6621 v8::Handle<Context> context = | 6621 v8::Handle<Context> context = |
| 6622 Context::New(CcTest::isolate(), &extensions); | 6622 Context::New(CcTest::isolate(), &extensions); |
| 6623 Context::Scope lock(context); | 6623 Context::Scope lock(context); |
| 6624 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); | 6624 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); |
| 6625 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); | 6625 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); |
| 6626 } | 6626 } |
| 6627 | 6627 |
| 6628 | 6628 |
| 6629 THREADED_TEST(NullExtensions) { | 6629 TEST(NullExtensions) { |
| 6630 v8::HandleScope handle_scope(CcTest::isolate()); | 6630 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6631 v8::RegisterExtension(new Extension("nulltest", NULL)); | 6631 v8::RegisterExtension(new Extension("nulltest", NULL)); |
| 6632 const char* extension_names[] = { "nulltest" }; | 6632 const char* extension_names[] = { "nulltest" }; |
| 6633 v8::ExtensionConfiguration extensions(1, extension_names); | 6633 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6634 v8::Handle<Context> context = | 6634 v8::Handle<Context> context = |
| 6635 Context::New(CcTest::isolate(), &extensions); | 6635 Context::New(CcTest::isolate(), &extensions); |
| 6636 Context::Scope lock(context); | 6636 Context::Scope lock(context); |
| 6637 v8::Handle<Value> result = Script::Compile(v8_str("1+3"))->Run(); | 6637 v8::Handle<Value> result = Script::Compile(v8_str("1+3"))->Run(); |
| 6638 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); | 6638 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); |
| 6639 } | 6639 } |
| 6640 | 6640 |
| 6641 | 6641 |
| 6642 static const char* kEmbeddedExtensionSource = | 6642 static const char* kEmbeddedExtensionSource = |
| 6643 "function Ret54321(){return 54321;}~~@@$" | 6643 "function Ret54321(){return 54321;}~~@@$" |
| 6644 "$%% THIS IS A SERIES OF NON-NULL-TERMINATED STRINGS."; | 6644 "$%% THIS IS A SERIES OF NON-NULL-TERMINATED STRINGS."; |
| 6645 static const int kEmbeddedExtensionSourceValidLen = 34; | 6645 static const int kEmbeddedExtensionSourceValidLen = 34; |
| 6646 | 6646 |
| 6647 | 6647 |
| 6648 THREADED_TEST(ExtensionMissingSourceLength) { | 6648 TEST(ExtensionMissingSourceLength) { |
| 6649 v8::HandleScope handle_scope(CcTest::isolate()); | 6649 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6650 v8::RegisterExtension(new Extension("srclentest_fail", | 6650 v8::RegisterExtension(new Extension("srclentest_fail", |
| 6651 kEmbeddedExtensionSource)); | 6651 kEmbeddedExtensionSource)); |
| 6652 const char* extension_names[] = { "srclentest_fail" }; | 6652 const char* extension_names[] = { "srclentest_fail" }; |
| 6653 v8::ExtensionConfiguration extensions(1, extension_names); | 6653 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6654 v8::Handle<Context> context = | 6654 v8::Handle<Context> context = |
| 6655 Context::New(CcTest::isolate(), &extensions); | 6655 Context::New(CcTest::isolate(), &extensions); |
| 6656 CHECK_EQ(0, *context); | 6656 CHECK_EQ(0, *context); |
| 6657 } | 6657 } |
| 6658 | 6658 |
| 6659 | 6659 |
| 6660 THREADED_TEST(ExtensionWithSourceLength) { | 6660 TEST(ExtensionWithSourceLength) { |
| 6661 for (int source_len = kEmbeddedExtensionSourceValidLen - 1; | 6661 for (int source_len = kEmbeddedExtensionSourceValidLen - 1; |
| 6662 source_len <= kEmbeddedExtensionSourceValidLen + 1; ++source_len) { | 6662 source_len <= kEmbeddedExtensionSourceValidLen + 1; ++source_len) { |
| 6663 v8::HandleScope handle_scope(CcTest::isolate()); | 6663 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6664 i::ScopedVector<char> extension_name(32); | 6664 i::ScopedVector<char> extension_name(32); |
| 6665 i::OS::SNPrintF(extension_name, "ext #%d", source_len); | 6665 i::OS::SNPrintF(extension_name, "ext #%d", source_len); |
| 6666 v8::RegisterExtension(new Extension(extension_name.start(), | 6666 v8::RegisterExtension(new Extension(extension_name.start(), |
| 6667 kEmbeddedExtensionSource, 0, 0, | 6667 kEmbeddedExtensionSource, 0, 0, |
| 6668 source_len)); | 6668 source_len)); |
| 6669 const char* extension_names[1] = { extension_name.start() }; | 6669 const char* extension_names[1] = { extension_name.start() }; |
| 6670 v8::ExtensionConfiguration extensions(1, extension_names); | 6670 v8::ExtensionConfiguration extensions(1, extension_names); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 6692 static const char* kEvalExtensionSource2 = | 6692 static const char* kEvalExtensionSource2 = |
| 6693 "(function() {" | 6693 "(function() {" |
| 6694 " var x = 42;" | 6694 " var x = 42;" |
| 6695 " function e() {" | 6695 " function e() {" |
| 6696 " return eval('x');" | 6696 " return eval('x');" |
| 6697 " }" | 6697 " }" |
| 6698 " this.UseEval2 = e;" | 6698 " this.UseEval2 = e;" |
| 6699 "})()"; | 6699 "})()"; |
| 6700 | 6700 |
| 6701 | 6701 |
| 6702 THREADED_TEST(UseEvalFromExtension) { | 6702 TEST(UseEvalFromExtension) { |
| 6703 v8::HandleScope handle_scope(CcTest::isolate()); | 6703 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6704 v8::RegisterExtension(new Extension("evaltest1", kEvalExtensionSource1)); | 6704 v8::RegisterExtension(new Extension("evaltest1", kEvalExtensionSource1)); |
| 6705 v8::RegisterExtension(new Extension("evaltest2", kEvalExtensionSource2)); | 6705 v8::RegisterExtension(new Extension("evaltest2", kEvalExtensionSource2)); |
| 6706 const char* extension_names[] = { "evaltest1", "evaltest2" }; | 6706 const char* extension_names[] = { "evaltest1", "evaltest2" }; |
| 6707 v8::ExtensionConfiguration extensions(2, extension_names); | 6707 v8::ExtensionConfiguration extensions(2, extension_names); |
| 6708 v8::Handle<Context> context = | 6708 v8::Handle<Context> context = |
| 6709 Context::New(CcTest::isolate(), &extensions); | 6709 Context::New(CcTest::isolate(), &extensions); |
| 6710 Context::Scope lock(context); | 6710 Context::Scope lock(context); |
| 6711 v8::Handle<Value> result = Script::Compile(v8_str("UseEval1()"))->Run(); | 6711 v8::Handle<Value> result = Script::Compile(v8_str("UseEval1()"))->Run(); |
| 6712 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 42)); | 6712 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 42)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 6726 static const char* kWithExtensionSource2 = | 6726 static const char* kWithExtensionSource2 = |
| 6727 "(function() {" | 6727 "(function() {" |
| 6728 " var x = 42;" | 6728 " var x = 42;" |
| 6729 " function e() {" | 6729 " function e() {" |
| 6730 " with ({x:87}) { return x; }" | 6730 " with ({x:87}) { return x; }" |
| 6731 " }" | 6731 " }" |
| 6732 " this.UseWith2 = e;" | 6732 " this.UseWith2 = e;" |
| 6733 "})()"; | 6733 "})()"; |
| 6734 | 6734 |
| 6735 | 6735 |
| 6736 THREADED_TEST(UseWithFromExtension) { | 6736 TEST(UseWithFromExtension) { |
| 6737 v8::HandleScope handle_scope(CcTest::isolate()); | 6737 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6738 v8::RegisterExtension(new Extension("withtest1", kWithExtensionSource1)); | 6738 v8::RegisterExtension(new Extension("withtest1", kWithExtensionSource1)); |
| 6739 v8::RegisterExtension(new Extension("withtest2", kWithExtensionSource2)); | 6739 v8::RegisterExtension(new Extension("withtest2", kWithExtensionSource2)); |
| 6740 const char* extension_names[] = { "withtest1", "withtest2" }; | 6740 const char* extension_names[] = { "withtest1", "withtest2" }; |
| 6741 v8::ExtensionConfiguration extensions(2, extension_names); | 6741 v8::ExtensionConfiguration extensions(2, extension_names); |
| 6742 v8::Handle<Context> context = | 6742 v8::Handle<Context> context = |
| 6743 Context::New(CcTest::isolate(), &extensions); | 6743 Context::New(CcTest::isolate(), &extensions); |
| 6744 Context::Scope lock(context); | 6744 Context::Scope lock(context); |
| 6745 v8::Handle<Value> result = Script::Compile(v8_str("UseWith1()"))->Run(); | 6745 v8::Handle<Value> result = Script::Compile(v8_str("UseWith1()"))->Run(); |
| 6746 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 87)); | 6746 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 87)); |
| 6747 result = Script::Compile(v8_str("UseWith2()"))->Run(); | 6747 result = Script::Compile(v8_str("UseWith2()"))->Run(); |
| 6748 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 87)); | 6748 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 87)); |
| 6749 } | 6749 } |
| 6750 | 6750 |
| 6751 | 6751 |
| 6752 THREADED_TEST(AutoExtensions) { | 6752 TEST(AutoExtensions) { |
| 6753 v8::HandleScope handle_scope(CcTest::isolate()); | 6753 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6754 Extension* extension = new Extension("autotest", kSimpleExtensionSource); | 6754 Extension* extension = new Extension("autotest", kSimpleExtensionSource); |
| 6755 extension->set_auto_enable(true); | 6755 extension->set_auto_enable(true); |
| 6756 v8::RegisterExtension(extension); | 6756 v8::RegisterExtension(extension); |
| 6757 v8::Handle<Context> context = | 6757 v8::Handle<Context> context = |
| 6758 Context::New(CcTest::isolate()); | 6758 Context::New(CcTest::isolate()); |
| 6759 Context::Scope lock(context); | 6759 Context::Scope lock(context); |
| 6760 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); | 6760 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); |
| 6761 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); | 6761 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); |
| 6762 } | 6762 } |
| 6763 | 6763 |
| 6764 | 6764 |
| 6765 static const char* kSyntaxErrorInExtensionSource = | 6765 static const char* kSyntaxErrorInExtensionSource = |
| 6766 "["; | 6766 "["; |
| 6767 | 6767 |
| 6768 | 6768 |
| 6769 // Test that a syntax error in an extension does not cause a fatal | 6769 // Test that a syntax error in an extension does not cause a fatal |
| 6770 // error but results in an empty context. | 6770 // error but results in an empty context. |
| 6771 THREADED_TEST(SyntaxErrorExtensions) { | 6771 TEST(SyntaxErrorExtensions) { |
| 6772 v8::HandleScope handle_scope(CcTest::isolate()); | 6772 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6773 v8::RegisterExtension(new Extension("syntaxerror", | 6773 v8::RegisterExtension(new Extension("syntaxerror", |
| 6774 kSyntaxErrorInExtensionSource)); | 6774 kSyntaxErrorInExtensionSource)); |
| 6775 const char* extension_names[] = { "syntaxerror" }; | 6775 const char* extension_names[] = { "syntaxerror" }; |
| 6776 v8::ExtensionConfiguration extensions(1, extension_names); | 6776 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6777 v8::Handle<Context> context = | 6777 v8::Handle<Context> context = |
| 6778 Context::New(CcTest::isolate(), &extensions); | 6778 Context::New(CcTest::isolate(), &extensions); |
| 6779 CHECK(context.IsEmpty()); | 6779 CHECK(context.IsEmpty()); |
| 6780 } | 6780 } |
| 6781 | 6781 |
| 6782 | 6782 |
| 6783 static const char* kExceptionInExtensionSource = | 6783 static const char* kExceptionInExtensionSource = |
| 6784 "throw 42"; | 6784 "throw 42"; |
| 6785 | 6785 |
| 6786 | 6786 |
| 6787 // Test that an exception when installing an extension does not cause | 6787 // Test that an exception when installing an extension does not cause |
| 6788 // a fatal error but results in an empty context. | 6788 // a fatal error but results in an empty context. |
| 6789 THREADED_TEST(ExceptionExtensions) { | 6789 TEST(ExceptionExtensions) { |
| 6790 v8::HandleScope handle_scope(CcTest::isolate()); | 6790 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6791 v8::RegisterExtension(new Extension("exception", | 6791 v8::RegisterExtension(new Extension("exception", |
| 6792 kExceptionInExtensionSource)); | 6792 kExceptionInExtensionSource)); |
| 6793 const char* extension_names[] = { "exception" }; | 6793 const char* extension_names[] = { "exception" }; |
| 6794 v8::ExtensionConfiguration extensions(1, extension_names); | 6794 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6795 v8::Handle<Context> context = | 6795 v8::Handle<Context> context = |
| 6796 Context::New(CcTest::isolate(), &extensions); | 6796 Context::New(CcTest::isolate(), &extensions); |
| 6797 CHECK(context.IsEmpty()); | 6797 CHECK(context.IsEmpty()); |
| 6798 } | 6798 } |
| 6799 | 6799 |
| 6800 | 6800 |
| 6801 static const char* kNativeCallInExtensionSource = | 6801 static const char* kNativeCallInExtensionSource = |
| 6802 "function call_runtime_last_index_of(x) {" | 6802 "function call_runtime_last_index_of(x) {" |
| 6803 " return %StringLastIndexOf(x, 'bob', 10);" | 6803 " return %StringLastIndexOf(x, 'bob', 10);" |
| 6804 "}"; | 6804 "}"; |
| 6805 | 6805 |
| 6806 | 6806 |
| 6807 static const char* kNativeCallTest = | 6807 static const char* kNativeCallTest = |
| 6808 "call_runtime_last_index_of('bobbobboellebobboellebobbob');"; | 6808 "call_runtime_last_index_of('bobbobboellebobboellebobbob');"; |
| 6809 | 6809 |
| 6810 // Test that a native runtime calls are supported in extensions. | 6810 // Test that a native runtime calls are supported in extensions. |
| 6811 THREADED_TEST(NativeCallInExtensions) { | 6811 TEST(NativeCallInExtensions) { |
| 6812 v8::HandleScope handle_scope(CcTest::isolate()); | 6812 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6813 v8::RegisterExtension(new Extension("nativecall", | 6813 v8::RegisterExtension(new Extension("nativecall", |
| 6814 kNativeCallInExtensionSource)); | 6814 kNativeCallInExtensionSource)); |
| 6815 const char* extension_names[] = { "nativecall" }; | 6815 const char* extension_names[] = { "nativecall" }; |
| 6816 v8::ExtensionConfiguration extensions(1, extension_names); | 6816 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6817 v8::Handle<Context> context = | 6817 v8::Handle<Context> context = |
| 6818 Context::New(CcTest::isolate(), &extensions); | 6818 Context::New(CcTest::isolate(), &extensions); |
| 6819 Context::Scope lock(context); | 6819 Context::Scope lock(context); |
| 6820 v8::Handle<Value> result = Script::Compile(v8_str(kNativeCallTest))->Run(); | 6820 v8::Handle<Value> result = Script::Compile(v8_str(kNativeCallTest))->Run(); |
| 6821 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 3)); | 6821 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 3)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 6837 } | 6837 } |
| 6838 | 6838 |
| 6839 static void Echo(const v8::FunctionCallbackInfo<v8::Value>& args) { | 6839 static void Echo(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 6840 if (args.Length() >= 1) args.GetReturnValue().Set(args[0]); | 6840 if (args.Length() >= 1) args.GetReturnValue().Set(args[0]); |
| 6841 } | 6841 } |
| 6842 private: | 6842 private: |
| 6843 v8::FunctionCallback function_; | 6843 v8::FunctionCallback function_; |
| 6844 }; | 6844 }; |
| 6845 | 6845 |
| 6846 | 6846 |
| 6847 THREADED_TEST(NativeFunctionDeclaration) { | 6847 TEST(NativeFunctionDeclaration) { |
| 6848 v8::HandleScope handle_scope(CcTest::isolate()); | 6848 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6849 const char* name = "nativedecl"; | 6849 const char* name = "nativedecl"; |
| 6850 v8::RegisterExtension(new NativeFunctionExtension(name, | 6850 v8::RegisterExtension(new NativeFunctionExtension(name, |
| 6851 "native function foo();")); | 6851 "native function foo();")); |
| 6852 const char* extension_names[] = { name }; | 6852 const char* extension_names[] = { name }; |
| 6853 v8::ExtensionConfiguration extensions(1, extension_names); | 6853 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6854 v8::Handle<Context> context = | 6854 v8::Handle<Context> context = |
| 6855 Context::New(CcTest::isolate(), &extensions); | 6855 Context::New(CcTest::isolate(), &extensions); |
| 6856 Context::Scope lock(context); | 6856 Context::Scope lock(context); |
| 6857 v8::Handle<Value> result = Script::Compile(v8_str("foo(42);"))->Run(); | 6857 v8::Handle<Value> result = Script::Compile(v8_str("foo(42);"))->Run(); |
| 6858 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 42)); | 6858 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 42)); |
| 6859 } | 6859 } |
| 6860 | 6860 |
| 6861 | 6861 |
| 6862 THREADED_TEST(NativeFunctionDeclarationError) { | 6862 TEST(NativeFunctionDeclarationError) { |
| 6863 v8::HandleScope handle_scope(CcTest::isolate()); | 6863 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6864 const char* name = "nativedeclerr"; | 6864 const char* name = "nativedeclerr"; |
| 6865 // Syntax error in extension code. | 6865 // Syntax error in extension code. |
| 6866 v8::RegisterExtension(new NativeFunctionExtension(name, | 6866 v8::RegisterExtension(new NativeFunctionExtension(name, |
| 6867 "native\nfunction foo();")); | 6867 "native\nfunction foo();")); |
| 6868 const char* extension_names[] = { name }; | 6868 const char* extension_names[] = { name }; |
| 6869 v8::ExtensionConfiguration extensions(1, extension_names); | 6869 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6870 v8::Handle<Context> context = | 6870 v8::Handle<Context> context = |
| 6871 Context::New(CcTest::isolate(), &extensions); | 6871 Context::New(CcTest::isolate(), &extensions); |
| 6872 CHECK(context.IsEmpty()); | 6872 CHECK(context.IsEmpty()); |
| 6873 } | 6873 } |
| 6874 | 6874 |
| 6875 | 6875 |
| 6876 THREADED_TEST(NativeFunctionDeclarationErrorEscape) { | 6876 TEST(NativeFunctionDeclarationErrorEscape) { |
| 6877 v8::HandleScope handle_scope(CcTest::isolate()); | 6877 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6878 const char* name = "nativedeclerresc"; | 6878 const char* name = "nativedeclerresc"; |
| 6879 // Syntax error in extension code - escape code in "native" means that | 6879 // Syntax error in extension code - escape code in "native" means that |
| 6880 // it's not treated as a keyword. | 6880 // it's not treated as a keyword. |
| 6881 v8::RegisterExtension(new NativeFunctionExtension( | 6881 v8::RegisterExtension(new NativeFunctionExtension( |
| 6882 name, | 6882 name, |
| 6883 "nativ\\u0065 function foo();")); | 6883 "nativ\\u0065 function foo();")); |
| 6884 const char* extension_names[] = { name }; | 6884 const char* extension_names[] = { name }; |
| 6885 v8::ExtensionConfiguration extensions(1, extension_names); | 6885 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6886 v8::Handle<Context> context = | 6886 v8::Handle<Context> context = |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7128 ->Set(v8_str("next"), obj); | 7128 ->Set(v8_str("next"), obj); |
| 7129 prev.SetWeak<Value, Snorkel<Value> >(new Snorkel<Value>(&prev.As<Value>()), | 7129 prev.SetWeak<Value, Snorkel<Value> >(new Snorkel<Value>(&prev.As<Value>()), |
| 7130 &HandleWeakReference); | 7130 &HandleWeakReference); |
| 7131 } | 7131 } |
| 7132 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj); | 7132 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj); |
| 7133 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; | 7133 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; |
| 7134 info.GetReturnValue().Set(whammy->getScript()->Run()); | 7134 info.GetReturnValue().Set(whammy->getScript()->Run()); |
| 7135 } | 7135 } |
| 7136 | 7136 |
| 7137 | 7137 |
| 7138 THREADED_TEST(WeakReference) { | 7138 TEST(WeakReference) { |
| 7139 i::FLAG_expose_gc = true; | 7139 i::FLAG_expose_gc = true; |
| 7140 v8::Isolate* isolate = CcTest::isolate(); | 7140 v8::Isolate* isolate = CcTest::isolate(); |
| 7141 v8::HandleScope handle_scope(isolate); | 7141 v8::HandleScope handle_scope(isolate); |
| 7142 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New(isolate); | 7142 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New(isolate); |
| 7143 Whammy* whammy = new Whammy(CcTest::isolate()); | 7143 Whammy* whammy = new Whammy(CcTest::isolate()); |
| 7144 templ->SetNamedPropertyHandler(WhammyPropertyGetter, | 7144 templ->SetNamedPropertyHandler(WhammyPropertyGetter, |
| 7145 0, 0, 0, 0, | 7145 0, 0, 0, 0, |
| 7146 v8::External::New(CcTest::isolate(), whammy)); | 7146 v8::External::New(CcTest::isolate(), whammy)); |
| 7147 const char* extension_list[] = { "v8/gc" }; | 7147 const char* extension_list[] = { "v8/gc" }; |
| 7148 v8::ExtensionConfiguration extensions(1, extension_list); | 7148 v8::ExtensionConfiguration extensions(1, extension_list); |
| (...skipping 14684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21833 context->Global()->Set(v8_str("P"), templ->NewInstance()); | 21833 context->Global()->Set(v8_str("P"), templ->NewInstance()); |
| 21834 CompileRun( | 21834 CompileRun( |
| 21835 "function C1() {" | 21835 "function C1() {" |
| 21836 " this.x = 23;" | 21836 " this.x = 23;" |
| 21837 "};" | 21837 "};" |
| 21838 "C1.prototype = P;" | 21838 "C1.prototype = P;" |
| 21839 "for (var i = 0; i < 4; i++ ) {" | 21839 "for (var i = 0; i < 4; i++ ) {" |
| 21840 " new C1();" | 21840 " new C1();" |
| 21841 "}"); | 21841 "}"); |
| 21842 } | 21842 } |
| OLD | NEW |