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

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

Issue 139983003: Revert "Make Function.length and Function.name configurable properties." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 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/runtime.cc ('k') | test/mjsunit/harmony/object-observe.js » ('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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 "Object.defineProperty(this.__proto__, 'x', {" 617 "Object.defineProperty(this.__proto__, 'x', {"
618 " get : function() { return this; }," 618 " get : function() { return this; },"
619 " set : function() { set_value = this; }" 619 " set : function() { set_value = this; }"
620 "});" 620 "});"
621 "function getter() { return x; }" 621 "function getter() { return x; }"
622 "function setter() { x = 1; }" 622 "function setter() { x = 1; }"
623 "for (var i = 0; i < 4; i++) { getter(); setter(); }"); 623 "for (var i = 0; i < 4; i++) { getter(); setter(); }");
624 CHECK(v8::Utils::OpenHandle(*CompileRun("getter()"))->IsJSGlobalProxy()); 624 CHECK(v8::Utils::OpenHandle(*CompileRun("getter()"))->IsJSGlobalProxy());
625 CHECK(v8::Utils::OpenHandle(*CompileRun("set_value"))->IsJSGlobalProxy()); 625 CHECK(v8::Utils::OpenHandle(*CompileRun("set_value"))->IsJSGlobalProxy());
626 } 626 }
627
628
629 static i::MaybeObject* ZeroAccessorGet(i::Isolate*, i::Object*, void*) {
630 return i::Smi::FromInt(0);
631 }
632
633
634 static i::MaybeObject* ReadOnlySetAccessor(
635 i::Isolate* isolate, i::JSObject*, i::Object* value, void*) {
636 return value;
637 }
638
639
640 const i::AccessorDescriptor kCallbackDescriptor = {
641 ZeroAccessorGet,
642 ReadOnlySetAccessor,
643 0
644 };
645
646
647 THREADED_TEST(RedefineReadOnlyConfigurableForeignCallbackAccessor) {
648 // Verify that property redefinition over foreign callbacks-backed
649 // properties works as expected if the property is non-writable,
650 // but writable. Such a property can be redefined without first
651 // making the property writable (ES5.1 - 8.12.9.10.b)
652 // (bug 3045.)
653 LocalContext env;
654 v8::Isolate* isolate = env->GetIsolate();
655 i::Factory* factory = CcTest::i_isolate()->factory();
656
657 v8::HandleScope scope(isolate);
658
659 i::Handle<i::Map> map =
660 factory->NewMap(i::JS_OBJECT_TYPE, i::JSObject::kHeaderSize);
661 i::Handle<i::DescriptorArray> instance_descriptors(
662 map->instance_descriptors());
663 ASSERT(instance_descriptors->IsEmpty());
664
665 i::Handle<i::DescriptorArray> descriptors = factory->NewDescriptorArray(0, 1);
666 i::DescriptorArray::WhitenessWitness witness(*descriptors);
667 map->set_instance_descriptors(*descriptors);
668
669 i::Handle<i::Foreign> foreign = factory->NewForeign(&kCallbackDescriptor);
670 i::Handle<i::String> name =
671 factory->InternalizeUtf8String(i::Vector<const char>("prop", 4));
672
673 // Want a non-writable and configurable property.
674 PropertyAttributes attribs =
675 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY);
676 i::CallbacksDescriptor d(*name, *foreign, attribs);
677 map->AppendDescriptor(&d, witness);
678
679 i::Handle<i::Object> object = factory->NewJSObjectFromMap(map);
680
681 // Put the object on the global object.
682 env->Global()->Set(v8::String::NewFromUtf8(CcTest::isolate(), "Foreign"),
683 v8::Utils::ToLocal(object));
684
685 // ..and redefine the property through JavaScript, returning its value.
686 const char* script =
687 "Object.defineProperty(Foreign, 'prop', {value: 2}); Foreign.prop";
688 v8::Handle<v8::Value> result = v8::Script::Compile(
689 v8::String::NewFromUtf8(CcTest::isolate(), script))->Run();
690 CHECK_EQ(2, result->Int32Value());
691 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/harmony/object-observe.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698