Commit 55c33c01 authored by Z Nguyen-Huu's avatar Z Nguyen-Huu Committed by Commit Bot

Object.preventExtensions should return object even if object is proxy.

According to spec https://tc39.es/ecma262/#sec-object.preventextensions, the commit 8e0ef9b9 is missing the last step when object is proxy, it needs to return the object.
var proxy = new Proxy({}, {});
var object = Object.preventExtensions(proxy);
proxy === object; // should be true

Also, add mjsunit test.

Bug: v8:6664
Change-Id: Ic3688519539f8903ee0bc7e885905a86d195a4db
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1668443
Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com>
Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62393}
parent 6056c0dc
......@@ -34,7 +34,8 @@ namespace object {
const objectJSProxy = Cast<JSProxy>(objectJSReceiver)
otherwise return runtime::JSReceiverPreventExtensionsThrow(
objectJSReceiver);
return proxy::ProxyPreventExtensions(objectJSProxy, True);
const _status: Object = proxy::ProxyPreventExtensions(objectJSProxy, True);
return objectJSReceiver;
}
transitioning macro
......
......@@ -105,7 +105,7 @@
assertTrue(Object.isExtensible(target));
assertTrue(Object.isExtensible(proxy));
Object.preventExtensions(proxy);
assertSame(proxy, Object.preventExtensions(proxy));
assertFalse(Object.isExtensible(target));
assertFalse(Object.isExtensible(proxy));
})();
......@@ -119,7 +119,7 @@
assertTrue(Object.isExtensible(target));
assertTrue(Object.isExtensible(proxy));
Object.preventExtensions(proxy);
assertSame(proxy, Object.preventExtensions(proxy));
assertFalse(Object.isExtensible(target));
assertFalse(Object.isExtensible(proxy));
})();
......@@ -145,7 +145,7 @@
assertTrue(Object.isExtensible(proxy));
// Trap returns trueish but target is not extensible.
Object.preventExtensions(target);
assertSame(target, Object.preventExtensions(target));
assertThrows(() => { Object.isExtensible(proxy) }, TypeError);
})();
......@@ -158,7 +158,7 @@
var proxy = new Proxy(target, handler);
assertThrows(() => { Object.isExtensible(proxy) }, TypeError);
Object.preventExtensions(target);
assertSame(target, Object.preventExtensions(target));
assertFalse(Object.isExtensible(proxy));
})();
......@@ -171,7 +171,7 @@
var proxy = new Proxy(target, handler);
assertFalse(Reflect.preventExtensions(proxy));
Object.preventExtensions(target);
assertSame(target, Object.preventExtensions(target));
assertFalse(Reflect.preventExtensions(proxy));
assertThrows(() => { Object.preventExtensions(proxy) }, TypeError);
})();
......@@ -186,7 +186,7 @@
assertThrows(() => { Object.preventExtensions(proxy) }, TypeError);
// Trap returns trueish and target is not extensible.
Object.preventExtensions(target);
assertSame(target, Object.preventExtensions(target));
assertTrue(Reflect.preventExtensions(proxy));
})();
......@@ -194,7 +194,7 @@
(function () {
// Target is proxy
var object = {};
Object.preventExtensions(object);
assertSame(object, Object.preventExtensions(object));
var target = new Proxy(object, {});
var proxy = new Proxy(target, {});
assertFalse(Object.isExtensible(object));
......
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