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

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

Issue 1242123002: Fix GetOwnPropertyNames on access-checked objects (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Handle empty case Created 5 years, 5 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
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | no next file » | 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 8706 matching lines...) Expand 10 before | Expand all | Expand 10 after
8717 8717
8718 THREADED_TEST(AccessControlGetOwnPropertyNames) { 8718 THREADED_TEST(AccessControlGetOwnPropertyNames) {
8719 v8::Isolate* isolate = CcTest::isolate(); 8719 v8::Isolate* isolate = CcTest::isolate();
8720 v8::HandleScope handle_scope(isolate); 8720 v8::HandleScope handle_scope(isolate);
8721 v8::Handle<v8::ObjectTemplate> obj_template = 8721 v8::Handle<v8::ObjectTemplate> obj_template =
8722 v8::ObjectTemplate::New(isolate); 8722 v8::ObjectTemplate::New(isolate);
8723 8723
8724 obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42)); 8724 obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42));
8725 obj_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL); 8725 obj_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL);
8726 8726
8727 // Add an accessor accessible by cross-domain JS code.
8728 obj_template->SetAccessor(
8729 v8_str("accessible_prop"), EchoGetter, EchoSetter, v8::Handle<Value>(),
8730 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE));
8731
8727 // Create an environment 8732 // Create an environment
8728 v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template); 8733 v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template);
8729 context0->Enter(); 8734 context0->Enter();
8730 8735
8731 v8::Handle<v8::Object> global0 = context0->Global(); 8736 v8::Handle<v8::Object> global0 = context0->Global();
8732 8737
8733 v8::HandleScope scope1(CcTest::isolate()); 8738 v8::HandleScope scope1(CcTest::isolate());
8734 8739
8735 v8::Local<Context> context1 = Context::New(isolate); 8740 v8::Local<Context> context1 = Context::New(isolate);
8736 context1->Enter(); 8741 context1->Enter();
8737 8742
8738 v8::Handle<v8::Object> global1 = context1->Global(); 8743 v8::Handle<v8::Object> global1 = context1->Global();
8739 global1->Set(v8_str("other"), global0); 8744 global1->Set(v8_str("other"), global0);
8740 global1->Set(v8_str("object"), obj_template->NewInstance()); 8745 global1->Set(v8_str("object"), obj_template->NewInstance());
8741 8746
8742 v8::Handle<Value> value; 8747 v8::Handle<Value> value;
8743 8748
8744 // Attempt to get the property names of the other global object and 8749 // Attempt to get the property names of the other global object and
8745 // of an object that requires access checks. Accessing the other 8750 // of an object that requires access checks. Accessing the other
8746 // global object should be blocked by access checks on the global 8751 // global object should be blocked by access checks on the global
8747 // proxy object. Accessing the object that requires access checks 8752 // proxy object. Accessing the object that requires access checks
8748 // is blocked by the access checks on the object itself. 8753 // is blocked by the access checks on the object itself.
8749 value = CompileRun("Object.getOwnPropertyNames(other).length == 0"); 8754 value = CompileRun(
8750 CHECK(value.IsEmpty()); 8755 "var names = Object.getOwnPropertyNames(other);"
8756 "names.length == 1 && names[0] == 'accessible_prop';");
8757 CHECK(value->BooleanValue());
8751 8758
8752 value = CompileRun("Object.getOwnPropertyNames(object).length == 0"); 8759 value = CompileRun(
8753 CHECK(value.IsEmpty()); 8760 "var names = Object.getOwnPropertyNames(object);"
8761 "names.length == 1 && names[0] == 'accessible_prop';");
8762 CHECK(value->BooleanValue());
8754 8763
8755 context1->Exit(); 8764 context1->Exit();
8756 context0->Exit(); 8765 context0->Exit();
8757 } 8766 }
8758 8767
8759 8768
8760 TEST(SuperAccessControl) { 8769 TEST(SuperAccessControl) {
8761 i::FLAG_allow_natives_syntax = true; 8770 i::FLAG_allow_natives_syntax = true;
8762 v8::Isolate* isolate = CcTest::isolate(); 8771 v8::Isolate* isolate = CcTest::isolate();
8763 v8::HandleScope handle_scope(isolate); 8772 v8::HandleScope handle_scope(isolate);
(...skipping 10593 matching lines...) Expand 10 before | Expand all | Expand 10 after
19357 CheckCorrectThrow("%SetProperty(other, 'x', 'foo', 0)"); 19366 CheckCorrectThrow("%SetProperty(other, 'x', 'foo', 0)");
19358 CheckCorrectThrow("%AddNamedProperty(other, 'x', 'foo', 1)"); 19367 CheckCorrectThrow("%AddNamedProperty(other, 'x', 'foo', 1)");
19359 CheckCorrectThrow("%DeleteProperty(other, 'x', 0)"); 19368 CheckCorrectThrow("%DeleteProperty(other, 'x', 0)");
19360 CheckCorrectThrow("%DeleteProperty(other, '1', 0)"); 19369 CheckCorrectThrow("%DeleteProperty(other, '1', 0)");
19361 CheckCorrectThrow("%HasOwnProperty(other, 'x')"); 19370 CheckCorrectThrow("%HasOwnProperty(other, 'x')");
19362 CheckCorrectThrow("%HasProperty(other, 'x')"); 19371 CheckCorrectThrow("%HasProperty(other, 'x')");
19363 CheckCorrectThrow("%HasElement(other, 1)"); 19372 CheckCorrectThrow("%HasElement(other, 1)");
19364 CheckCorrectThrow("%IsPropertyEnumerable(other, 'x')"); 19373 CheckCorrectThrow("%IsPropertyEnumerable(other, 'x')");
19365 CheckCorrectThrow("%GetPropertyNames(other)"); 19374 CheckCorrectThrow("%GetPropertyNames(other)");
19366 // PROPERTY_ATTRIBUTES_NONE = 0 19375 // PROPERTY_ATTRIBUTES_NONE = 0
19367 CheckCorrectThrow("%GetOwnPropertyNames(other, 0)");
19368 CheckCorrectThrow("%DefineAccessorPropertyUnchecked(" 19376 CheckCorrectThrow("%DefineAccessorPropertyUnchecked("
19369 "other, 'x', null, null, 1)"); 19377 "other, 'x', null, null, 1)");
19370 19378
19371 // Reset the failed access check callback so it does not influence 19379 // Reset the failed access check callback so it does not influence
19372 // the other tests. 19380 // the other tests.
19373 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); 19381 v8::V8::SetFailedAccessCheckCallbackFunction(NULL);
19374 } 19382 }
19375 19383
19376 19384
19377 class RequestInterruptTestBase { 19385 class RequestInterruptTestBase {
(...skipping 2459 matching lines...) Expand 10 before | Expand all | Expand 10 after
21837 " fake.age;\n" 21845 " fake.age;\n"
21838 " result = 1;\n" 21846 " result = 1;\n"
21839 " } catch (e) {\n" 21847 " } catch (e) {\n"
21840 " }\n" 21848 " }\n"
21841 " test(d+1);\n" 21849 " test(d+1);\n"
21842 "}\n" 21850 "}\n"
21843 "test(0);\n" 21851 "test(0);\n"
21844 "result;\n", 21852 "result;\n",
21845 0); 21853 0);
21846 } 21854 }
OLDNEW
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698