| 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 5641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5652 } | 5652 } |
| 5653 | 5653 |
| 5654 | 5654 |
| 5655 TEST(AccessControlES5) { | 5655 TEST(AccessControlES5) { |
| 5656 v8::HandleScope handle_scope; | 5656 v8::HandleScope handle_scope; |
| 5657 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 5657 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 5658 | 5658 |
| 5659 global_template->SetAccessCheckCallbacks(NamedAccessBlocker, | 5659 global_template->SetAccessCheckCallbacks(NamedAccessBlocker, |
| 5660 IndexedAccessBlocker); | 5660 IndexedAccessBlocker); |
| 5661 | 5661 |
| 5662 // Add accessible accessor. |
| 5663 global_template->SetAccessor( |
| 5664 v8_str("accessible_prop"), |
| 5665 EchoGetter, EchoSetter, |
| 5666 v8::Handle<Value>(), |
| 5667 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE)); |
| 5668 |
| 5669 |
| 5662 // Add an accessor that is not accessible by cross-domain JS code. | 5670 // Add an accessor that is not accessible by cross-domain JS code. |
| 5663 global_template->SetAccessor(v8_str("blocked_prop"), | 5671 global_template->SetAccessor(v8_str("blocked_prop"), |
| 5664 UnreachableGetter, UnreachableSetter, | 5672 UnreachableGetter, UnreachableSetter, |
| 5665 v8::Handle<Value>(), | 5673 v8::Handle<Value>(), |
| 5666 v8::DEFAULT); | 5674 v8::DEFAULT); |
| 5667 | 5675 |
| 5668 // Create an environment | 5676 // Create an environment |
| 5669 v8::Persistent<Context> context0 = Context::New(NULL, global_template); | 5677 v8::Persistent<Context> context0 = Context::New(NULL, global_template); |
| 5670 context0->Enter(); | 5678 context0->Enter(); |
| 5671 | 5679 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 5692 ExpectTrue("Object.isExtensible(other)"); | 5700 ExpectTrue("Object.isExtensible(other)"); |
| 5693 CompileRun("Object.preventExtensions(other)"); | 5701 CompileRun("Object.preventExtensions(other)"); |
| 5694 ExpectTrue("Object.isExtensible(other)"); | 5702 ExpectTrue("Object.isExtensible(other)"); |
| 5695 | 5703 |
| 5696 // Object.seal and Object.freeze. | 5704 // Object.seal and Object.freeze. |
| 5697 CompileRun("Object.freeze(other)"); | 5705 CompileRun("Object.freeze(other)"); |
| 5698 ExpectTrue("Object.isExtensible(other)"); | 5706 ExpectTrue("Object.isExtensible(other)"); |
| 5699 | 5707 |
| 5700 CompileRun("Object.seal(other)"); | 5708 CompileRun("Object.seal(other)"); |
| 5701 ExpectTrue("Object.isExtensible(other)"); | 5709 ExpectTrue("Object.isExtensible(other)"); |
| 5710 |
| 5711 // Regression test for issue 1250. |
| 5712 // Make sure that we can set the accessible accessors value using normal |
| 5713 // assignment. |
| 5714 CompileRun("other.accessible_prop = 42"); |
| 5715 CHECK_EQ(42, g_echo_value); |
| 5716 |
| 5717 v8::Handle<Value> value; |
| 5718 // We follow Safari in ignoring assignments to host object accessors. |
| 5719 CompileRun("Object.defineProperty(other, 'accessible_prop', {value: -1})"); |
| 5720 value = CompileRun("other.accessible_prop == 42"); |
| 5721 CHECK(value->IsTrue()); |
| 5702 } | 5722 } |
| 5703 | 5723 |
| 5704 | 5724 |
| 5705 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global, | 5725 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global, |
| 5706 Local<Value> name, | 5726 Local<Value> name, |
| 5707 v8::AccessType type, | 5727 v8::AccessType type, |
| 5708 Local<Value> data) { | 5728 Local<Value> data) { |
| 5709 return false; | 5729 return false; |
| 5710 } | 5730 } |
| 5711 | 5731 |
| (...skipping 7183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12895 explicit InitDefaultIsolateThread(TestCase testCase) | 12915 explicit InitDefaultIsolateThread(TestCase testCase) |
| 12896 : Thread(NULL), | 12916 : Thread(NULL), |
| 12897 testCase_(testCase), | 12917 testCase_(testCase), |
| 12898 result_(false) { } | 12918 result_(false) { } |
| 12899 | 12919 |
| 12900 void Run() { | 12920 void Run() { |
| 12901 switch (testCase_) { | 12921 switch (testCase_) { |
| 12902 case IgnoreOOM: | 12922 case IgnoreOOM: |
| 12903 v8::V8::IgnoreOutOfMemoryException(); | 12923 v8::V8::IgnoreOutOfMemoryException(); |
| 12904 break; | 12924 break; |
| 12905 | 12925 |
| 12906 case SetResourceConstraints: { | 12926 case SetResourceConstraints: { |
| 12907 static const int K = 1024; | 12927 static const int K = 1024; |
| 12908 v8::ResourceConstraints constraints; | 12928 v8::ResourceConstraints constraints; |
| 12909 constraints.set_max_young_space_size(256 * K); | 12929 constraints.set_max_young_space_size(256 * K); |
| 12910 constraints.set_max_old_space_size(4 * K * K); | 12930 constraints.set_max_old_space_size(4 * K * K); |
| 12911 v8::SetResourceConstraints(&constraints); | 12931 v8::SetResourceConstraints(&constraints); |
| 12912 break; | 12932 break; |
| 12913 } | 12933 } |
| 12914 | 12934 |
| 12915 case SetFatalHandler: | 12935 case SetFatalHandler: |
| 12916 v8::V8::SetFatalErrorHandler(NULL); | 12936 v8::V8::SetFatalErrorHandler(NULL); |
| 12917 break; | 12937 break; |
| 12918 | |
| 12919 } | 12938 } |
| 12920 result_ = true; | 12939 result_ = true; |
| 12921 } | 12940 } |
| 12922 | 12941 |
| 12923 bool result() { return result_; } | 12942 bool result() { return result_; } |
| 12924 | 12943 |
| 12925 private: | 12944 private: |
| 12926 TestCase testCase_; | 12945 TestCase testCase_; |
| 12927 bool result_; | 12946 bool result_; |
| 12928 }; | 12947 }; |
| 12929 | 12948 |
| 12930 | 12949 |
| 12931 static void InitializeTestHelper(InitDefaultIsolateThread::TestCase testCase) { | 12950 static void InitializeTestHelper(InitDefaultIsolateThread::TestCase testCase) { |
| 12932 InitDefaultIsolateThread thread(testCase); | 12951 InitDefaultIsolateThread thread(testCase); |
| 12933 thread.Start(); | 12952 thread.Start(); |
| 12934 thread.Join(); | 12953 thread.Join(); |
| 12935 CHECK_EQ(thread.result(), true); | 12954 CHECK_EQ(thread.result(), true); |
| 12936 } | 12955 } |
| 12937 | 12956 |
| 12938 TEST(InitializeDefaultIsolateOnSecondaryThread1) { | 12957 TEST(InitializeDefaultIsolateOnSecondaryThread1) { |
| 12939 InitializeTestHelper(InitDefaultIsolateThread::IgnoreOOM); | 12958 InitializeTestHelper(InitDefaultIsolateThread::IgnoreOOM); |
| 12940 } | 12959 } |
| 12941 | 12960 |
| 12942 TEST(InitializeDefaultIsolateOnSecondaryThread2) { | 12961 TEST(InitializeDefaultIsolateOnSecondaryThread2) { |
| 12943 InitializeTestHelper(InitDefaultIsolateThread::SetResourceConstraints); | 12962 InitializeTestHelper(InitDefaultIsolateThread::SetResourceConstraints); |
| 12944 } | 12963 } |
| 12945 | 12964 |
| 12946 TEST(InitializeDefaultIsolateOnSecondaryThread3) { | 12965 TEST(InitializeDefaultIsolateOnSecondaryThread3) { |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13274 v8::Handle<v8::Function> define_property = | 13293 v8::Handle<v8::Function> define_property = |
| 13275 CompileRun("(function() {" | 13294 CompileRun("(function() {" |
| 13276 " Object.defineProperty(" | 13295 " Object.defineProperty(" |
| 13277 " this," | 13296 " this," |
| 13278 " 1," | 13297 " 1," |
| 13279 " { configurable: true, enumerable: true, value: 3 });" | 13298 " { configurable: true, enumerable: true, value: 3 });" |
| 13280 "})").As<Function>(); | 13299 "})").As<Function>(); |
| 13281 context->DetachGlobal(); | 13300 context->DetachGlobal(); |
| 13282 define_property->Call(proxy, 0, NULL); | 13301 define_property->Call(proxy, 0, NULL); |
| 13283 } | 13302 } |
| OLD | NEW |