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 7841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7852 "}"); | 7852 "}"); |
7853 CHECK(try_catch.HasCaught()); | 7853 CHECK(try_catch.HasCaught()); |
7854 CHECK(!try_catch.Message().IsEmpty()); | 7854 CHECK(!try_catch.Message().IsEmpty()); |
7855 String::Utf8Value finally_exception_value(try_catch.Exception()); | 7855 String::Utf8Value finally_exception_value(try_catch.Exception()); |
7856 CHECK_EQ(0, strcmp(*finally_exception_value, "2")); | 7856 CHECK_EQ(0, strcmp(*finally_exception_value, "2")); |
7857 } | 7857 } |
7858 | 7858 |
7859 | 7859 |
7860 // For use within the TestSecurityHandler() test. | 7860 // For use within the TestSecurityHandler() test. |
7861 static bool g_security_callback_result = false; | 7861 static bool g_security_callback_result = false; |
7862 static bool SecurityTestCallback(Local<v8::Object> global, Local<Value> name, | 7862 static bool SecurityTestCallback(Local<v8::Context> accessing_context, |
7863 v8::AccessType type, Local<Value> data) { | 7863 Local<v8::Object> accessed_object) { |
7864 printf("a\n"); | 7864 printf("a\n"); |
7865 return g_security_callback_result; | 7865 return g_security_callback_result; |
7866 } | 7866 } |
7867 | 7867 |
7868 | 7868 |
7869 // SecurityHandler can't be run twice | 7869 // SecurityHandler can't be run twice |
7870 TEST(SecurityHandler) { | 7870 TEST(SecurityHandler) { |
7871 v8::Isolate* isolate = CcTest::isolate(); | 7871 v8::Isolate* isolate = CcTest::isolate(); |
7872 v8::HandleScope scope0(isolate); | 7872 v8::HandleScope scope0(isolate); |
7873 v8::Handle<v8::ObjectTemplate> global_template = | 7873 v8::Handle<v8::ObjectTemplate> global_template = |
7874 v8::ObjectTemplate::New(isolate); | 7874 v8::ObjectTemplate::New(isolate); |
7875 global_template->SetAccessCheckCallbacks(SecurityTestCallback, NULL); | 7875 global_template->SetAccessCheckCallback(SecurityTestCallback); |
7876 // Create an environment | 7876 // Create an environment |
7877 v8::Handle<Context> context0 = Context::New(isolate, NULL, global_template); | 7877 v8::Handle<Context> context0 = Context::New(isolate, NULL, global_template); |
7878 context0->Enter(); | 7878 context0->Enter(); |
7879 | 7879 |
7880 v8::Handle<v8::Object> global0 = context0->Global(); | 7880 v8::Handle<v8::Object> global0 = context0->Global(); |
7881 v8::Handle<Script> script0 = v8_compile("foo = 111"); | 7881 v8::Handle<Script> script0 = v8_compile("foo = 111"); |
7882 script0->Run(); | 7882 script0->Run(); |
7883 global0->Set(v8_str("0"), v8_num(999)); | 7883 global0->Set(v8_str("0"), v8_num(999)); |
7884 v8::Handle<Value> foo0 = global0->Get(v8_str("foo")); | 7884 v8::Handle<Value> foo0 = global0->Get(v8_str("foo")); |
7885 CHECK_EQ(111, foo0->Int32Value()); | 7885 CHECK_EQ(111, foo0->Int32Value()); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8026 Local<Script> access_f3 = v8_compile("f[99]"); | 8026 Local<Script> access_f3 = v8_compile("f[99]"); |
8027 for (int k = 0; k < 5; k++) { | 8027 for (int k = 0; k < 5; k++) { |
8028 CHECK(access_f2->Run().IsEmpty()); | 8028 CHECK(access_f2->Run().IsEmpty()); |
8029 CHECK(access_f3->Run().IsEmpty()); | 8029 CHECK(access_f3->Run().IsEmpty()); |
8030 } | 8030 } |
8031 } | 8031 } |
8032 | 8032 |
8033 | 8033 |
8034 static bool security_check_with_gc_called; | 8034 static bool security_check_with_gc_called; |
8035 | 8035 |
8036 static bool SecurityTestCallbackWithGC(Local<v8::Object> global, | 8036 static bool SecurityTestCallbackWithGC(Local<v8::Context> accessing_context, |
8037 Local<v8::Value> name, | 8037 Local<v8::Object> accessed_object) { |
8038 v8::AccessType type, Local<Value> data) { | |
8039 CcTest::heap()->CollectAllGarbage(); | 8038 CcTest::heap()->CollectAllGarbage(); |
8040 security_check_with_gc_called = true; | 8039 security_check_with_gc_called = true; |
8041 return true; | 8040 return true; |
8042 } | 8041 } |
8043 | 8042 |
8044 | 8043 |
8045 TEST(SecurityTestGCAllowed) { | 8044 TEST(SecurityTestGCAllowed) { |
8046 v8::Isolate* isolate = CcTest::isolate(); | 8045 v8::Isolate* isolate = CcTest::isolate(); |
8047 v8::HandleScope handle_scope(isolate); | 8046 v8::HandleScope handle_scope(isolate); |
8048 v8::Handle<v8::ObjectTemplate> object_template = | 8047 v8::Handle<v8::ObjectTemplate> object_template = |
8049 v8::ObjectTemplate::New(isolate); | 8048 v8::ObjectTemplate::New(isolate); |
8050 object_template->SetAccessCheckCallbacks(SecurityTestCallbackWithGC, NULL); | 8049 object_template->SetAccessCheckCallback(SecurityTestCallbackWithGC); |
8051 | 8050 |
8052 v8::Handle<Context> context = Context::New(isolate); | 8051 v8::Handle<Context> context = Context::New(isolate); |
8053 v8::Context::Scope context_scope(context); | 8052 v8::Context::Scope context_scope(context); |
8054 | 8053 |
8055 context->Global()->Set(v8_str("obj"), object_template->NewInstance()); | 8054 context->Global()->Set(v8_str("obj"), object_template->NewInstance()); |
8056 | 8055 |
8057 security_check_with_gc_called = false; | 8056 security_check_with_gc_called = false; |
8058 CompileRun("obj[0] = new String(1002);"); | 8057 CompileRun("obj[0] = new String(1002);"); |
8059 CHECK(security_check_with_gc_called); | 8058 CHECK(security_check_with_gc_called); |
8060 | 8059 |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8449 for (int i = 0; i < 16; i += 4) { | 8448 for (int i = 0; i < 16; i += 4) { |
8450 CHECK(v8_str("env2_x")->Equals(results->Get(i + 0))); | 8449 CHECK(v8_str("env2_x")->Equals(results->Get(i + 0))); |
8451 CHECK(v8_str("env1_x")->Equals(results->Get(i + 1))); | 8450 CHECK(v8_str("env1_x")->Equals(results->Get(i + 1))); |
8452 CHECK(v8_str("env3_x")->Equals(results->Get(i + 2))); | 8451 CHECK(v8_str("env3_x")->Equals(results->Get(i + 2))); |
8453 CHECK(v8_str("env2_x")->Equals(results->Get(i + 3))); | 8452 CHECK(v8_str("env2_x")->Equals(results->Get(i + 3))); |
8454 } | 8453 } |
8455 } | 8454 } |
8456 | 8455 |
8457 | 8456 |
8458 static bool allowed_access = false; | 8457 static bool allowed_access = false; |
8459 static bool AccessBlocker(Local<v8::Object> global, Local<Value> name, | 8458 static bool AccessBlocker(Local<v8::Context> accessing_context, |
8460 v8::AccessType type, Local<Value> data) { | 8459 Local<v8::Object> accessed_object) { |
8461 return CcTest::isolate()->GetCurrentContext()->Global()->Equals(global) || | 8460 return CcTest::isolate()->GetCurrentContext()->Global()->Equals( |
| 8461 accessed_object) || |
8462 allowed_access; | 8462 allowed_access; |
8463 } | 8463 } |
8464 | 8464 |
8465 | 8465 |
8466 static int g_echo_value = -1; | 8466 static int g_echo_value = -1; |
8467 | 8467 |
8468 | 8468 |
8469 static void EchoGetter( | 8469 static void EchoGetter( |
8470 Local<String> name, | 8470 Local<String> name, |
8471 const v8::PropertyCallbackInfo<v8::Value>& info) { | 8471 const v8::PropertyCallbackInfo<v8::Value>& info) { |
(...skipping 28 matching lines...) Expand all Loading... |
8500 CHECK(false); // This function should not be called.. | 8500 CHECK(false); // This function should not be called.. |
8501 } | 8501 } |
8502 | 8502 |
8503 | 8503 |
8504 TEST(AccessControl) { | 8504 TEST(AccessControl) { |
8505 v8::Isolate* isolate = CcTest::isolate(); | 8505 v8::Isolate* isolate = CcTest::isolate(); |
8506 v8::HandleScope handle_scope(isolate); | 8506 v8::HandleScope handle_scope(isolate); |
8507 v8::Handle<v8::ObjectTemplate> global_template = | 8507 v8::Handle<v8::ObjectTemplate> global_template = |
8508 v8::ObjectTemplate::New(isolate); | 8508 v8::ObjectTemplate::New(isolate); |
8509 | 8509 |
8510 global_template->SetAccessCheckCallbacks(AccessBlocker, NULL); | 8510 global_template->SetAccessCheckCallback(AccessBlocker); |
8511 | 8511 |
8512 // Add an accessor accessible by cross-domain JS code. | 8512 // Add an accessor accessible by cross-domain JS code. |
8513 global_template->SetAccessor( | 8513 global_template->SetAccessor( |
8514 v8_str("accessible_prop"), | 8514 v8_str("accessible_prop"), |
8515 EchoGetter, EchoSetter, | 8515 EchoGetter, EchoSetter, |
8516 v8::Handle<Value>(), | 8516 v8::Handle<Value>(), |
8517 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE)); | 8517 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE)); |
8518 | 8518 |
8519 | 8519 |
8520 // Add an accessor that is not accessible by cross-domain JS code. | 8520 // Add an accessor that is not accessible by cross-domain JS code. |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8664 context0->Exit(); | 8664 context0->Exit(); |
8665 } | 8665 } |
8666 | 8666 |
8667 | 8667 |
8668 TEST(AccessControlES5) { | 8668 TEST(AccessControlES5) { |
8669 v8::Isolate* isolate = CcTest::isolate(); | 8669 v8::Isolate* isolate = CcTest::isolate(); |
8670 v8::HandleScope handle_scope(isolate); | 8670 v8::HandleScope handle_scope(isolate); |
8671 v8::Handle<v8::ObjectTemplate> global_template = | 8671 v8::Handle<v8::ObjectTemplate> global_template = |
8672 v8::ObjectTemplate::New(isolate); | 8672 v8::ObjectTemplate::New(isolate); |
8673 | 8673 |
8674 global_template->SetAccessCheckCallbacks(AccessBlocker, NULL); | 8674 global_template->SetAccessCheckCallback(AccessBlocker); |
8675 | 8675 |
8676 // Add accessible accessor. | 8676 // Add accessible accessor. |
8677 global_template->SetAccessor( | 8677 global_template->SetAccessor( |
8678 v8_str("accessible_prop"), | 8678 v8_str("accessible_prop"), |
8679 EchoGetter, EchoSetter, | 8679 EchoGetter, EchoSetter, |
8680 v8::Handle<Value>(), | 8680 v8::Handle<Value>(), |
8681 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE)); | 8681 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE)); |
8682 | 8682 |
8683 | 8683 |
8684 // Add an accessor that is not accessible by cross-domain JS code. | 8684 // Add an accessor that is not accessible by cross-domain JS code. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8729 | 8729 |
8730 // [[DefineOwnProperty]] always throws for access-checked objects. | 8730 // [[DefineOwnProperty]] always throws for access-checked objects. |
8731 CHECK( | 8731 CHECK( |
8732 CompileRun("Object.defineProperty(other, 'accessible_prop', {value: 43})") | 8732 CompileRun("Object.defineProperty(other, 'accessible_prop', {value: 43})") |
8733 .IsEmpty()); | 8733 .IsEmpty()); |
8734 CHECK(CompileRun("other.accessible_prop == 42")->IsTrue()); | 8734 CHECK(CompileRun("other.accessible_prop == 42")->IsTrue()); |
8735 CHECK_EQ(42, g_echo_value); // Make sure we didn't call the setter. | 8735 CHECK_EQ(42, g_echo_value); // Make sure we didn't call the setter. |
8736 } | 8736 } |
8737 | 8737 |
8738 | 8738 |
8739 static bool AccessAlwaysBlocked(Local<v8::Object> global, Local<Value> name, | 8739 static bool AccessAlwaysBlocked(Local<v8::Context> accessing_context, |
8740 v8::AccessType type, Local<Value> data) { | 8740 Local<v8::Object> global) { |
8741 i::PrintF("Access blocked.\n"); | 8741 i::PrintF("Access blocked.\n"); |
8742 return false; | 8742 return false; |
8743 } | 8743 } |
8744 | 8744 |
8745 | 8745 |
8746 THREADED_TEST(AccessControlGetOwnPropertyNames) { | 8746 THREADED_TEST(AccessControlGetOwnPropertyNames) { |
8747 v8::Isolate* isolate = CcTest::isolate(); | 8747 v8::Isolate* isolate = CcTest::isolate(); |
8748 v8::HandleScope handle_scope(isolate); | 8748 v8::HandleScope handle_scope(isolate); |
8749 v8::Handle<v8::ObjectTemplate> obj_template = | 8749 v8::Handle<v8::ObjectTemplate> obj_template = |
8750 v8::ObjectTemplate::New(isolate); | 8750 v8::ObjectTemplate::New(isolate); |
8751 | 8751 |
8752 obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42)); | 8752 obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42)); |
8753 obj_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL); | 8753 obj_template->SetAccessCheckCallback(AccessAlwaysBlocked); |
8754 | 8754 |
8755 // Add an accessor accessible by cross-domain JS code. | 8755 // Add an accessor accessible by cross-domain JS code. |
8756 obj_template->SetAccessor( | 8756 obj_template->SetAccessor( |
8757 v8_str("accessible_prop"), EchoGetter, EchoSetter, v8::Handle<Value>(), | 8757 v8_str("accessible_prop"), EchoGetter, EchoSetter, v8::Handle<Value>(), |
8758 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE)); | 8758 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE)); |
8759 | 8759 |
8760 // Create an environment | 8760 // Create an environment |
8761 v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template); | 8761 v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template); |
8762 context0->Enter(); | 8762 context0->Enter(); |
8763 | 8763 |
(...skipping 28 matching lines...) Expand all Loading... |
8792 context1->Exit(); | 8792 context1->Exit(); |
8793 context0->Exit(); | 8793 context0->Exit(); |
8794 } | 8794 } |
8795 | 8795 |
8796 | 8796 |
8797 TEST(Regress470113) { | 8797 TEST(Regress470113) { |
8798 v8::Isolate* isolate = CcTest::isolate(); | 8798 v8::Isolate* isolate = CcTest::isolate(); |
8799 v8::HandleScope handle_scope(isolate); | 8799 v8::HandleScope handle_scope(isolate); |
8800 v8::Handle<v8::ObjectTemplate> obj_template = | 8800 v8::Handle<v8::ObjectTemplate> obj_template = |
8801 v8::ObjectTemplate::New(isolate); | 8801 v8::ObjectTemplate::New(isolate); |
8802 obj_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL); | 8802 obj_template->SetAccessCheckCallback(AccessAlwaysBlocked); |
8803 LocalContext env; | 8803 LocalContext env; |
8804 env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance()); | 8804 env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance()); |
8805 | 8805 |
8806 { | 8806 { |
8807 v8::TryCatch try_catch(isolate); | 8807 v8::TryCatch try_catch(isolate); |
8808 CompileRun( | 8808 CompileRun( |
8809 "'use strict';\n" | 8809 "'use strict';\n" |
8810 "class C extends Object {\n" | 8810 "class C extends Object {\n" |
8811 " m() { super.powned = 'Powned!'; }\n" | 8811 " m() { super.powned = 'Powned!'; }\n" |
8812 "}\n" | 8812 "}\n" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8872 value = v8_compile("other.unreachable")->Run(); | 8872 value = v8_compile("other.unreachable")->Run(); |
8873 CHECK(value.IsEmpty()); | 8873 CHECK(value.IsEmpty()); |
8874 | 8874 |
8875 context1->Exit(); | 8875 context1->Exit(); |
8876 context0->Exit(); | 8876 context0->Exit(); |
8877 } | 8877 } |
8878 | 8878 |
8879 | 8879 |
8880 static int access_count = 0; | 8880 static int access_count = 0; |
8881 | 8881 |
8882 static bool AccessCounter(Local<v8::Object> global, Local<Value> name, | 8882 static bool AccessCounter(Local<v8::Context> accessing_context, |
8883 v8::AccessType type, Local<Value> data) { | 8883 Local<v8::Object> accessed_object) { |
8884 access_count++; | 8884 access_count++; |
8885 return true; | 8885 return true; |
8886 } | 8886 } |
8887 | 8887 |
8888 | 8888 |
8889 // This one is too easily disturbed by other tests. | 8889 // This one is too easily disturbed by other tests. |
8890 TEST(AccessControlIC) { | 8890 TEST(AccessControlIC) { |
8891 access_count = 0; | 8891 access_count = 0; |
8892 | 8892 |
8893 v8::Isolate* isolate = CcTest::isolate(); | 8893 v8::Isolate* isolate = CcTest::isolate(); |
8894 v8::HandleScope handle_scope(isolate); | 8894 v8::HandleScope handle_scope(isolate); |
8895 | 8895 |
8896 // Create an environment. | 8896 // Create an environment. |
8897 v8::Local<Context> context0 = Context::New(isolate); | 8897 v8::Local<Context> context0 = Context::New(isolate); |
8898 context0->Enter(); | 8898 context0->Enter(); |
8899 | 8899 |
8900 // Create an object that requires access-check functions to be | 8900 // Create an object that requires access-check functions to be |
8901 // called for cross-domain access. | 8901 // called for cross-domain access. |
8902 v8::Handle<v8::ObjectTemplate> object_template = | 8902 v8::Handle<v8::ObjectTemplate> object_template = |
8903 v8::ObjectTemplate::New(isolate); | 8903 v8::ObjectTemplate::New(isolate); |
8904 object_template->SetAccessCheckCallbacks(AccessCounter, NULL); | 8904 object_template->SetAccessCheckCallback(AccessCounter); |
8905 Local<v8::Object> object = object_template->NewInstance(); | 8905 Local<v8::Object> object = object_template->NewInstance(); |
8906 | 8906 |
8907 v8::HandleScope scope1(isolate); | 8907 v8::HandleScope scope1(isolate); |
8908 | 8908 |
8909 // Create another environment. | 8909 // Create another environment. |
8910 v8::Local<Context> context1 = Context::New(isolate); | 8910 v8::Local<Context> context1 = Context::New(isolate); |
8911 context1->Enter(); | 8911 context1->Enter(); |
8912 | 8912 |
8913 // Make easy access to the object from the other environment. | 8913 // Make easy access to the object from the other environment. |
8914 v8::Handle<v8::Object> global1 = context1->Global(); | 8914 v8::Handle<v8::Object> global1 = context1->Global(); |
(...skipping 3875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12790 printf("p[%u]\n", i); | 12790 printf("p[%u]\n", i); |
12791 } | 12791 } |
12792 } | 12792 } |
12793 | 12793 |
12794 | 12794 |
12795 THREADED_TEST(AccessChecksReenabledCorrectly) { | 12795 THREADED_TEST(AccessChecksReenabledCorrectly) { |
12796 LocalContext context; | 12796 LocalContext context; |
12797 v8::Isolate* isolate = context->GetIsolate(); | 12797 v8::Isolate* isolate = context->GetIsolate(); |
12798 v8::HandleScope scope(isolate); | 12798 v8::HandleScope scope(isolate); |
12799 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 12799 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
12800 templ->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL); | 12800 templ->SetAccessCheckCallback(AccessAlwaysBlocked); |
12801 templ->Set(v8_str("a"), v8_str("a")); | 12801 templ->Set(v8_str("a"), v8_str("a")); |
12802 // Add more than 8 (see kMaxFastProperties) properties | 12802 // Add more than 8 (see kMaxFastProperties) properties |
12803 // so that the constructor will force copying map. | 12803 // so that the constructor will force copying map. |
12804 // Cannot sprintf, gcc complains unsafety. | 12804 // Cannot sprintf, gcc complains unsafety. |
12805 char buf[4]; | 12805 char buf[4]; |
12806 for (char i = '0'; i <= '9' ; i++) { | 12806 for (char i = '0'; i <= '9' ; i++) { |
12807 buf[0] = i; | 12807 buf[0] = i; |
12808 for (char j = '0'; j <= '9'; j++) { | 12808 for (char j = '0'; j <= '9'; j++) { |
12809 buf[1] = j; | 12809 buf[1] = j; |
12810 for (char k = '0'; k <= '9'; k++) { | 12810 for (char k = '0'; k <= '9'; k++) { |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13411 CompileRun("Object.freeze(a);"); | 13411 CompileRun("Object.freeze(a);"); |
13412 { | 13412 { |
13413 // Can't change non-extensible objects. | 13413 // Can't change non-extensible objects. |
13414 v8::TryCatch try_catch(isolate); | 13414 v8::TryCatch try_catch(isolate); |
13415 CHECK(!obj->CreateDataProperty(env.local(), v8_str("baz"), | 13415 CHECK(!obj->CreateDataProperty(env.local(), v8_str("baz"), |
13416 v8::Integer::New(isolate, 42)).FromJust()); | 13416 v8::Integer::New(isolate, 42)).FromJust()); |
13417 CHECK(!try_catch.HasCaught()); | 13417 CHECK(!try_catch.HasCaught()); |
13418 } | 13418 } |
13419 | 13419 |
13420 v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); | 13420 v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); |
13421 templ->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL); | 13421 templ->SetAccessCheckCallback(AccessAlwaysBlocked); |
13422 v8::Local<v8::Object> access_checked = | 13422 v8::Local<v8::Object> access_checked = |
13423 templ->NewInstance(env.local()).ToLocalChecked(); | 13423 templ->NewInstance(env.local()).ToLocalChecked(); |
13424 { | 13424 { |
13425 v8::TryCatch try_catch(isolate); | 13425 v8::TryCatch try_catch(isolate); |
13426 CHECK(access_checked->CreateDataProperty(env.local(), v8_str("foo"), | 13426 CHECK(access_checked->CreateDataProperty(env.local(), v8_str("foo"), |
13427 v8::Integer::New(isolate, 42)) | 13427 v8::Integer::New(isolate, 42)) |
13428 .IsNothing()); | 13428 .IsNothing()); |
13429 CHECK(try_catch.HasCaught()); | 13429 CHECK(try_catch.HasCaught()); |
13430 } | 13430 } |
13431 } | 13431 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13530 CompileRun("Object.freeze(a);"); | 13530 CompileRun("Object.freeze(a);"); |
13531 { | 13531 { |
13532 // Can't change non-extensible objects. | 13532 // Can't change non-extensible objects. |
13533 v8::TryCatch try_catch(isolate); | 13533 v8::TryCatch try_catch(isolate); |
13534 CHECK(!obj->DefineOwnProperty(env.local(), v8_str("baz"), | 13534 CHECK(!obj->DefineOwnProperty(env.local(), v8_str("baz"), |
13535 v8::Integer::New(isolate, 42)).FromJust()); | 13535 v8::Integer::New(isolate, 42)).FromJust()); |
13536 CHECK(!try_catch.HasCaught()); | 13536 CHECK(!try_catch.HasCaught()); |
13537 } | 13537 } |
13538 | 13538 |
13539 v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); | 13539 v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); |
13540 templ->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL); | 13540 templ->SetAccessCheckCallback(AccessAlwaysBlocked); |
13541 v8::Local<v8::Object> access_checked = | 13541 v8::Local<v8::Object> access_checked = |
13542 templ->NewInstance(env.local()).ToLocalChecked(); | 13542 templ->NewInstance(env.local()).ToLocalChecked(); |
13543 { | 13543 { |
13544 v8::TryCatch try_catch(isolate); | 13544 v8::TryCatch try_catch(isolate); |
13545 CHECK(access_checked->DefineOwnProperty(env.local(), v8_str("foo"), | 13545 CHECK(access_checked->DefineOwnProperty(env.local(), v8_str("foo"), |
13546 v8::Integer::New(isolate, 42)) | 13546 v8::Integer::New(isolate, 42)) |
13547 .IsNothing()); | 13547 .IsNothing()); |
13548 CHECK(try_catch.HasCaught()); | 13548 CHECK(try_catch.HasCaught()); |
13549 } | 13549 } |
13550 } | 13550 } |
(...skipping 3163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16714 v8::V8::Initialize(); | 16714 v8::V8::Initialize(); |
16715 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC); | 16715 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC); |
16716 | 16716 |
16717 v8::Isolate* isolate = CcTest::isolate(); | 16717 v8::Isolate* isolate = CcTest::isolate(); |
16718 v8::HandleScope scope(isolate); | 16718 v8::HandleScope scope(isolate); |
16719 | 16719 |
16720 // Create an ObjectTemplate for global objects and install access | 16720 // Create an ObjectTemplate for global objects and install access |
16721 // check callbacks that will block access. | 16721 // check callbacks that will block access. |
16722 v8::Handle<v8::ObjectTemplate> global_template = | 16722 v8::Handle<v8::ObjectTemplate> global_template = |
16723 v8::ObjectTemplate::New(isolate); | 16723 v8::ObjectTemplate::New(isolate); |
16724 global_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL, | 16724 global_template->SetAccessCheckCallback(AccessAlwaysBlocked); |
16725 v8::Handle<v8::Value>()); | |
16726 | 16725 |
16727 // Create a context and set an x property on it's global object. | 16726 // Create a context and set an x property on it's global object. |
16728 LocalContext context0(NULL, global_template); | 16727 LocalContext context0(NULL, global_template); |
16729 context0->Global()->Set(v8_str("x"), v8_num(42)); | 16728 context0->Global()->Set(v8_str("x"), v8_num(42)); |
16730 v8::Handle<v8::Object> global0 = context0->Global(); | 16729 v8::Handle<v8::Object> global0 = context0->Global(); |
16731 | 16730 |
16732 // Create a context with a different security token so that the | 16731 // Create a context with a different security token so that the |
16733 // failed access check callback will be called on each access. | 16732 // failed access check callback will be called on each access. |
16734 LocalContext context1(NULL, global_template); | 16733 LocalContext context1(NULL, global_template); |
16735 context1->Global()->Set(v8_str("other"), global0); | 16734 context1->Global()->Set(v8_str("other"), global0); |
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17948 CHECK_GT(elements, CountLiveMapsInMapCache(CcTest::i_isolate()->context())); | 17947 CHECK_GT(elements, CountLiveMapsInMapCache(CcTest::i_isolate()->context())); |
17949 } | 17948 } |
17950 | 17949 |
17951 | 17950 |
17952 THREADED_TEST(Regress93759) { | 17951 THREADED_TEST(Regress93759) { |
17953 v8::Isolate* isolate = CcTest::isolate(); | 17952 v8::Isolate* isolate = CcTest::isolate(); |
17954 HandleScope scope(isolate); | 17953 HandleScope scope(isolate); |
17955 | 17954 |
17956 // Template for object with security check. | 17955 // Template for object with security check. |
17957 Local<ObjectTemplate> no_proto_template = v8::ObjectTemplate::New(isolate); | 17956 Local<ObjectTemplate> no_proto_template = v8::ObjectTemplate::New(isolate); |
17958 no_proto_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL); | 17957 no_proto_template->SetAccessCheckCallback(AccessAlwaysBlocked); |
17959 | 17958 |
17960 // Templates for objects with hidden prototypes and possibly security check. | 17959 // Templates for objects with hidden prototypes and possibly security check. |
17961 Local<FunctionTemplate> hidden_proto_template = | 17960 Local<FunctionTemplate> hidden_proto_template = |
17962 v8::FunctionTemplate::New(isolate); | 17961 v8::FunctionTemplate::New(isolate); |
17963 hidden_proto_template->SetHiddenPrototype(true); | 17962 hidden_proto_template->SetHiddenPrototype(true); |
17964 | 17963 |
17965 Local<FunctionTemplate> protected_hidden_proto_template = | 17964 Local<FunctionTemplate> protected_hidden_proto_template = |
17966 v8::FunctionTemplate::New(isolate); | 17965 v8::FunctionTemplate::New(isolate); |
17967 protected_hidden_proto_template->InstanceTemplate()->SetAccessCheckCallbacks( | 17966 protected_hidden_proto_template->InstanceTemplate()->SetAccessCheckCallback( |
17968 AccessAlwaysBlocked, NULL); | 17967 AccessAlwaysBlocked); |
17969 protected_hidden_proto_template->SetHiddenPrototype(true); | 17968 protected_hidden_proto_template->SetHiddenPrototype(true); |
17970 | 17969 |
17971 // Context for "foreign" objects used in test. | 17970 // Context for "foreign" objects used in test. |
17972 Local<Context> context = v8::Context::New(isolate); | 17971 Local<Context> context = v8::Context::New(isolate); |
17973 context->Enter(); | 17972 context->Enter(); |
17974 | 17973 |
17975 // Plain object, no security check. | 17974 // Plain object, no security check. |
17976 Local<Object> simple_object = Object::New(isolate); | 17975 Local<Object> simple_object = Object::New(isolate); |
17977 | 17976 |
17978 // Object with explicit security check. | 17977 // Object with explicit security check. |
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19126 | 19125 |
19127 TEST(JSONStringifyAccessCheck) { | 19126 TEST(JSONStringifyAccessCheck) { |
19128 v8::V8::Initialize(); | 19127 v8::V8::Initialize(); |
19129 v8::Isolate* isolate = CcTest::isolate(); | 19128 v8::Isolate* isolate = CcTest::isolate(); |
19130 v8::HandleScope scope(isolate); | 19129 v8::HandleScope scope(isolate); |
19131 | 19130 |
19132 // Create an ObjectTemplate for global objects and install access | 19131 // Create an ObjectTemplate for global objects and install access |
19133 // check callbacks that will block access. | 19132 // check callbacks that will block access. |
19134 v8::Handle<v8::ObjectTemplate> global_template = | 19133 v8::Handle<v8::ObjectTemplate> global_template = |
19135 v8::ObjectTemplate::New(isolate); | 19134 v8::ObjectTemplate::New(isolate); |
19136 global_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL); | 19135 global_template->SetAccessCheckCallback(AccessAlwaysBlocked); |
19137 | 19136 |
19138 // Create a context and set an x property on it's global object. | 19137 // Create a context and set an x property on it's global object. |
19139 LocalContext context0(NULL, global_template); | 19138 LocalContext context0(NULL, global_template); |
19140 v8::Handle<v8::Object> global0 = context0->Global(); | 19139 v8::Handle<v8::Object> global0 = context0->Global(); |
19141 global0->Set(v8_str("x"), v8_num(42)); | 19140 global0->Set(v8_str("x"), v8_num(42)); |
19142 ExpectString("JSON.stringify(this)", "{\"x\":42}"); | 19141 ExpectString("JSON.stringify(this)", "{\"x\":42}"); |
19143 | 19142 |
19144 for (int i = 0; i < 2; i++) { | 19143 for (int i = 0; i < 2; i++) { |
19145 if (i == 1) { | 19144 if (i == 1) { |
19146 // Install a toJSON function on the second run. | 19145 // Install a toJSON function on the second run. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19214 i::FLAG_allow_natives_syntax = true; | 19213 i::FLAG_allow_natives_syntax = true; |
19215 v8::V8::Initialize(); | 19214 v8::V8::Initialize(); |
19216 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckThrows); | 19215 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckThrows); |
19217 v8::Isolate* isolate = CcTest::isolate(); | 19216 v8::Isolate* isolate = CcTest::isolate(); |
19218 v8::HandleScope scope(isolate); | 19217 v8::HandleScope scope(isolate); |
19219 | 19218 |
19220 // Create an ObjectTemplate for global objects and install access | 19219 // Create an ObjectTemplate for global objects and install access |
19221 // check callbacks that will block access. | 19220 // check callbacks that will block access. |
19222 v8::Handle<v8::ObjectTemplate> global_template = | 19221 v8::Handle<v8::ObjectTemplate> global_template = |
19223 v8::ObjectTemplate::New(isolate); | 19222 v8::ObjectTemplate::New(isolate); |
19224 global_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL); | 19223 global_template->SetAccessCheckCallback(AccessAlwaysBlocked); |
19225 | 19224 |
19226 // Create a context and set an x property on it's global object. | 19225 // Create a context and set an x property on it's global object. |
19227 LocalContext context0(NULL, global_template); | 19226 LocalContext context0(NULL, global_template); |
19228 v8::Handle<v8::Object> global0 = context0->Global(); | 19227 v8::Handle<v8::Object> global0 = context0->Global(); |
19229 | 19228 |
19230 // Create a context with a different security token so that the | 19229 // Create a context with a different security token so that the |
19231 // failed access check callback will be called on each access. | 19230 // failed access check callback will be called on each access. |
19232 LocalContext context1(NULL, global_template); | 19231 LocalContext context1(NULL, global_template); |
19233 context1->Global()->Set(v8_str("other"), global0); | 19232 context1->Global()->Set(v8_str("other"), global0); |
19234 | 19233 |
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20289 CHECK(try_catch.HasCaught()); | 20288 CHECK(try_catch.HasCaught()); |
20290 } | 20289 } |
20291 | 20290 |
20292 | 20291 |
20293 TEST(Regress354123) { | 20292 TEST(Regress354123) { |
20294 LocalContext current; | 20293 LocalContext current; |
20295 v8::Isolate* isolate = current->GetIsolate(); | 20294 v8::Isolate* isolate = current->GetIsolate(); |
20296 v8::HandleScope scope(isolate); | 20295 v8::HandleScope scope(isolate); |
20297 | 20296 |
20298 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); | 20297 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); |
20299 templ->SetAccessCheckCallbacks(AccessCounter, NULL); | 20298 templ->SetAccessCheckCallback(AccessCounter); |
20300 current->Global()->Set(v8_str("friend"), templ->NewInstance()); | 20299 current->Global()->Set(v8_str("friend"), templ->NewInstance()); |
20301 | 20300 |
20302 // Test access using __proto__ from the prototype chain. | 20301 // Test access using __proto__ from the prototype chain. |
20303 access_count = 0; | 20302 access_count = 0; |
20304 CompileRun("friend.__proto__ = {};"); | 20303 CompileRun("friend.__proto__ = {};"); |
20305 CHECK_EQ(2, access_count); | 20304 CHECK_EQ(2, access_count); |
20306 CompileRun("friend.__proto__;"); | 20305 CompileRun("friend.__proto__;"); |
20307 CHECK_EQ(4, access_count); | 20306 CHECK_EQ(4, access_count); |
20308 | 20307 |
20309 // Test access using __proto__ as a hijacked function (A). | 20308 // Test access using __proto__ as a hijacked function (A). |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20479 set->Call(x, 1, args); | 20478 set->Call(x, 1, args); |
20480 CHECK(v8_num(14)->Equals(get->Call(x, 0, NULL))); | 20479 CHECK(v8_num(14)->Equals(get->Call(x, 0, NULL))); |
20481 } | 20480 } |
20482 | 20481 |
20483 | 20482 |
20484 TEST(Regress411877) { | 20483 TEST(Regress411877) { |
20485 v8::Isolate* isolate = CcTest::isolate(); | 20484 v8::Isolate* isolate = CcTest::isolate(); |
20486 v8::HandleScope handle_scope(isolate); | 20485 v8::HandleScope handle_scope(isolate); |
20487 v8::Handle<v8::ObjectTemplate> object_template = | 20486 v8::Handle<v8::ObjectTemplate> object_template = |
20488 v8::ObjectTemplate::New(isolate); | 20487 v8::ObjectTemplate::New(isolate); |
20489 object_template->SetAccessCheckCallbacks(AccessCounter, NULL); | 20488 object_template->SetAccessCheckCallback(AccessCounter); |
20490 | 20489 |
20491 v8::Handle<Context> context = Context::New(isolate); | 20490 v8::Handle<Context> context = Context::New(isolate); |
20492 v8::Context::Scope context_scope(context); | 20491 v8::Context::Scope context_scope(context); |
20493 | 20492 |
20494 context->Global()->Set(v8_str("o"), object_template->NewInstance()); | 20493 context->Global()->Set(v8_str("o"), object_template->NewInstance()); |
20495 CompileRun("Object.getOwnPropertyNames(o)"); | 20494 CompileRun("Object.getOwnPropertyNames(o)"); |
20496 } | 20495 } |
20497 | 20496 |
20498 | 20497 |
20499 TEST(GetHiddenPropertyTableAfterAccessCheck) { | 20498 TEST(GetHiddenPropertyTableAfterAccessCheck) { |
20500 v8::Isolate* isolate = CcTest::isolate(); | 20499 v8::Isolate* isolate = CcTest::isolate(); |
20501 v8::HandleScope handle_scope(isolate); | 20500 v8::HandleScope handle_scope(isolate); |
20502 v8::Handle<v8::ObjectTemplate> object_template = | 20501 v8::Handle<v8::ObjectTemplate> object_template = |
20503 v8::ObjectTemplate::New(isolate); | 20502 v8::ObjectTemplate::New(isolate); |
20504 object_template->SetAccessCheckCallbacks(AccessCounter, NULL); | 20503 object_template->SetAccessCheckCallback(AccessCounter); |
20505 | 20504 |
20506 v8::Handle<Context> context = Context::New(isolate); | 20505 v8::Handle<Context> context = Context::New(isolate); |
20507 v8::Context::Scope context_scope(context); | 20506 v8::Context::Scope context_scope(context); |
20508 | 20507 |
20509 v8::Handle<v8::Object> obj = object_template->NewInstance(); | 20508 v8::Handle<v8::Object> obj = object_template->NewInstance(); |
20510 obj->Set(v8_str("key"), v8_str("value")); | 20509 obj->Set(v8_str("key"), v8_str("value")); |
20511 obj->Delete(v8_str("key")); | 20510 obj->Delete(v8_str("key")); |
20512 | 20511 |
20513 obj->SetHiddenValue(v8_str("hidden key 2"), v8_str("hidden value 2")); | 20512 obj->SetHiddenValue(v8_str("hidden key 2"), v8_str("hidden value 2")); |
20514 } | 20513 } |
20515 | 20514 |
20516 | 20515 |
20517 TEST(Regress411793) { | 20516 TEST(Regress411793) { |
20518 v8::Isolate* isolate = CcTest::isolate(); | 20517 v8::Isolate* isolate = CcTest::isolate(); |
20519 v8::HandleScope handle_scope(isolate); | 20518 v8::HandleScope handle_scope(isolate); |
20520 v8::Handle<v8::ObjectTemplate> object_template = | 20519 v8::Handle<v8::ObjectTemplate> object_template = |
20521 v8::ObjectTemplate::New(isolate); | 20520 v8::ObjectTemplate::New(isolate); |
20522 object_template->SetAccessCheckCallbacks(AccessCounter, NULL); | 20521 object_template->SetAccessCheckCallback(AccessCounter); |
20523 | 20522 |
20524 v8::Handle<Context> context = Context::New(isolate); | 20523 v8::Handle<Context> context = Context::New(isolate); |
20525 v8::Context::Scope context_scope(context); | 20524 v8::Context::Scope context_scope(context); |
20526 | 20525 |
20527 context->Global()->Set(v8_str("o"), object_template->NewInstance()); | 20526 context->Global()->Set(v8_str("o"), object_template->NewInstance()); |
20528 CompileRun( | 20527 CompileRun( |
20529 "Object.defineProperty(o, 'key', " | 20528 "Object.defineProperty(o, 'key', " |
20530 " { get: function() {}, set: function() {} });"); | 20529 " { get: function() {}, set: function() {} });"); |
20531 } | 20530 } |
20532 | 20531 |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21176 | 21175 |
21177 | 21176 |
21178 TEST(GetPrototypeAccessControl) { | 21177 TEST(GetPrototypeAccessControl) { |
21179 i::FLAG_allow_natives_syntax = true; | 21178 i::FLAG_allow_natives_syntax = true; |
21180 v8::Isolate* isolate = CcTest::isolate(); | 21179 v8::Isolate* isolate = CcTest::isolate(); |
21181 v8::HandleScope handle_scope(isolate); | 21180 v8::HandleScope handle_scope(isolate); |
21182 LocalContext env; | 21181 LocalContext env; |
21183 | 21182 |
21184 v8::Handle<v8::ObjectTemplate> obj_template = | 21183 v8::Handle<v8::ObjectTemplate> obj_template = |
21185 v8::ObjectTemplate::New(isolate); | 21184 v8::ObjectTemplate::New(isolate); |
21186 obj_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL); | 21185 obj_template->SetAccessCheckCallback(AccessAlwaysBlocked); |
21187 | 21186 |
21188 env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance()); | 21187 env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance()); |
21189 | 21188 |
21190 CHECK(CompileRun( | 21189 CHECK(CompileRun( |
21191 "function f() { return %_GetPrototype(prohibited); }" | 21190 "function f() { return %_GetPrototype(prohibited); }" |
21192 "%OptimizeFunctionOnNextCall(f);" | 21191 "%OptimizeFunctionOnNextCall(f);" |
21193 "f();")->IsNull()); | 21192 "f();")->IsNull()); |
21194 } | 21193 } |
21195 | 21194 |
21196 | 21195 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21319 v8::Local<v8::Object> obj = v8::Object::New(isolate); | 21318 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
21320 | 21319 |
21321 USE(obj); | 21320 USE(obj); |
21322 } | 21321 } |
21323 } | 21322 } |
21324 | 21323 |
21325 | 21324 |
21326 static bool access_was_called = false; | 21325 static bool access_was_called = false; |
21327 | 21326 |
21328 | 21327 |
21329 static bool AccessAlwaysAllowedWithFlag(Local<v8::Object> global, | 21328 static bool AccessAlwaysAllowedWithFlag(Local<v8::Context> accessing_context, |
21330 Local<Value> name, v8::AccessType type, | 21329 Local<v8::Object> accessed_object) { |
21331 Local<Value> data) { | |
21332 access_was_called = true; | 21330 access_was_called = true; |
21333 return true; | 21331 return true; |
21334 } | 21332 } |
21335 | 21333 |
21336 | 21334 |
21337 static bool AccessAlwaysBlockedWithFlag(Local<v8::Object> global, | 21335 static bool AccessAlwaysBlockedWithFlag(Local<v8::Context> accessing_context, |
21338 Local<Value> name, v8::AccessType type, | 21336 Local<v8::Object> accessed_object) { |
21339 Local<Value> data) { | |
21340 access_was_called = true; | 21337 access_was_called = true; |
21341 return false; | 21338 return false; |
21342 } | 21339 } |
21343 | 21340 |
21344 | 21341 |
21345 TEST(StrongModeAccessCheckAllowed) { | 21342 TEST(StrongModeAccessCheckAllowed) { |
21346 i::FLAG_strong_mode = true; | 21343 i::FLAG_strong_mode = true; |
21347 v8::Isolate* isolate = CcTest::isolate(); | 21344 v8::Isolate* isolate = CcTest::isolate(); |
21348 v8::HandleScope handle_scope(isolate); | 21345 v8::HandleScope handle_scope(isolate); |
21349 v8::Handle<Value> value; | 21346 v8::Handle<Value> value; |
21350 access_was_called = false; | 21347 access_was_called = false; |
21351 | 21348 |
21352 v8::Handle<v8::ObjectTemplate> obj_template = | 21349 v8::Handle<v8::ObjectTemplate> obj_template = |
21353 v8::ObjectTemplate::New(isolate); | 21350 v8::ObjectTemplate::New(isolate); |
21354 | 21351 |
21355 obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42)); | 21352 obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42)); |
21356 obj_template->SetAccessCheckCallbacks(AccessAlwaysAllowedWithFlag, NULL); | 21353 obj_template->SetAccessCheckCallback(AccessAlwaysAllowedWithFlag); |
21357 | 21354 |
21358 // Create an environment | 21355 // Create an environment |
21359 v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template); | 21356 v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template); |
21360 context0->Enter(); | 21357 context0->Enter(); |
21361 v8::Handle<v8::Object> global0 = context0->Global(); | 21358 v8::Handle<v8::Object> global0 = context0->Global(); |
21362 global0->Set(v8_str("object"), obj_template->NewInstance()); | 21359 global0->Set(v8_str("object"), obj_template->NewInstance()); |
21363 { | 21360 { |
21364 v8::TryCatch try_catch(isolate); | 21361 v8::TryCatch try_catch(isolate); |
21365 value = CompileRun("'use strong'; object.x"); | 21362 value = CompileRun("'use strong'; object.x"); |
21366 CHECK(!try_catch.HasCaught()); | 21363 CHECK(!try_catch.HasCaught()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21416 i::FLAG_strong_mode = true; | 21413 i::FLAG_strong_mode = true; |
21417 v8::Isolate* isolate = CcTest::isolate(); | 21414 v8::Isolate* isolate = CcTest::isolate(); |
21418 v8::HandleScope handle_scope(isolate); | 21415 v8::HandleScope handle_scope(isolate); |
21419 v8::Handle<Value> value; | 21416 v8::Handle<Value> value; |
21420 access_was_called = false; | 21417 access_was_called = false; |
21421 | 21418 |
21422 v8::Handle<v8::ObjectTemplate> obj_template = | 21419 v8::Handle<v8::ObjectTemplate> obj_template = |
21423 v8::ObjectTemplate::New(isolate); | 21420 v8::ObjectTemplate::New(isolate); |
21424 | 21421 |
21425 obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42)); | 21422 obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42)); |
21426 obj_template->SetAccessCheckCallbacks(AccessAlwaysBlockedWithFlag, NULL); | 21423 obj_template->SetAccessCheckCallback(AccessAlwaysBlockedWithFlag); |
21427 | 21424 |
21428 // Create an environment | 21425 // Create an environment |
21429 v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template); | 21426 v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template); |
21430 context0->Enter(); | 21427 context0->Enter(); |
21431 v8::Handle<v8::Object> global0 = context0->Global(); | 21428 v8::Handle<v8::Object> global0 = context0->Global(); |
21432 global0->Set(v8_str("object"), obj_template->NewInstance()); | 21429 global0->Set(v8_str("object"), obj_template->NewInstance()); |
21433 { | 21430 { |
21434 v8::TryCatch try_catch(isolate); | 21431 v8::TryCatch try_catch(isolate); |
21435 value = CompileRun("'use strong'; object.x"); | 21432 value = CompileRun("'use strong'; object.x"); |
21436 CHECK(!try_catch.HasCaught()); | 21433 CHECK(!try_catch.HasCaught()); |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21889 | 21886 |
21890 | 21887 |
21891 TEST(AccessCheckedIsConcatSpreadable) { | 21888 TEST(AccessCheckedIsConcatSpreadable) { |
21892 i::FLAG_harmony_concat_spreadable = true; | 21889 i::FLAG_harmony_concat_spreadable = true; |
21893 v8::Isolate* isolate = CcTest::isolate(); | 21890 v8::Isolate* isolate = CcTest::isolate(); |
21894 HandleScope scope(isolate); | 21891 HandleScope scope(isolate); |
21895 LocalContext env; | 21892 LocalContext env; |
21896 | 21893 |
21897 // Object with access check | 21894 // Object with access check |
21898 Local<ObjectTemplate> spreadable_template = v8::ObjectTemplate::New(isolate); | 21895 Local<ObjectTemplate> spreadable_template = v8::ObjectTemplate::New(isolate); |
21899 spreadable_template->SetAccessCheckCallbacks(AccessBlocker, nullptr); | 21896 spreadable_template->SetAccessCheckCallback(AccessBlocker); |
21900 spreadable_template->Set(v8::Symbol::GetIsConcatSpreadable(isolate), | 21897 spreadable_template->Set(v8::Symbol::GetIsConcatSpreadable(isolate), |
21901 v8::Boolean::New(isolate, true)); | 21898 v8::Boolean::New(isolate, true)); |
21902 Local<Object> object = spreadable_template->NewInstance(); | 21899 Local<Object> object = spreadable_template->NewInstance(); |
21903 | 21900 |
21904 allowed_access = true; | 21901 allowed_access = true; |
21905 env->Global()->Set(v8_str("object"), object); | 21902 env->Global()->Set(v8_str("object"), object); |
21906 object->Set(v8_str("length"), v8_num(2)); | 21903 object->Set(v8_str("length"), v8_num(2)); |
21907 object->Set(0U, v8_str("a")); | 21904 object->Set(0U, v8_str("a")); |
21908 object->Set(1U, v8_str("b")); | 21905 object->Set(1U, v8_str("b")); |
21909 | 21906 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21949 env2->Global()->Set(v8_str("obj2"), object2); | 21946 env2->Global()->Set(v8_str("obj2"), object2); |
21950 ExpectString("typeof obj2.values", "function"); | 21947 ExpectString("typeof obj2.values", "function"); |
21951 CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values"))); | 21948 CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values"))); |
21952 | 21949 |
21953 auto values2 = Local<Function>::Cast(object2->Get(v8_str("values"))); | 21950 auto values2 = Local<Function>::Cast(object2->Get(v8_str("values"))); |
21954 auto fn2 = v8::Utils::OpenHandle(*values2); | 21951 auto fn2 = v8::Utils::OpenHandle(*values2); |
21955 auto ctx2 = v8::Utils::OpenHandle(*env2.local()); | 21952 auto ctx2 = v8::Utils::OpenHandle(*env2.local()); |
21956 CHECK_EQ(fn2->GetCreationContext(), *ctx2); | 21953 CHECK_EQ(fn2->GetCreationContext(), *ctx2); |
21957 } | 21954 } |
21958 } | 21955 } |
OLD | NEW |