Commit 00346bd1 authored by rossberg@chromium.org's avatar rossberg@chromium.org

Fix use of proxies as f.prototype properties.

R=mstarzinger@chromium.org
BUG=v8:2021
TEST=

Review URL: https://chromiumcodereview.appspot.com/9837008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11116 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c0ec8a64
...@@ -7450,7 +7450,7 @@ bool JSFunction::IsInlineable() { ...@@ -7450,7 +7450,7 @@ bool JSFunction::IsInlineable() {
MaybeObject* JSFunction::SetInstancePrototype(Object* value) { MaybeObject* JSFunction::SetInstancePrototype(Object* value) {
ASSERT(value->IsJSObject()); ASSERT(value->IsJSReceiver());
Heap* heap = GetHeap(); Heap* heap = GetHeap();
if (has_initial_map()) { if (has_initial_map()) {
// If the function has allocated the initial map // If the function has allocated the initial map
...@@ -7477,11 +7477,11 @@ MaybeObject* JSFunction::SetPrototype(Object* value) { ...@@ -7477,11 +7477,11 @@ MaybeObject* JSFunction::SetPrototype(Object* value) {
ASSERT(should_have_prototype()); ASSERT(should_have_prototype());
Object* construct_prototype = value; Object* construct_prototype = value;
// If the value is not a JSObject, store the value in the map's // If the value is not a JSReceiver, store the value in the map's
// constructor field so it can be accessed. Also, set the prototype // constructor field so it can be accessed. Also, set the prototype
// used for constructing objects to the original object prototype. // used for constructing objects to the original object prototype.
// See ECMA-262 13.2.2. // See ECMA-262 13.2.2.
if (!value->IsJSObject()) { if (!value->IsJSReceiver()) {
// Copy the map so this does not affect unrelated functions. // Copy the map so this does not affect unrelated functions.
// Remove map transitions because they point to maps with a // Remove map transitions because they point to maps with a
// different prototype. // different prototype.
......
...@@ -2257,3 +2257,22 @@ TestIsEnumerableThrow(Proxy.create({ ...@@ -2257,3 +2257,22 @@ TestIsEnumerableThrow(Proxy.create({
return function(k) { throw "myexn" } return function(k) { throw "myexn" }
} }
})) }))
// Constructor functions with proxy prototypes.
function TestConstructorWithProxyPrototype() {
TestWithProxies(TestConstructorWithProxyPrototype2, {})
}
function TestConstructorWithProxyPrototype2(create, handler) {
function C() {};
C.prototype = create(handler);
var o = new C;
assertSame(C.prototype, o.__proto__);
assertSame(C.prototype, Object.getPrototypeOf(o));
}
TestConstructorWithProxyPrototype();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment