Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: test/cctest/test-api.cc

Issue 428733007: Throw an exception when an access check fails and no external callback is installed (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: s/ReferenceError/TypeError/ per Toon's wish Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/mirror-debugger.js ('k') | tools/generate-runtime-tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6160 matching lines...) Expand 10 before | Expand all | Expand 10 after
6171 v8::HandleScope scope(isolate); 6171 v8::HandleScope scope(isolate);
6172 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); 6172 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6173 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); 6173 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter);
6174 6174
6175 LocalContext context; 6175 LocalContext context;
6176 Local<v8::Object> obj = templ->NewInstance(); 6176 Local<v8::Object> obj = templ->NewInstance();
6177 obj->TurnOnAccessCheck(); 6177 obj->TurnOnAccessCheck();
6178 context->Global()->Set(v8_str("obj"), obj); 6178 context->Global()->Set(v8_str("obj"), obj);
6179 6179
6180 const char* code = 6180 const char* code =
6181 "try {" 6181 "var result = 'PASSED';"
6182 " for (var i = 0; i < 100; i++) {" 6182 "for (var i = 0; i < 100; i++) {"
6183 " try {"
6183 " var v = obj[0];" 6184 " var v = obj[0];"
6184 " if (v != undefined) throw 'Wrong value ' + v + ' at iteration ' + i;" 6185 " result = 'Wrong value ' + v + ' at iteration ' + i;"
6186 " break;"
6187 " } catch (e) {"
6188 " /* pass */"
6185 " }" 6189 " }"
6186 " 'PASSED'" 6190 "}"
6187 "} catch(e) {" 6191 "result";
6188 " e"
6189 "}";
6190 ExpectString(code, "PASSED"); 6192 ExpectString(code, "PASSED");
6191 } 6193 }
6192 6194
6193 6195
6194 THREADED_TEST(IndexedInterceptorWithAccessorCheckSwitchedOn) { 6196 THREADED_TEST(IndexedInterceptorWithAccessorCheckSwitchedOn) {
6195 i::FLAG_allow_natives_syntax = true; 6197 i::FLAG_allow_natives_syntax = true;
6196 v8::Isolate* isolate = CcTest::isolate(); 6198 v8::Isolate* isolate = CcTest::isolate();
6197 v8::HandleScope scope(isolate); 6199 v8::HandleScope scope(isolate);
6198 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); 6200 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6199 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); 6201 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter);
6200 6202
6201 LocalContext context; 6203 LocalContext context;
6202 Local<v8::Object> obj = templ->NewInstance(); 6204 Local<v8::Object> obj = templ->NewInstance();
6203 context->Global()->Set(v8_str("obj"), obj); 6205 context->Global()->Set(v8_str("obj"), obj);
6204 6206
6205 const char* code = 6207 const char* code =
6206 "try {" 6208 "var result = 'PASSED';"
6207 " for (var i = 0; i < 100; i++) {" 6209 "for (var i = 0; i < 100; i++) {"
6208 " var expected = i;" 6210 " var expected = i;"
6211 " if (i == 5) {"
6212 " %EnableAccessChecks(obj);"
6213 " }"
6214 " try {"
6215 " var v = obj[i];"
6209 " if (i == 5) {" 6216 " if (i == 5) {"
6210 " %EnableAccessChecks(obj);" 6217 " result = 'Should not have reached this!';"
6211 " expected = undefined;" 6218 " break;"
6219 " } else if (v != expected) {"
6220 " result = 'Wrong value ' + v + ' at iteration ' + i;"
6221 " break;"
6212 " }" 6222 " }"
6213 " var v = obj[i];" 6223 " } catch (e) {"
6214 " if (v != expected) throw 'Wrong value ' + v + ' at iteration ' + i;" 6224 " if (i != 5) {"
6215 " if (i == 5) %DisableAccessChecks(obj);" 6225 " result = e;"
6226 " }"
6216 " }" 6227 " }"
6217 " 'PASSED'" 6228 " if (i == 5) %DisableAccessChecks(obj);"
6218 "} catch(e) {" 6229 "}"
6219 " e" 6230 "result";
6220 "}";
6221 ExpectString(code, "PASSED"); 6231 ExpectString(code, "PASSED");
6222 } 6232 }
6223 6233
6224 6234
6225 THREADED_TEST(IndexedInterceptorWithDifferentIndices) { 6235 THREADED_TEST(IndexedInterceptorWithDifferentIndices) {
6226 v8::Isolate* isolate = CcTest::isolate(); 6236 v8::Isolate* isolate = CcTest::isolate();
6227 v8::HandleScope scope(isolate); 6237 v8::HandleScope scope(isolate);
6228 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); 6238 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6229 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); 6239 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter);
6230 6240
(...skipping 2390 matching lines...) Expand 10 before | Expand all | Expand 10 after
8621 8631
8622 current->Global()->Set(v8_str("other"), other->Global()); 8632 current->Global()->Set(v8_str("other"), other->Global());
8623 CHECK(v8_compile("other")->Run()->Equals(other->Global())); 8633 CHECK(v8_compile("other")->Run()->Equals(other->Global()));
8624 8634
8625 // Make sure the security check fails here and we get an undefined 8635 // Make sure the security check fails here and we get an undefined
8626 // result instead of getting the Object function. Repeat in a loop 8636 // result instead of getting the Object function. Repeat in a loop
8627 // to make sure to exercise the IC code. 8637 // to make sure to exercise the IC code.
8628 v8::Local<Script> access_other0 = v8_compile("other.Object"); 8638 v8::Local<Script> access_other0 = v8_compile("other.Object");
8629 v8::Local<Script> access_other1 = v8_compile("other[42]"); 8639 v8::Local<Script> access_other1 = v8_compile("other[42]");
8630 for (int i = 0; i < 5; i++) { 8640 for (int i = 0; i < 5; i++) {
8631 CHECK(!access_other0->Run()->Equals(other_object)); 8641 CHECK(access_other0->Run().IsEmpty());
8632 CHECK(access_other0->Run()->IsUndefined()); 8642 CHECK(access_other1->Run().IsEmpty());
8633 CHECK(!access_other1->Run()->Equals(v8_num(87)));
8634 CHECK(access_other1->Run()->IsUndefined());
8635 } 8643 }
8636 8644
8637 // Create an object that has 'other' in its prototype chain and make 8645 // Create an object that has 'other' in its prototype chain and make
8638 // sure we cannot access the Object function indirectly through 8646 // sure we cannot access the Object function indirectly through
8639 // that. Repeat in a loop to make sure to exercise the IC code. 8647 // that. Repeat in a loop to make sure to exercise the IC code.
8640 v8_compile("function F() { };" 8648 v8_compile("function F() { };"
8641 "F.prototype = other;" 8649 "F.prototype = other;"
8642 "var f = new F();")->Run(); 8650 "var f = new F();")->Run();
8643 v8::Local<Script> access_f0 = v8_compile("f.Object"); 8651 v8::Local<Script> access_f0 = v8_compile("f.Object");
8644 v8::Local<Script> access_f1 = v8_compile("f[42]"); 8652 v8::Local<Script> access_f1 = v8_compile("f[42]");
8645 for (int j = 0; j < 5; j++) { 8653 for (int j = 0; j < 5; j++) {
8646 CHECK(!access_f0->Run()->Equals(other_object)); 8654 CHECK(access_f0->Run().IsEmpty());
8647 CHECK(access_f0->Run()->IsUndefined()); 8655 CHECK(access_f1->Run().IsEmpty());
8648 CHECK(!access_f1->Run()->Equals(v8_num(87)));
8649 CHECK(access_f1->Run()->IsUndefined());
8650 } 8656 }
8651 8657
8652 // Now it gets hairy: Set the prototype for the other global object 8658 // Now it gets hairy: Set the prototype for the other global object
8653 // to be the current global object. The prototype chain for 'f' now 8659 // to be the current global object. The prototype chain for 'f' now
8654 // goes through 'other' but ends up in the current global object. 8660 // goes through 'other' but ends up in the current global object.
8655 { Context::Scope scope(other); 8661 { Context::Scope scope(other);
8656 other->Global()->Set(v8_str("__proto__"), current->Global()); 8662 other->Global()->Set(v8_str("__proto__"), current->Global());
8657 } 8663 }
8658 // Set a named and an index property on the current global 8664 // Set a named and an index property on the current global
8659 // object. To force the lookup to go through the other global object, 8665 // object. To force the lookup to go through the other global object,
8660 // the properties must not exist in the other global object. 8666 // the properties must not exist in the other global object.
8661 current->Global()->Set(v8_str("foo"), v8_num(100)); 8667 current->Global()->Set(v8_str("foo"), v8_num(100));
8662 current->Global()->Set(v8_num(99), v8_num(101)); 8668 current->Global()->Set(v8_num(99), v8_num(101));
8663 // Try to read the properties from f and make sure that the access 8669 // Try to read the properties from f and make sure that the access
8664 // gets stopped by the security checks on the other global object. 8670 // gets stopped by the security checks on the other global object.
8665 Local<Script> access_f2 = v8_compile("f.foo"); 8671 Local<Script> access_f2 = v8_compile("f.foo");
8666 Local<Script> access_f3 = v8_compile("f[99]"); 8672 Local<Script> access_f3 = v8_compile("f[99]");
8667 for (int k = 0; k < 5; k++) { 8673 for (int k = 0; k < 5; k++) {
8668 CHECK(!access_f2->Run()->Equals(v8_num(100))); 8674 CHECK(access_f2->Run().IsEmpty());
8669 CHECK(access_f2->Run()->IsUndefined()); 8675 CHECK(access_f3->Run().IsEmpty());
8670 CHECK(!access_f3->Run()->Equals(v8_num(101)));
8671 CHECK(access_f3->Run()->IsUndefined());
8672 } 8676 }
8673 } 8677 }
8674 8678
8675 8679
8676 static bool named_security_check_with_gc_called; 8680 static bool named_security_check_with_gc_called;
8677 8681
8678 static bool NamedSecurityCallbackWithGC(Local<v8::Object> global, 8682 static bool NamedSecurityCallbackWithGC(Local<v8::Object> global,
8679 Local<Value> name, 8683 Local<Value> name,
8680 v8::AccessType type, 8684 v8::AccessType type,
8681 Local<Value> data) { 8685 Local<Value> data) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
8742 8746
8743 env1->Global()->Set(v8_str("prop"), v8_num(3)); 8747 env1->Global()->Set(v8_str("prop"), v8_num(3));
8744 env2->Global()->Set(v8_str("env1"), env1->Global()); 8748 env2->Global()->Set(v8_str("env1"), env1->Global());
8745 8749
8746 // Change env2 to a different domain and delete env1.prop. 8750 // Change env2 to a different domain and delete env1.prop.
8747 env2->SetSecurityToken(bar); 8751 env2->SetSecurityToken(bar);
8748 { 8752 {
8749 Context::Scope scope_env2(env2); 8753 Context::Scope scope_env2(env2);
8750 Local<Value> result = 8754 Local<Value> result =
8751 CompileRun("delete env1.prop"); 8755 CompileRun("delete env1.prop");
8752 CHECK(result->IsFalse()); 8756 CHECK(result.IsEmpty());
8753 } 8757 }
8754 8758
8755 // Check that env1.prop still exists. 8759 // Check that env1.prop still exists.
8756 Local<Value> v = env1->Global()->Get(v8_str("prop")); 8760 Local<Value> v = env1->Global()->Get(v8_str("prop"));
8757 CHECK(v->IsNumber()); 8761 CHECK(v->IsNumber());
8758 CHECK_EQ(3, v->Int32Value()); 8762 CHECK_EQ(3, v->Int32Value());
8759 } 8763 }
8760 8764
8761 8765
8762 THREADED_TEST(CrossDomainIsPropertyEnumerable) { 8766 THREADED_TEST(CrossDomainIsPropertyEnumerable) {
(...skipping 17 matching lines...) Expand all
8780 Context::Scope scope_env2(env2); 8784 Context::Scope scope_env2(env2);
8781 Local<Value> result = CompileRun(test); 8785 Local<Value> result = CompileRun(test);
8782 CHECK(result->IsTrue()); 8786 CHECK(result->IsTrue());
8783 } 8787 }
8784 8788
8785 // Change env2 to a different domain and test again. 8789 // Change env2 to a different domain and test again.
8786 env2->SetSecurityToken(bar); 8790 env2->SetSecurityToken(bar);
8787 { 8791 {
8788 Context::Scope scope_env2(env2); 8792 Context::Scope scope_env2(env2);
8789 Local<Value> result = CompileRun(test); 8793 Local<Value> result = CompileRun(test);
8790 CHECK(result->IsFalse()); 8794 CHECK(result.IsEmpty());
8791 } 8795 }
8792 } 8796 }
8793 8797
8794 8798
8795 THREADED_TEST(CrossDomainForIn) { 8799 THREADED_TEST(CrossDomainForIn) {
8796 LocalContext env1; 8800 LocalContext env1;
8797 v8::HandleScope handle_scope(env1->GetIsolate()); 8801 v8::HandleScope handle_scope(env1->GetIsolate());
8798 v8::Handle<Context> env2 = Context::New(env1->GetIsolate()); 8802 v8::Handle<Context> env2 = Context::New(env1->GetIsolate());
8799 8803
8800 Local<Value> foo = v8_str("foo"); 8804 Local<Value> foo = v8_str("foo");
8801 Local<Value> bar = v8_str("bar"); 8805 Local<Value> bar = v8_str("bar");
8802 8806
8803 // Set to the same domain. 8807 // Set to the same domain.
8804 env1->SetSecurityToken(foo); 8808 env1->SetSecurityToken(foo);
8805 env2->SetSecurityToken(foo); 8809 env2->SetSecurityToken(foo);
8806 8810
8807 env1->Global()->Set(v8_str("prop"), v8_num(3)); 8811 env1->Global()->Set(v8_str("prop"), v8_num(3));
8808 env2->Global()->Set(v8_str("env1"), env1->Global()); 8812 env2->Global()->Set(v8_str("env1"), env1->Global());
8809 8813
8810 // Change env2 to a different domain and set env1's global object 8814 // Change env2 to a different domain and set env1's global object
8811 // as the __proto__ of an object in env2 and enumerate properties 8815 // as the __proto__ of an object in env2 and enumerate properties
8812 // in for-in. It shouldn't enumerate properties on env1's global 8816 // in for-in. It shouldn't enumerate properties on env1's global
8813 // object. 8817 // object.
8814 env2->SetSecurityToken(bar); 8818 env2->SetSecurityToken(bar);
8815 { 8819 {
8816 Context::Scope scope_env2(env2); 8820 Context::Scope scope_env2(env2);
8817 Local<Value> result = 8821 Local<Value> result = CompileRun(
8818 CompileRun("(function(){var obj = {'__proto__':env1};" 8822 "(function() {"
8819 "for (var p in obj)" 8823 " var obj = { '__proto__': env1 };"
8820 " if (p == 'prop') return false;" 8824 " try {"
8821 "return true;})()"); 8825 " for (var p in obj) {"
8826 " if (p == 'prop') return false;"
8827 " }"
8828 " return false;"
8829 " } catch (e) {"
8830 " return true;"
8831 " }"
8832 "})()");
8822 CHECK(result->IsTrue()); 8833 CHECK(result->IsTrue());
8823 } 8834 }
8824 } 8835 }
8825 8836
8826 8837
8827 TEST(ContextDetachGlobal) { 8838 TEST(ContextDetachGlobal) {
8828 LocalContext env1; 8839 LocalContext env1;
8829 v8::HandleScope handle_scope(env1->GetIsolate()); 8840 v8::HandleScope handle_scope(env1->GetIsolate());
8830 v8::Handle<Context> env2 = Context::New(env1->GetIsolate()); 8841 v8::Handle<Context> env2 = Context::New(env1->GetIsolate());
8831 8842
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
8873 CHECK(get_prop->IsFunction()); 8884 CHECK(get_prop->IsFunction());
8874 v8::TryCatch try_catch; 8885 v8::TryCatch try_catch;
8875 Local<Value> r = Function::Cast(*get_prop)->Call(global1, 0, NULL); 8886 Local<Value> r = Function::Cast(*get_prop)->Call(global1, 0, NULL);
8876 CHECK(!try_catch.HasCaught()); 8887 CHECK(!try_catch.HasCaught());
8877 CHECK_EQ(1, r->Int32Value()); 8888 CHECK_EQ(1, r->Int32Value());
8878 } 8889 }
8879 8890
8880 // Check that env3 is not accessible from env1 8891 // Check that env3 is not accessible from env1
8881 { 8892 {
8882 Local<Value> r = global3->Get(v8_str("prop2")); 8893 Local<Value> r = global3->Get(v8_str("prop2"));
8883 CHECK(r->IsUndefined()); 8894 CHECK(r.IsEmpty());
8884 } 8895 }
8885 } 8896 }
8886 8897
8887 8898
8888 TEST(DetachGlobal) { 8899 TEST(DetachGlobal) {
8889 LocalContext env1; 8900 LocalContext env1;
8890 v8::HandleScope scope(env1->GetIsolate()); 8901 v8::HandleScope scope(env1->GetIsolate());
8891 8902
8892 // Create second environment. 8903 // Create second environment.
8893 v8::Handle<Context> env2 = Context::New(env1->GetIsolate()); 8904 v8::Handle<Context> env2 = Context::New(env1->GetIsolate());
(...skipping 18 matching lines...) Expand all
8912 CHECK(result->IsInt32()); 8923 CHECK(result->IsInt32());
8913 CHECK_EQ(42, result->Int32Value()); 8924 CHECK_EQ(42, result->Int32Value());
8914 8925
8915 // Hold on to global from env2 and detach global from env2. 8926 // Hold on to global from env2 and detach global from env2.
8916 Local<v8::Object> global2 = env2->Global(); 8927 Local<v8::Object> global2 = env2->Global();
8917 env2->DetachGlobal(); 8928 env2->DetachGlobal();
8918 8929
8919 // Check that the global has been detached. No other.p property can 8930 // Check that the global has been detached. No other.p property can
8920 // be found. 8931 // be found.
8921 result = CompileRun("other.p"); 8932 result = CompileRun("other.p");
8922 CHECK(result->IsUndefined()); 8933 CHECK(result.IsEmpty());
8923 8934
8924 // Reuse global2 for env3. 8935 // Reuse global2 for env3.
8925 v8::Handle<Context> env3 = Context::New(env1->GetIsolate(), 8936 v8::Handle<Context> env3 = Context::New(env1->GetIsolate(),
8926 0, 8937 0,
8927 v8::Handle<v8::ObjectTemplate>(), 8938 v8::Handle<v8::ObjectTemplate>(),
8928 global2); 8939 global2);
8929 CHECK_EQ(global2, env3->Global()); 8940 CHECK_EQ(global2, env3->Global());
8930 8941
8931 // Start by using the same security token for env3 as for env1 and env2. 8942 // Start by using the same security token for env3 as for env1 and env2.
8932 env3->SetSecurityToken(foo); 8943 env3->SetSecurityToken(foo);
8933 8944
8934 // Create a property on the global object in env3. 8945 // Create a property on the global object in env3.
8935 { 8946 {
8936 v8::Context::Scope scope(env3); 8947 v8::Context::Scope scope(env3);
8937 env3->Global()->Set(v8_str("p"), v8::Integer::New(env3->GetIsolate(), 24)); 8948 env3->Global()->Set(v8_str("p"), v8::Integer::New(env3->GetIsolate(), 24));
8938 } 8949 }
8939 8950
8940 // Check that other.p is now the property in env3 and that we have access. 8951 // Check that other.p is now the property in env3 and that we have access.
8941 result = CompileRun("other.p"); 8952 result = CompileRun("other.p");
8942 CHECK(result->IsInt32()); 8953 CHECK(result->IsInt32());
8943 CHECK_EQ(24, result->Int32Value()); 8954 CHECK_EQ(24, result->Int32Value());
8944 8955
8945 // Change security token for env3 to something different from env1 and env2. 8956 // Change security token for env3 to something different from env1 and env2.
8946 env3->SetSecurityToken(v8_str("bar")); 8957 env3->SetSecurityToken(v8_str("bar"));
8947 8958
8948 // Check that we do not have access to other.p in env1. |other| is now 8959 // Check that we do not have access to other.p in env1. |other| is now
8949 // the global object for env3 which has a different security token, 8960 // the global object for env3 which has a different security token,
8950 // so access should be blocked. 8961 // so access should be blocked.
8951 result = CompileRun("other.p"); 8962 result = CompileRun("other.p");
8952 CHECK(result->IsUndefined()); 8963 CHECK(result.IsEmpty());
8953 } 8964 }
8954 8965
8955 8966
8956 void GetThisX(const v8::FunctionCallbackInfo<v8::Value>& info) { 8967 void GetThisX(const v8::FunctionCallbackInfo<v8::Value>& info) {
8957 info.GetReturnValue().Set( 8968 info.GetReturnValue().Set(
8958 info.GetIsolate()->GetCurrentContext()->Global()->Get(v8_str("x"))); 8969 info.GetIsolate()->GetCurrentContext()->Global()->Get(v8_str("x")));
8959 } 8970 }
8960 8971
8961 8972
8962 TEST(DetachedAccesses) { 8973 TEST(DetachedAccesses) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
8995 } 9006 }
8996 9007
8997 Local<Object> env2_global = env2->Global(); 9008 Local<Object> env2_global = env2->Global();
8998 env2_global->TurnOnAccessCheck(); 9009 env2_global->TurnOnAccessCheck();
8999 env2->DetachGlobal(); 9010 env2->DetachGlobal();
9000 9011
9001 Local<Value> result; 9012 Local<Value> result;
9002 result = CompileRun("bound_x()"); 9013 result = CompileRun("bound_x()");
9003 CHECK_EQ(v8_str("env2_x"), result); 9014 CHECK_EQ(v8_str("env2_x"), result);
9004 result = CompileRun("get_x()"); 9015 result = CompileRun("get_x()");
9005 CHECK(result->IsUndefined()); 9016 CHECK(result.IsEmpty());
9006 result = CompileRun("get_x_w()"); 9017 result = CompileRun("get_x_w()");
9007 CHECK(result->IsUndefined()); 9018 CHECK(result.IsEmpty());
9008 result = CompileRun("this_x()"); 9019 result = CompileRun("this_x()");
9009 CHECK_EQ(v8_str("env2_x"), result); 9020 CHECK_EQ(v8_str("env2_x"), result);
9010 9021
9011 // Reattach env2's proxy 9022 // Reattach env2's proxy
9012 env2 = Context::New(env1->GetIsolate(), 9023 env2 = Context::New(env1->GetIsolate(),
9013 0, 9024 0,
9014 v8::Handle<v8::ObjectTemplate>(), 9025 v8::Handle<v8::ObjectTemplate>(),
9015 env2_global); 9026 env2_global);
9016 env2->SetSecurityToken(foo); 9027 env2->SetSecurityToken(foo);
9017 { 9028 {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
9193 9204
9194 v8::Local<Context> context1 = Context::New(isolate); 9205 v8::Local<Context> context1 = Context::New(isolate);
9195 context1->Enter(); 9206 context1->Enter();
9196 9207
9197 v8::Handle<v8::Object> global1 = context1->Global(); 9208 v8::Handle<v8::Object> global1 = context1->Global();
9198 global1->Set(v8_str("other"), global0); 9209 global1->Set(v8_str("other"), global0);
9199 9210
9200 // Access blocked property. 9211 // Access blocked property.
9201 CompileRun("other.blocked_prop = 1"); 9212 CompileRun("other.blocked_prop = 1");
9202 9213
9203 ExpectUndefined("other.blocked_prop"); 9214 CHECK(CompileRun("other.blocked_prop").IsEmpty());
9204 ExpectUndefined( 9215 CHECK(CompileRun("Object.getOwnPropertyDescriptor(other, 'blocked_prop')")
9205 "Object.getOwnPropertyDescriptor(other, 'blocked_prop')"); 9216 .IsEmpty());
9206 ExpectFalse("propertyIsEnumerable.call(other, 'blocked_prop')"); 9217 CHECK(
9218 CompileRun("propertyIsEnumerable.call(other, 'blocked_prop')").IsEmpty());
9207 9219
9208 // Access blocked element. 9220 // Access blocked element.
9209 CompileRun("other[239] = 1"); 9221 CHECK(CompileRun("other[239] = 1").IsEmpty());
9210 9222
9211 ExpectUndefined("other[239]"); 9223 CHECK(CompileRun("other[239]").IsEmpty());
9212 ExpectUndefined("Object.getOwnPropertyDescriptor(other, '239')"); 9224 CHECK(CompileRun("Object.getOwnPropertyDescriptor(other, '239')").IsEmpty());
9213 ExpectFalse("propertyIsEnumerable.call(other, '239')"); 9225 CHECK(CompileRun("propertyIsEnumerable.call(other, '239')").IsEmpty());
9214 9226
9215 // Enable ACCESS_HAS 9227 // Enable ACCESS_HAS
9216 allowed_access_type[v8::ACCESS_HAS] = true; 9228 allowed_access_type[v8::ACCESS_HAS] = true;
9217 ExpectUndefined("other[239]"); 9229 CHECK(CompileRun("other[239]").IsEmpty());
9218 // ... and now we can get the descriptor... 9230 // ... and now we can get the descriptor...
9219 ExpectUndefined("Object.getOwnPropertyDescriptor(other, '239').value"); 9231 CHECK(CompileRun("Object.getOwnPropertyDescriptor(other, '239').value")
9232 .IsEmpty());
9220 // ... and enumerate the property. 9233 // ... and enumerate the property.
9221 ExpectTrue("propertyIsEnumerable.call(other, '239')"); 9234 ExpectTrue("propertyIsEnumerable.call(other, '239')");
9222 allowed_access_type[v8::ACCESS_HAS] = false; 9235 allowed_access_type[v8::ACCESS_HAS] = false;
9223 9236
9224 // Access a property with JS accessor. 9237 // Access a property with JS accessor.
9225 CompileRun("other.js_accessor_p = 2"); 9238 CHECK(CompileRun("other.js_accessor_p = 2").IsEmpty());
9226 9239
9227 ExpectUndefined("other.js_accessor_p"); 9240 CHECK(CompileRun("other.js_accessor_p").IsEmpty());
9228 ExpectUndefined( 9241 CHECK(CompileRun("Object.getOwnPropertyDescriptor(other, 'js_accessor_p')")
9229 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p')"); 9242 .IsEmpty());
9230 9243
9231 // Enable both ACCESS_HAS and ACCESS_GET. 9244 // Enable both ACCESS_HAS and ACCESS_GET.
9232 allowed_access_type[v8::ACCESS_HAS] = true; 9245 allowed_access_type[v8::ACCESS_HAS] = true;
9233 allowed_access_type[v8::ACCESS_GET] = true; 9246 allowed_access_type[v8::ACCESS_GET] = true;
9234 9247
9235 ExpectString("other.js_accessor_p", "getter"); 9248 ExpectString("other.js_accessor_p", "getter");
9236 ExpectObject( 9249 ExpectObject(
9237 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').get", getter); 9250 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').get", getter);
9238 ExpectObject( 9251 ExpectObject(
9239 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').set", setter); 9252 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').set", setter);
9240 ExpectUndefined( 9253 ExpectUndefined(
9241 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').value"); 9254 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').value");
9242 9255
9243 allowed_access_type[v8::ACCESS_HAS] = false; 9256 allowed_access_type[v8::ACCESS_HAS] = false;
9244 allowed_access_type[v8::ACCESS_GET] = false; 9257 allowed_access_type[v8::ACCESS_GET] = false;
9245 9258
9246 // Access an element with JS accessor. 9259 // Access an element with JS accessor.
9247 CompileRun("other[42] = 2"); 9260 CHECK(CompileRun("other[42] = 2").IsEmpty());
9248 9261
9249 ExpectUndefined("other[42]"); 9262 CHECK(CompileRun("other[42]").IsEmpty());
9250 ExpectUndefined("Object.getOwnPropertyDescriptor(other, '42')"); 9263 CHECK(CompileRun("Object.getOwnPropertyDescriptor(other, '42')").IsEmpty());
9251 9264
9252 // Enable both ACCESS_HAS and ACCESS_GET. 9265 // Enable both ACCESS_HAS and ACCESS_GET.
9253 allowed_access_type[v8::ACCESS_HAS] = true; 9266 allowed_access_type[v8::ACCESS_HAS] = true;
9254 allowed_access_type[v8::ACCESS_GET] = true; 9267 allowed_access_type[v8::ACCESS_GET] = true;
9255 9268
9256 ExpectString("other[42]", "el_getter"); 9269 ExpectString("other[42]", "el_getter");
9257 ExpectObject("Object.getOwnPropertyDescriptor(other, '42').get", el_getter); 9270 ExpectObject("Object.getOwnPropertyDescriptor(other, '42').get", el_getter);
9258 ExpectObject("Object.getOwnPropertyDescriptor(other, '42').set", el_setter); 9271 ExpectObject("Object.getOwnPropertyDescriptor(other, '42').set", el_setter);
9259 ExpectUndefined("Object.getOwnPropertyDescriptor(other, '42').value"); 9272 ExpectUndefined("Object.getOwnPropertyDescriptor(other, '42').value");
9260 9273
(...skipping 15 matching lines...) Expand all
9276 value = CompileRun( 9289 value = CompileRun(
9277 "Object.getOwnPropertyDescriptor(other, 'accessible_prop').value"); 9290 "Object.getOwnPropertyDescriptor(other, 'accessible_prop').value");
9278 CHECK(value->IsNumber()); 9291 CHECK(value->IsNumber());
9279 CHECK_EQ(3, value->Int32Value()); 9292 CHECK_EQ(3, value->Int32Value());
9280 9293
9281 value = CompileRun("propertyIsEnumerable.call(other, 'accessible_prop')"); 9294 value = CompileRun("propertyIsEnumerable.call(other, 'accessible_prop')");
9282 CHECK(value->IsTrue()); 9295 CHECK(value->IsTrue());
9283 9296
9284 // Enumeration doesn't enumerate accessors from inaccessible objects in 9297 // Enumeration doesn't enumerate accessors from inaccessible objects in
9285 // the prototype chain even if the accessors are in themselves accessible. 9298 // the prototype chain even if the accessors are in themselves accessible.
9286 value = 9299 value = CompileRun(
9287 CompileRun("(function(){var obj = {'__proto__':other};" 9300 "(function() {"
9288 "for (var p in obj)" 9301 " var obj = { '__proto__': other };"
9289 " if (p == 'accessible_prop' ||" 9302 " try {"
9290 " p == 'blocked_js_prop' ||" 9303 " for (var p in obj) {"
9291 " p == 'blocked_js_prop') {" 9304 " if (p == 'accessible_prop' ||"
9292 " return false;" 9305 " p == 'blocked_js_prop' ||"
9293 " }" 9306 " p == 'blocked_js_prop') {"
9294 "return true;})()"); 9307 " return false;"
9308 " }"
9309 " }"
9310 " return false;"
9311 " } catch (e) {"
9312 " return true;"
9313 " }"
9314 "})()");
9295 CHECK(value->IsTrue()); 9315 CHECK(value->IsTrue());
9296 9316
9297 context1->Exit(); 9317 context1->Exit();
9298 context0->Exit(); 9318 context0->Exit();
9299 } 9319 }
9300 9320
9301 9321
9302 TEST(AccessControlES5) { 9322 TEST(AccessControlES5) {
9303 v8::Isolate* isolate = CcTest::isolate(); 9323 v8::Isolate* isolate = CcTest::isolate();
9304 v8::HandleScope handle_scope(isolate); 9324 v8::HandleScope handle_scope(isolate);
(...skipping 22 matching lines...) Expand all
9327 context0->Enter(); 9347 context0->Enter();
9328 9348
9329 v8::Handle<v8::Object> global0 = context0->Global(); 9349 v8::Handle<v8::Object> global0 = context0->Global();
9330 9350
9331 v8::Local<Context> context1 = Context::New(isolate); 9351 v8::Local<Context> context1 = Context::New(isolate);
9332 context1->Enter(); 9352 context1->Enter();
9333 v8::Handle<v8::Object> global1 = context1->Global(); 9353 v8::Handle<v8::Object> global1 = context1->Global();
9334 global1->Set(v8_str("other"), global0); 9354 global1->Set(v8_str("other"), global0);
9335 9355
9336 // Regression test for issue 1154. 9356 // Regression test for issue 1154.
9337 ExpectTrue("Object.keys(other).indexOf('blocked_prop') == -1"); 9357 CHECK(CompileRun("Object.keys(other)").IsEmpty());
9338 9358 CHECK(CompileRun("other.blocked_prop").IsEmpty());
9339 ExpectUndefined("other.blocked_prop");
9340 9359
9341 // Regression test for issue 1027. 9360 // Regression test for issue 1027.
9342 CompileRun("Object.defineProperty(\n" 9361 CompileRun("Object.defineProperty(\n"
9343 " other, 'blocked_prop', {configurable: false})"); 9362 " other, 'blocked_prop', {configurable: false})");
9344 ExpectUndefined("other.blocked_prop"); 9363 CHECK(CompileRun("other.blocked_prop").IsEmpty());
9345 ExpectUndefined( 9364 CHECK(CompileRun("Object.getOwnPropertyDescriptor(other, 'blocked_prop')")
9346 "Object.getOwnPropertyDescriptor(other, 'blocked_prop')"); 9365 .IsEmpty());
9347 9366
9348 // Regression test for issue 1171. 9367 // Regression test for issue 1171.
9349 ExpectTrue("Object.isExtensible(other)"); 9368 ExpectTrue("Object.isExtensible(other)");
9350 CompileRun("Object.preventExtensions(other)"); 9369 CompileRun("Object.preventExtensions(other)");
9351 ExpectTrue("Object.isExtensible(other)"); 9370 ExpectTrue("Object.isExtensible(other)");
9352 9371
9353 // Object.seal and Object.freeze. 9372 // Object.seal and Object.freeze.
9354 CompileRun("Object.freeze(other)"); 9373 CompileRun("Object.freeze(other)");
9355 ExpectTrue("Object.isExtensible(other)"); 9374 ExpectTrue("Object.isExtensible(other)");
9356 9375
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
9412 global1->Set(v8_str("object"), obj_template->NewInstance()); 9431 global1->Set(v8_str("object"), obj_template->NewInstance());
9413 9432
9414 v8::Handle<Value> value; 9433 v8::Handle<Value> value;
9415 9434
9416 // Attempt to get the property names of the other global object and 9435 // Attempt to get the property names of the other global object and
9417 // of an object that requires access checks. Accessing the other 9436 // of an object that requires access checks. Accessing the other
9418 // global object should be blocked by access checks on the global 9437 // global object should be blocked by access checks on the global
9419 // proxy object. Accessing the object that requires access checks 9438 // proxy object. Accessing the object that requires access checks
9420 // is blocked by the access checks on the object itself. 9439 // is blocked by the access checks on the object itself.
9421 value = CompileRun("Object.getOwnPropertyNames(other).length == 0"); 9440 value = CompileRun("Object.getOwnPropertyNames(other).length == 0");
9422 CHECK(value->IsTrue()); 9441 CHECK(value.IsEmpty());
9423 9442
9424 value = CompileRun("Object.getOwnPropertyNames(object).length == 0"); 9443 value = CompileRun("Object.getOwnPropertyNames(object).length == 0");
9425 CHECK(value->IsTrue()); 9444 CHECK(value.IsEmpty());
9426 9445
9427 context1->Exit(); 9446 context1->Exit();
9428 context0->Exit(); 9447 context0->Exit();
9429 } 9448 }
9430 9449
9431 9450
9432 static void IndexedPropertyEnumerator( 9451 static void IndexedPropertyEnumerator(
9433 const v8::PropertyCallbackInfo<v8::Array>& info) { 9452 const v8::PropertyCallbackInfo<v8::Array>& info) {
9434 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); 9453 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2);
9435 result->Set(0, v8::Integer::New(info.GetIsolate(), 7)); 9454 result->Set(0, v8::Integer::New(info.GetIsolate(), 7));
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
9523 9542
9524 v8::Handle<v8::Object> global1 = context1->Global(); 9543 v8::Handle<v8::Object> global1 = context1->Global();
9525 global1->Set(v8_str("other"), global); 9544 global1->Set(v8_str("other"), global);
9526 9545
9527 // Should return 10, instead of 11 9546 // Should return 10, instead of 11
9528 v8::Handle<Value> value = v8_compile("other.accessible")->Run(); 9547 v8::Handle<Value> value = v8_compile("other.accessible")->Run();
9529 CHECK(value->IsNumber()); 9548 CHECK(value->IsNumber());
9530 CHECK_EQ(10, value->Int32Value()); 9549 CHECK_EQ(10, value->Int32Value());
9531 9550
9532 value = v8_compile("other.unreachable")->Run(); 9551 value = v8_compile("other.unreachable")->Run();
9533 CHECK(value->IsUndefined()); 9552 CHECK(value.IsEmpty());
9534 9553
9535 context1->Exit(); 9554 context1->Exit();
9536 context0->Exit(); 9555 context0->Exit();
9537 } 9556 }
9538 9557
9539 9558
9540 static int named_access_count = 0; 9559 static int named_access_count = 0;
9541 static int indexed_access_count = 0; 9560 static int indexed_access_count = 0;
9542 9561
9543 static bool NamedAccessCounter(Local<v8::Object> global, 9562 static bool NamedAccessCounter(Local<v8::Object> global,
(...skipping 5091 matching lines...) Expand 10 before | Expand all | Expand 10 after
14635 buf[3] = 0; 14654 buf[3] = 0;
14636 templ->Set(v8_str(buf), v8::Number::New(isolate, k)); 14655 templ->Set(v8_str(buf), v8::Number::New(isolate, k));
14637 } 14656 }
14638 } 14657 }
14639 } 14658 }
14640 14659
14641 Local<v8::Object> instance_1 = templ->NewInstance(); 14660 Local<v8::Object> instance_1 = templ->NewInstance();
14642 context->Global()->Set(v8_str("obj_1"), instance_1); 14661 context->Global()->Set(v8_str("obj_1"), instance_1);
14643 14662
14644 Local<Value> value_1 = CompileRun("obj_1.a"); 14663 Local<Value> value_1 = CompileRun("obj_1.a");
14645 CHECK(value_1->IsUndefined()); 14664 CHECK(value_1.IsEmpty());
14646 14665
14647 Local<v8::Object> instance_2 = templ->NewInstance(); 14666 Local<v8::Object> instance_2 = templ->NewInstance();
14648 context->Global()->Set(v8_str("obj_2"), instance_2); 14667 context->Global()->Set(v8_str("obj_2"), instance_2);
14649 14668
14650 Local<Value> value_2 = CompileRun("obj_2.a"); 14669 Local<Value> value_2 = CompileRun("obj_2.a");
14651 CHECK(value_2->IsUndefined()); 14670 CHECK(value_2.IsEmpty());
14652 } 14671 }
14653 14672
14654 14673
14655 // This tests that access check information remains on the global 14674 // This tests that access check information remains on the global
14656 // object template when creating contexts. 14675 // object template when creating contexts.
14657 THREADED_TEST(AccessControlRepeatedContextCreation) { 14676 THREADED_TEST(AccessControlRepeatedContextCreation) {
14658 v8::Isolate* isolate = CcTest::isolate(); 14677 v8::Isolate* isolate = CcTest::isolate();
14659 v8::HandleScope handle_scope(isolate); 14678 v8::HandleScope handle_scope(isolate);
14660 v8::Handle<v8::ObjectTemplate> global_template = 14679 v8::Handle<v8::ObjectTemplate> global_template =
14661 v8::ObjectTemplate::New(isolate); 14680 v8::ObjectTemplate::New(isolate);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
14722 for (int i = 0; i < 4; i++) { 14741 for (int i = 0; i < 4; i++) {
14723 CHECK(g2->Call(global, 0, NULL)->Equals(v8_num(1))); 14742 CHECK(g2->Call(global, 0, NULL)->Equals(v8_num(1)));
14724 } 14743 }
14725 14744
14726 // Detach the global and turn on access check. 14745 // Detach the global and turn on access check.
14727 Local<Object> hidden_global = Local<Object>::Cast( 14746 Local<Object> hidden_global = Local<Object>::Cast(
14728 context->Global()->GetPrototype()); 14747 context->Global()->GetPrototype());
14729 context->DetachGlobal(); 14748 context->DetachGlobal();
14730 hidden_global->TurnOnAccessCheck(); 14749 hidden_global->TurnOnAccessCheck();
14731 14750
14732 // Failing access check to property get results in undefined. 14751 // Failing access check results in exception.
14733 CHECK(f1->Call(global, 0, NULL)->IsUndefined()); 14752 CHECK(f1->Call(global, 0, NULL).IsEmpty());
14734 CHECK(f2->Call(global, 0, NULL)->IsUndefined()); 14753 CHECK(f2->Call(global, 0, NULL).IsEmpty());
14735
14736 // Failing access check to function call results in exception.
14737 CHECK(g1->Call(global, 0, NULL).IsEmpty()); 14754 CHECK(g1->Call(global, 0, NULL).IsEmpty());
14738 CHECK(g2->Call(global, 0, NULL).IsEmpty()); 14755 CHECK(g2->Call(global, 0, NULL).IsEmpty());
14739 14756
14740 // No failing access check when just returning a constant. 14757 // No failing access check when just returning a constant.
14741 CHECK(h->Call(global, 0, NULL)->Equals(v8_num(1))); 14758 CHECK(h->Call(global, 0, NULL)->Equals(v8_num(1)));
14742 } 14759 }
14743 14760
14744 14761
14745 static const char* kPropertyA = "a"; 14762 static const char* kPropertyA = "a";
14746 static const char* kPropertyH = "h"; 14763 static const char* kPropertyH = "h";
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
14810 CHECK(g2->Call(global, 0, NULL)->Equals(v8_num(1))); 14827 CHECK(g2->Call(global, 0, NULL)->Equals(v8_num(1)));
14811 } 14828 }
14812 14829
14813 // Detach the global and turn on access check now blocking access to property 14830 // Detach the global and turn on access check now blocking access to property
14814 // a and function h. 14831 // a and function h.
14815 Local<Object> hidden_global = Local<Object>::Cast( 14832 Local<Object> hidden_global = Local<Object>::Cast(
14816 context->Global()->GetPrototype()); 14833 context->Global()->GetPrototype());
14817 context->DetachGlobal(); 14834 context->DetachGlobal();
14818 hidden_global->TurnOnAccessCheck(); 14835 hidden_global->TurnOnAccessCheck();
14819 14836
14820 // Failing access check to property get results in undefined. 14837 // Failing access check results in exception.
14821 CHECK(f1->Call(global, 0, NULL)->IsUndefined()); 14838 CHECK(f1->Call(global, 0, NULL).IsEmpty());
14822 CHECK(f2->Call(global, 0, NULL)->IsUndefined()); 14839 CHECK(f2->Call(global, 0, NULL).IsEmpty());
14823
14824 // Failing access check to function call results in exception.
14825 CHECK(g1->Call(global, 0, NULL).IsEmpty()); 14840 CHECK(g1->Call(global, 0, NULL).IsEmpty());
14826 CHECK(g2->Call(global, 0, NULL).IsEmpty()); 14841 CHECK(g2->Call(global, 0, NULL).IsEmpty());
14827 14842
14828 // No failing access check when just returning a constant. 14843 // No failing access check when just returning a constant.
14829 CHECK(h->Call(global, 0, NULL)->Equals(v8_num(1))); 14844 CHECK(h->Call(global, 0, NULL)->Equals(v8_num(1)));
14830 14845
14831 // Now compile the source again. And get the newly compiled functions, except 14846 // Now compile the source again. And get the newly compiled functions, except
14832 // for h for which access is blocked. 14847 // for h for which access is blocked.
14833 CompileRun(source); 14848 CompileRun(source);
14834 f1 = Local<Function>::Cast(hidden_global->Get(v8_str("f1"))); 14849 f1 = Local<Function>::Cast(hidden_global->Get(v8_str("f1")));
14835 f2 = Local<Function>::Cast(hidden_global->Get(v8_str("f2"))); 14850 f2 = Local<Function>::Cast(hidden_global->Get(v8_str("f2")));
14836 g1 = Local<Function>::Cast(hidden_global->Get(v8_str("g1"))); 14851 g1 = Local<Function>::Cast(hidden_global->Get(v8_str("g1")));
14837 g2 = Local<Function>::Cast(hidden_global->Get(v8_str("g2"))); 14852 g2 = Local<Function>::Cast(hidden_global->Get(v8_str("g2")));
14838 CHECK(hidden_global->Get(v8_str("h"))->IsUndefined()); 14853 CHECK(hidden_global->Get(v8_str("h")).IsEmpty());
14839 14854
14840 // Failing access check to property get results in undefined. 14855 // Failing access check results in exception.
14841 CHECK(f1->Call(global, 0, NULL)->IsUndefined()); 14856 v8::Local<v8::Value> result = f1->Call(global, 0, NULL);
14842 CHECK(f2->Call(global, 0, NULL)->IsUndefined()); 14857 CHECK(result.IsEmpty());
14843 14858 CHECK(f1->Call(global, 0, NULL).IsEmpty());
14844 // Failing access check to function call results in exception. 14859 CHECK(f2->Call(global, 0, NULL).IsEmpty());
14845 CHECK(g1->Call(global, 0, NULL).IsEmpty()); 14860 CHECK(g1->Call(global, 0, NULL).IsEmpty());
14846 CHECK(g2->Call(global, 0, NULL).IsEmpty()); 14861 CHECK(g2->Call(global, 0, NULL).IsEmpty());
14847 } 14862 }
14848 14863
14849 14864
14850 // Tests that ScriptData can be serialized and deserialized. 14865 // Tests that ScriptData can be serialized and deserialized.
14851 TEST(PreCompileSerialization) { 14866 TEST(PreCompileSerialization) {
14852 v8::V8::Initialize(); 14867 v8::V8::Initialize();
14853 LocalContext env; 14868 LocalContext env;
14854 v8::Isolate* isolate = env->GetIsolate(); 14869 v8::Isolate* isolate = env->GetIsolate();
(...skipping 5502 matching lines...) Expand 10 before | Expand all | Expand 10 after
20357 global_template->Set(v8_str("proxy"), proxy_object); 20372 global_template->Set(v8_str("proxy"), proxy_object);
20358 global_template->Set(v8_str("hidden"), object_with_hidden); 20373 global_template->Set(v8_str("hidden"), object_with_hidden);
20359 global_template->Set(v8_str("phidden"), object_with_protected_hidden); 20374 global_template->Set(v8_str("phidden"), object_with_protected_hidden);
20360 20375
20361 LocalContext context2(NULL, global_template); 20376 LocalContext context2(NULL, global_template);
20362 20377
20363 Local<Value> result1 = CompileRun("Object.getPrototypeOf(simple)"); 20378 Local<Value> result1 = CompileRun("Object.getPrototypeOf(simple)");
20364 CHECK(result1->Equals(simple_object->GetPrototype())); 20379 CHECK(result1->Equals(simple_object->GetPrototype()));
20365 20380
20366 Local<Value> result2 = CompileRun("Object.getPrototypeOf(protected)"); 20381 Local<Value> result2 = CompileRun("Object.getPrototypeOf(protected)");
20367 CHECK(result2->Equals(Undefined(isolate))); 20382 CHECK(result2.IsEmpty());
20368 20383
20369 Local<Value> result3 = CompileRun("Object.getPrototypeOf(global)"); 20384 Local<Value> result3 = CompileRun("Object.getPrototypeOf(global)");
20370 CHECK(result3->Equals(global_object->GetPrototype())); 20385 CHECK(result3->Equals(global_object->GetPrototype()));
20371 20386
20372 Local<Value> result4 = CompileRun("Object.getPrototypeOf(proxy)"); 20387 Local<Value> result4 = CompileRun("Object.getPrototypeOf(proxy)");
20373 CHECK(result4->Equals(Undefined(isolate))); 20388 CHECK(result4.IsEmpty());
20374 20389
20375 Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)"); 20390 Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)");
20376 CHECK(result5->Equals( 20391 CHECK(result5->Equals(
20377 object_with_hidden->GetPrototype()->ToObject()->GetPrototype())); 20392 object_with_hidden->GetPrototype()->ToObject()->GetPrototype()));
20378 20393
20379 Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)"); 20394 Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)");
20380 CHECK(result6->Equals(Undefined(isolate))); 20395 CHECK(result6.IsEmpty());
20381 } 20396 }
20382 20397
20383 20398
20384 THREADED_TEST(Regress125988) { 20399 THREADED_TEST(Regress125988) {
20385 v8::HandleScope scope(CcTest::isolate()); 20400 v8::HandleScope scope(CcTest::isolate());
20386 Handle<FunctionTemplate> intercept = FunctionTemplate::New(CcTest::isolate()); 20401 Handle<FunctionTemplate> intercept = FunctionTemplate::New(CcTest::isolate());
20387 AddInterceptor(intercept, EmptyInterceptorGetter, EmptyInterceptorSetter); 20402 AddInterceptor(intercept, EmptyInterceptorGetter, EmptyInterceptorSetter);
20388 LocalContext env; 20403 LocalContext env;
20389 env->Global()->Set(v8_str("Intercept"), intercept->GetFunction()); 20404 env->Global()->Set(v8_str("Intercept"), intercept->GetFunction());
20390 CompileRun("var a = new Object();" 20405 CompileRun("var a = new Object();"
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after
21565 v8::Handle<v8::FunctionTemplate> toJSON = 21580 v8::Handle<v8::FunctionTemplate> toJSON =
21566 v8::FunctionTemplate::New(isolate, UnreachableCallback); 21581 v8::FunctionTemplate::New(isolate, UnreachableCallback);
21567 21582
21568 global0->Set(v8_str("toJSON"), toJSON->GetFunction()); 21583 global0->Set(v8_str("toJSON"), toJSON->GetFunction());
21569 } 21584 }
21570 // Create a context with a different security token so that the 21585 // Create a context with a different security token so that the
21571 // failed access check callback will be called on each access. 21586 // failed access check callback will be called on each access.
21572 LocalContext context1(NULL, global_template); 21587 LocalContext context1(NULL, global_template);
21573 context1->Global()->Set(v8_str("other"), global0); 21588 context1->Global()->Set(v8_str("other"), global0);
21574 21589
21575 ExpectString("JSON.stringify(other)", "{}"); 21590 CHECK(CompileRun("JSON.stringify(other)").IsEmpty());
21576 ExpectString("JSON.stringify({ 'a' : other, 'b' : ['c'] })", 21591 CHECK(CompileRun("JSON.stringify({ 'a' : other, 'b' : ['c'] })").IsEmpty());
21577 "{\"a\":{},\"b\":[\"c\"]}"); 21592 CHECK(CompileRun("JSON.stringify([other, 'b', 'c'])").IsEmpty());
21578 ExpectString("JSON.stringify([other, 'b', 'c'])",
21579 "[{},\"b\",\"c\"]");
21580 21593
21581 v8::Handle<v8::Array> array = v8::Array::New(isolate, 2); 21594 v8::Handle<v8::Array> array = v8::Array::New(isolate, 2);
21582 array->Set(0, v8_str("a")); 21595 array->Set(0, v8_str("a"));
21583 array->Set(1, v8_str("b")); 21596 array->Set(1, v8_str("b"));
21584 context1->Global()->Set(v8_str("array"), array); 21597 context1->Global()->Set(v8_str("array"), array);
21585 ExpectString("JSON.stringify(array)", "[\"a\",\"b\"]"); 21598 ExpectString("JSON.stringify(array)", "[\"a\",\"b\"]");
21586 array->TurnOnAccessCheck(); 21599 array->TurnOnAccessCheck();
21587 ExpectString("JSON.stringify(array)", "[]"); 21600 CHECK(CompileRun("JSON.stringify(array)").IsEmpty());
21588 ExpectString("JSON.stringify([array])", "[[]]"); 21601 CHECK(CompileRun("JSON.stringify([array])").IsEmpty());
21589 ExpectString("JSON.stringify({'a' : array})", "{\"a\":[]}"); 21602 CHECK(CompileRun("JSON.stringify({'a' : array})").IsEmpty());
21590 } 21603 }
21591 } 21604 }
21592 21605
21593 21606
21594 bool access_check_fail_thrown = false; 21607 bool access_check_fail_thrown = false;
21595 bool catch_callback_called = false; 21608 bool catch_callback_called = false;
21596 21609
21597 21610
21598 // Failed access check callback that performs a GC on each invocation. 21611 // Failed access check callback that performs a GC on each invocation.
21599 void FailedAccessCheckThrows(Local<v8::Object> target, 21612 void FailedAccessCheckThrows(Local<v8::Object> target,
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
22829 desc = x->GetOwnPropertyDescriptor(v8_str("p1")); 22842 desc = x->GetOwnPropertyDescriptor(v8_str("p1"));
22830 Local<Function> set = 22843 Local<Function> set =
22831 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set"))); 22844 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set")));
22832 Local<Function> get = 22845 Local<Function> get =
22833 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get"))); 22846 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get")));
22834 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL)); 22847 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL));
22835 Handle<Value> args[] = { v8_num(14) }; 22848 Handle<Value> args[] = { v8_num(14) };
22836 set->Call(x, 1, args); 22849 set->Call(x, 1, args);
22837 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL)); 22850 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL));
22838 } 22851 }
OLDNEW
« no previous file with comments | « src/mirror-debugger.js ('k') | tools/generate-runtime-tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698