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

Implement spec change in some Proxy traps

Pass test262 change in Proxy: defineProperty, deleteProperty, getOwnPropertyDescriptor.

Bug: v8:9228
Change-Id: Id9a2c8dcbfcf68ed2837eb6d5042abcbce7ab0ba
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1626474
Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61832}
parent be47fd1c
......@@ -171,6 +171,11 @@ namespace internal {
"'defineProperty' on proxy: trap returned truish for defining " \
"non-configurable property '%' which is either non-existent or " \
"configurable in the proxy target") \
T(ProxyDefinePropertyNonConfigurableWritable, \
"'defineProperty' on proxy: trap returned truish for defining " \
"non-configurable property '%' which cannot be non-writable, unless " \
"there exists a corresponding non-configurable, non-writable own " \
"property of the target object.") \
T(ProxyDefinePropertyNonExtensible, \
"'defineProperty' on proxy: trap returned truish for adding property '%' " \
" to the non-extensible proxy target") \
......@@ -180,6 +185,9 @@ namespace internal {
T(ProxyDeletePropertyNonConfigurable, \
"'deleteProperty' on proxy: trap returned truish for property '%' which " \
"is non-configurable in the proxy target") \
T(ProxyDeletePropertyNonExtensible, \
"'deleteProperty' on proxy: trap returned truish for property '%' but " \
"the proxy target is non-extensible") \
T(ProxyGetNonConfigurableData, \
"'get' on proxy: property '%' is a read-only and " \
"non-configurable data property on the proxy target but the proxy " \
......@@ -199,6 +207,10 @@ namespace internal {
"'getOwnPropertyDescriptor' on proxy: trap reported non-configurability " \
"for property '%' which is either non-existent or configurable in the " \
"proxy target") \
T(ProxyGetOwnPropertyDescriptorNonConfigurableWritable, \
"'getOwnPropertyDescriptor' on proxy: trap reported non-configurable " \
"and writable for property '%' which is non-configurable, non-writable " \
"in the proxy target") \
T(ProxyGetOwnPropertyDescriptorNonExtensible, \
"'getOwnPropertyDescriptor' on proxy: trap returned undefined for " \
"property '%' which exists in the non-extensible proxy target") \
......
......@@ -3070,11 +3070,23 @@ Maybe<bool> JSProxy::DeletePropertyOrElement(Handle<JSProxy> proxy,
Maybe<bool> owned =
JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc);
MAYBE_RETURN(owned, Nothing<bool>());
if (owned.FromJust() && !target_desc.configurable()) {
isolate->Throw(*factory->NewTypeError(
MessageTemplate::kProxyDeletePropertyNonConfigurable, name));
return Nothing<bool>();
if (owned.FromJust()) {
if (!target_desc.configurable()) {
isolate->Throw(*factory->NewTypeError(
MessageTemplate::kProxyDeletePropertyNonConfigurable, name));
return Nothing<bool>();
}
// 13. Let extensibleTarget be ? IsExtensible(target).
// 14. If extensibleTarget is false, throw a TypeError exception.
Maybe<bool> extensible = JSReceiver::IsExtensible(target);
MAYBE_RETURN(extensible, Nothing<bool>());
if (!extensible.FromJust()) {
isolate->Throw(*factory->NewTypeError(
MessageTemplate::kProxyDeletePropertyNonExtensible, name));
return Nothing<bool>();
}
}
return Just(true);
}
......@@ -3432,6 +3444,20 @@ Maybe<bool> JSProxy::DefineOwnProperty(Isolate* isolate, Handle<JSProxy> proxy,
MessageTemplate::kProxyDefinePropertyNonConfigurable, property_name));
return Nothing<bool>();
}
// 16c. If IsDataDescriptor(targetDesc) is true,
// targetDesc.[[Configurable]] is
// false, and targetDesc.[[Writable]] is true, then
if (PropertyDescriptor::IsDataDescriptor(&target_desc) &&
!target_desc.configurable() && target_desc.writable()) {
// 16c i. If Desc has a [[Writable]] field and Desc.[[Writable]] is false,
// throw a TypeError exception.
if (desc->has_writable() && !desc->writable()) {
isolate->Throw(*isolate->factory()->NewTypeError(
MessageTemplate::kProxyDefinePropertyNonConfigurableWritable,
property_name));
return Nothing<bool>();
}
}
}
// 17. Return true.
return Just(true);
......@@ -3583,6 +3609,18 @@ Maybe<bool> JSProxy::GetOwnPropertyDescriptor(Isolate* isolate,
name));
return Nothing<bool>();
}
// 17b. If resultDesc has a [[Writable]] field and resultDesc.[[Writable]]
// is false, then
if (desc->has_writable() && !desc->writable()) {
// 17b i. If targetDesc.[[Writable]] is true, throw a TypeError exception.
if (target_desc.writable()) {
isolate->Throw(*isolate->factory()->NewTypeError(
MessageTemplate::
kProxyGetOwnPropertyDescriptorNonConfigurableWritable,
name));
return Nothing<bool>();
}
}
}
// 18. Return resultDesc.
return Just(true);
......
......@@ -300,7 +300,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(18),
B(LdaConstant), U8(12),
B(Star), R(19),
......
......@@ -66,7 +66,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(13),
B(LdaConstant), U8(6),
B(Star), R(14),
......@@ -203,7 +203,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(14),
B(LdaConstant), U8(6),
B(Star), R(15),
......@@ -327,7 +327,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(15),
B(LdaConstant), U8(7),
B(Star), R(16),
......
......@@ -94,7 +94,7 @@ bytecodes: [
B(JumpIfNull), U8(86),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(17),
B(LdaConstant), U8(9),
B(Star), R(18),
......@@ -263,7 +263,7 @@ bytecodes: [
B(JumpIfNull), U8(86),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(17),
B(LdaConstant), U8(9),
B(Star), R(18),
......@@ -448,7 +448,7 @@ bytecodes: [
B(JumpIfNull), U8(86),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(17),
B(LdaConstant), U8(9),
B(Star), R(18),
......@@ -600,7 +600,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(14),
B(LdaConstant), U8(8),
B(Star), R(15),
......
......@@ -62,7 +62,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(12),
B(LdaConstant), U8(6),
B(Star), R(13),
......@@ -165,7 +165,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(13),
B(LdaConstant), U8(6),
B(Star), R(14),
......@@ -278,7 +278,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(12),
B(LdaConstant), U8(6),
B(Star), R(13),
......@@ -384,7 +384,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(12),
B(LdaConstant), U8(8),
B(Star), R(13),
......
......@@ -66,7 +66,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(14),
B(LdaConstant), U8(5),
B(Star), R(15),
......@@ -203,7 +203,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(15),
B(LdaConstant), U8(10),
B(Star), R(16),
......@@ -318,7 +318,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(13),
B(LdaConstant), U8(7),
B(Star), R(14),
......@@ -430,7 +430,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(16),
B(LdaConstant), U8(7),
B(Star), R(17),
......@@ -547,7 +547,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(15),
B(LdaConstant), U8(8),
B(Star), R(16),
......@@ -679,7 +679,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(14),
B(LdaConstant), U8(11),
B(Star), R(15),
......@@ -795,7 +795,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(16),
B(LdaConstant), U8(5),
B(Star), R(17),
......@@ -935,7 +935,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(15),
B(LdaConstant), U8(6),
B(Star), R(16),
......
......@@ -180,7 +180,7 @@ bytecodes: [
B(JumpIfNull), U8(50),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(155),
B(Wide), B(LdaSmi), I16(158),
B(Star), R(14),
B(LdaConstant), U8(12),
B(Star), R(15),
......
......@@ -93,11 +93,11 @@ assertEquals(undefined, Object.getOwnPropertyDescriptor(proxy, "nonexistent"));
// (Inv-4) "A property cannot be reported as existent, if it does not exist as
// an own property of the target object and the target object is not
// extensible."
var existent_desc = {value: "yes"};
var existent_desc = {value: "yes", writable: true};
handler.getOwnPropertyDescriptor = function() { return existent_desc; };
assertThrows('Object.getOwnPropertyDescriptor(proxy, "nonexistent")');
assertEquals(
{value: "yes", writable: false, enumerable: false, configurable: false},
{value: "yes", writable: true, enumerable: false, configurable: false},
Object.getOwnPropertyDescriptor(proxy, "configurable"));
// Checking individual bailout points in the implementation:
......
......@@ -517,11 +517,6 @@
# https://bugs.chromium.org/p/v8/issues/detail?id=9049
'language/comments/hashbang/use-strict': [SKIP],
# https://bugs.chromium.org/p/v8/issues/detail?id=9228
'built-ins/Proxy/defineProperty/targetdesc-not-configurable-writable-desc-not-writable': [FAIL],
'built-ins/Proxy/deleteProperty/targetdesc-is-configurable-target-is-not-extensible': [FAIL],
'built-ins/Proxy/getOwnPropertyDescriptor/resultdesc-is-not-configurable-not-writable-targetdesc-is-writable': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=9229
'language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage': [FAIL],
'language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-chained-usage': [FAIL],
......
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