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
This commit is contained in:
parent
c0ec8a64be
commit
00346bd1da
@ -7450,7 +7450,7 @@ bool JSFunction::IsInlineable() {
|
||||
|
||||
|
||||
MaybeObject* JSFunction::SetInstancePrototype(Object* value) {
|
||||
ASSERT(value->IsJSObject());
|
||||
ASSERT(value->IsJSReceiver());
|
||||
Heap* heap = GetHeap();
|
||||
if (has_initial_map()) {
|
||||
// If the function has allocated the initial map
|
||||
@ -7477,11 +7477,11 @@ MaybeObject* JSFunction::SetPrototype(Object* value) {
|
||||
ASSERT(should_have_prototype());
|
||||
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
|
||||
// used for constructing objects to the original object prototype.
|
||||
// See ECMA-262 13.2.2.
|
||||
if (!value->IsJSObject()) {
|
||||
if (!value->IsJSReceiver()) {
|
||||
// Copy the map so this does not affect unrelated functions.
|
||||
// Remove map transitions because they point to maps with a
|
||||
// different prototype.
|
||||
|
@ -2257,3 +2257,22 @@ TestIsEnumerableThrow(Proxy.create({
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user