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

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

Issue 306203002: Remove PROHIBITS_OVERWRITING as it is subsumed by non-configurable properties. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Restore include/v8.h declaration to avoid dependencies Created 6 years, 6 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/objects-inl.h ('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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 "}" 222 "}"
223 "result")); 223 "result"));
224 CHECK_EQ(80, array->Length()); 224 CHECK_EQ(80, array->Length());
225 for (int i = 0; i < 80; i++) { 225 for (int i = 0; i < 80; i++) {
226 v8::Handle<Value> entry = array->Get(v8::Integer::New(isolate, i)); 226 v8::Handle<Value> entry = array->Get(v8::Integer::New(isolate, i));
227 CHECK_EQ(v8::Integer::New(isolate, i/2), entry); 227 CHECK_EQ(v8::Integer::New(isolate, i/2), entry);
228 } 228 }
229 } 229 }
230 230
231 231
232 static void AccessorProhibitsOverwritingGetter(
233 Local<String> name,
234 const v8::PropertyCallbackInfo<v8::Value>& info) {
235 ApiTestFuzzer::Fuzz();
236 info.GetReturnValue().Set(true);
237 }
238
239
240 THREADED_TEST(AccessorProhibitsOverwriting) {
241 LocalContext context;
242 v8::Isolate* isolate = context->GetIsolate();
243 v8::HandleScope scope(isolate);
244 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
245 templ->SetAccessor(v8_str("x"),
246 AccessorProhibitsOverwritingGetter,
247 0,
248 v8::Handle<Value>(),
249 v8::PROHIBITS_OVERWRITING,
250 v8::ReadOnly);
251 Local<v8::Object> instance = templ->NewInstance();
252 context->Global()->Set(v8_str("obj"), instance);
253 Local<Value> value = CompileRun(
254 "obj.__defineGetter__('x', function() { return false; });"
255 "obj.x");
256 CHECK(value->BooleanValue());
257 value = CompileRun(
258 "var setter_called = false;"
259 "obj.__defineSetter__('x', function() { setter_called = true; });"
260 "obj.x = 42;"
261 "setter_called");
262 CHECK(!value->BooleanValue());
263 value = CompileRun(
264 "obj2 = {};"
265 "obj2.__proto__ = obj;"
266 "obj2.__defineGetter__('x', function() { return false; });"
267 "obj2.x");
268 CHECK(value->BooleanValue());
269 value = CompileRun(
270 "var setter_called = false;"
271 "obj2 = {};"
272 "obj2.__proto__ = obj;"
273 "obj2.__defineSetter__('x', function() { setter_called = true; });"
274 "obj2.x = 42;"
275 "setter_called");
276 CHECK(!value->BooleanValue());
277 }
278
279
280 template <int C> 232 template <int C>
281 static void HandleAllocatingGetter( 233 static void HandleAllocatingGetter(
282 Local<String> name, 234 Local<String> name,
283 const v8::PropertyCallbackInfo<v8::Value>& info) { 235 const v8::PropertyCallbackInfo<v8::Value>& info) {
284 ApiTestFuzzer::Fuzz(); 236 ApiTestFuzzer::Fuzz();
285 for (int i = 0; i < C; i++) 237 for (int i = 0; i < C; i++)
286 v8::String::NewFromUtf8(info.GetIsolate(), "foo"); 238 v8::String::NewFromUtf8(info.GetIsolate(), "foo");
287 info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "foo")); 239 info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "foo"));
288 } 240 }
289 241
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 "Object.defineProperty(this.__proto__, 'x', {" 570 "Object.defineProperty(this.__proto__, 'x', {"
619 " get : function() { return this; }," 571 " get : function() { return this; },"
620 " set : function() { set_value = this; }" 572 " set : function() { set_value = this; }"
621 "});" 573 "});"
622 "function getter() { return x; }" 574 "function getter() { return x; }"
623 "function setter() { x = 1; }" 575 "function setter() { x = 1; }"
624 "for (var i = 0; i < 4; i++) { getter(); setter(); }"); 576 "for (var i = 0; i < 4; i++) { getter(); setter(); }");
625 CHECK(v8::Utils::OpenHandle(*CompileRun("getter()"))->IsJSGlobalProxy()); 577 CHECK(v8::Utils::OpenHandle(*CompileRun("getter()"))->IsJSGlobalProxy());
626 CHECK(v8::Utils::OpenHandle(*CompileRun("set_value"))->IsJSGlobalProxy()); 578 CHECK(v8::Utils::OpenHandle(*CompileRun("set_value"))->IsJSGlobalProxy());
627 } 579 }
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698