OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 5057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5068 int elmc1 = 2; | 5068 int elmc1 = 2; |
5069 const char* elmv1[] = {"a", "b"}; | 5069 const char* elmv1[] = {"a", "b"}; |
5070 CheckProperties(elms->Get(v8::Integer::New(1)), elmc1, elmv1); | 5070 CheckProperties(elms->Get(v8::Integer::New(1)), elmc1, elmv1); |
5071 int elmc2 = 3; | 5071 int elmc2 = 3; |
5072 const char* elmv2[] = {"0", "1", "2"}; | 5072 const char* elmv2[] = {"0", "1", "2"}; |
5073 CheckProperties(elms->Get(v8::Integer::New(2)), elmc2, elmv2); | 5073 CheckProperties(elms->Get(v8::Integer::New(2)), elmc2, elmv2); |
5074 int elmc3 = 4; | 5074 int elmc3 = 4; |
5075 const char* elmv3[] = {"w", "z", "x", "y"}; | 5075 const char* elmv3[] = {"w", "z", "x", "y"}; |
5076 CheckProperties(elms->Get(v8::Integer::New(3)), elmc3, elmv3); | 5076 CheckProperties(elms->Get(v8::Integer::New(3)), elmc3, elmv3); |
5077 } | 5077 } |
| 5078 |
| 5079 |
| 5080 static v8::Handle<Value> AccessorProhibitsOverwritingGetter( |
| 5081 Local<String> name, |
| 5082 const AccessorInfo& info) { |
| 5083 ApiTestFuzzer::Fuzz(); |
| 5084 return v8::True(); |
| 5085 } |
| 5086 |
| 5087 |
| 5088 THREADED_TEST(AccessorProhibitsOverwriting) { |
| 5089 v8::HandleScope scope; |
| 5090 LocalContext context; |
| 5091 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5092 templ->SetAccessor(v8_str("x"), |
| 5093 AccessorProhibitsOverwritingGetter, |
| 5094 0, |
| 5095 v8::Handle<Value>(), |
| 5096 v8::PROHIBITS_OVERWRITING, |
| 5097 v8::ReadOnly); |
| 5098 Local<v8::Object> instance = templ->NewInstance(); |
| 5099 context->Global()->Set(v8_str("obj"), instance); |
| 5100 Local<Value> value = CompileRun( |
| 5101 "obj.__defineGetter__('x', function() { return false; });" |
| 5102 "obj.x"); |
| 5103 CHECK(value->BooleanValue()); |
| 5104 value = CompileRun( |
| 5105 "var setter_called = false;" |
| 5106 "obj.__defineSetter__('x', function() { setter_called = true; });" |
| 5107 "obj.x = 42;" |
| 5108 "setter_called"); |
| 5109 CHECK(!value->BooleanValue()); |
| 5110 value = CompileRun( |
| 5111 "obj2 = {};" |
| 5112 "obj2.__proto__ = obj;" |
| 5113 "obj2.__defineGetter__('x', function() { return false; });" |
| 5114 "obj2.x"); |
| 5115 CHECK(value->BooleanValue()); |
| 5116 value = CompileRun( |
| 5117 "var setter_called = false;" |
| 5118 "obj2 = {};" |
| 5119 "obj2.__proto__ = obj;" |
| 5120 "obj2.__defineSetter__('x', function() { setter_called = true; });" |
| 5121 "obj2.x = 42;" |
| 5122 "setter_called"); |
| 5123 CHECK(!value->BooleanValue()); |
| 5124 } |
| 5125 |
| 5126 |
| 5127 static bool NamedSetAccessBlocker(Local<v8::Object> obj, |
| 5128 Local<Value> name, |
| 5129 v8::AccessType type, |
| 5130 Local<Value> data) { |
| 5131 return type != v8::ACCESS_SET; |
| 5132 } |
| 5133 |
| 5134 |
| 5135 static bool IndexedSetAccessBlocker(Local<v8::Object> obj, |
| 5136 uint32_t key, |
| 5137 v8::AccessType type, |
| 5138 Local<Value> data) { |
| 5139 return type != v8::ACCESS_SET; |
| 5140 } |
| 5141 |
| 5142 |
| 5143 THREADED_TEST(DisableAccessChecksWhileConfiguring) { |
| 5144 v8::HandleScope scope; |
| 5145 LocalContext context; |
| 5146 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5147 templ->SetAccessCheckCallbacks(NamedSetAccessBlocker, |
| 5148 IndexedSetAccessBlocker); |
| 5149 templ->Set(v8_str("x"), v8::True()); |
| 5150 Local<v8::Object> instance = templ->NewInstance(); |
| 5151 context->Global()->Set(v8_str("obj"), instance); |
| 5152 Local<Value> value = CompileRun("obj.x"); |
| 5153 CHECK(value->BooleanValue()); |
| 5154 } |
OLD | NEW |