Update proxy to ES2020 (#4085)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
This commit is contained in:
@@ -806,6 +806,7 @@ ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p, /**< proxy
|
||||
is_extensible);
|
||||
|
||||
bool target_has_desc = ecma_is_value_true (target_status);
|
||||
bool target_is_writable = (target_desc.flags & ECMA_PROP_IS_WRITABLE) ;
|
||||
bool target_is_configurable = false;
|
||||
|
||||
if (target_has_desc)
|
||||
@@ -829,6 +830,14 @@ ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p, /**< proxy
|
||||
ecma_free_property_descriptor (prop_desc_p);
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Not compatible."));
|
||||
}
|
||||
|
||||
/* ES11: 17.b */
|
||||
if ((prop_desc_p->flags & (ECMA_PROP_IS_WRITABLE_DEFINED | ECMA_PROP_IS_WRITABLE)) == ECMA_PROP_IS_WRITABLE_DEFINED
|
||||
&& target_is_writable)
|
||||
{
|
||||
ecma_free_property_descriptor (prop_desc_p);
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Not compatible."));
|
||||
}
|
||||
}
|
||||
return ECMA_VALUE_TRUE;
|
||||
} /* ecma_proxy_object_get_own_property_descriptor */
|
||||
@@ -967,6 +976,16 @@ ecma_proxy_object_define_own_property (ecma_object_t *obj_p, /**< proxy object *
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for defining non-configurable property "
|
||||
"which is configurable in the target"));
|
||||
}
|
||||
/* ES11: 16.c */
|
||||
else if ((target_desc.flags & (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_IS_WRITABLE_DEFINED)) != 0
|
||||
&& (prop_desc_p->flags & (ECMA_PROP_IS_WRITABLE_DEFINED | ECMA_PROP_IS_WRITABLE))
|
||||
== ECMA_PROP_IS_WRITABLE_DEFINED
|
||||
&& (target_desc.flags & (ECMA_PROP_IS_WRITABLE | ECMA_PROP_IS_CONFIGURABLE)) == ECMA_PROP_IS_WRITABLE)
|
||||
|
||||
{
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for defining non-configurable property "
|
||||
"which is configurable in the target"));
|
||||
}
|
||||
|
||||
ecma_free_property_descriptor (&target_desc);
|
||||
|
||||
@@ -1389,6 +1408,13 @@ ecma_proxy_object_delete_property (ecma_object_t *obj_p, /**< proxy object */
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for property which is "
|
||||
"non-configurable in the proxy target."));
|
||||
}
|
||||
/* ES11: 13-14 */
|
||||
ecma_value_t extensible_target = ecma_builtin_object_object_is_extensible (target_obj_p);
|
||||
|
||||
if (!ecma_is_value_true (extensible_target))
|
||||
{
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for target is not extensible"));
|
||||
}
|
||||
|
||||
ecma_free_property_descriptor (&target_desc);
|
||||
|
||||
|
||||
@@ -174,3 +174,27 @@ try {
|
||||
} catch (e) {
|
||||
assert(e instanceof TypeError);
|
||||
}
|
||||
|
||||
var trapCalls = 0;
|
||||
var p = new Proxy({}, {
|
||||
defineProperty: function(t, prop, desc) {
|
||||
Object.defineProperty(t, prop, {
|
||||
configurable: false,
|
||||
writable: true,
|
||||
});
|
||||
|
||||
trapCalls++;
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
Reflect.defineProperty (p, "prop", {
|
||||
writable: false,
|
||||
});
|
||||
assert (false);
|
||||
} catch (e) {
|
||||
assert (e instanceof TypeError);
|
||||
}
|
||||
|
||||
assert (trapCalls == 1)
|
||||
|
||||
@@ -162,3 +162,21 @@ try {
|
||||
} catch (e) {
|
||||
assert(e instanceof TypeError);
|
||||
}
|
||||
|
||||
var trapCalls = 0;
|
||||
var p = new Proxy({prop: 1}, {
|
||||
deleteProperty: function(t, prop) {
|
||||
Object.preventExtensions(t);
|
||||
trapCalls++;
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
Reflect.deleteProperty (p, "prop");
|
||||
assert (false);
|
||||
} catch (e) {
|
||||
assert (e instanceof TypeError);
|
||||
}
|
||||
|
||||
assert (trapCalls == 1);
|
||||
|
||||
@@ -282,3 +282,30 @@ Object.assign({}, proxy);
|
||||
assert(result.length === 2);
|
||||
assert(result[0] === "foo");
|
||||
assert(result[1] === "bar");
|
||||
|
||||
|
||||
var trapCalls = 0;
|
||||
var p = new Proxy({}, {
|
||||
getOwnPropertyDescriptor: function(t, prop) {
|
||||
Object.defineProperty(t, prop, {
|
||||
configurable: false,
|
||||
writable: true,
|
||||
});
|
||||
|
||||
trapCalls++;
|
||||
return {
|
||||
configurable: false,
|
||||
writable: false,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
Object.getOwnPropertyDescriptor(p, "prop");
|
||||
assert (false)
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
assert(e instanceof TypeError)
|
||||
}
|
||||
|
||||
@@ -1341,12 +1341,10 @@
|
||||
<test id="built-ins/Proxy/defineProperty/targetdesc-configurable-desc-not-configurable-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/defineProperty/targetdesc-not-compatible-descriptor-not-configurable-target-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/defineProperty/targetdesc-not-compatible-descriptor-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/defineProperty/targetdesc-not-configurable-writable-desc-not-writable.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/defineProperty/targetdesc-undefined-not-configurable-descriptor-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/defineProperty/targetdesc-undefined-target-is-not-extensible-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/defineProperty/trap-is-not-callable-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/defineProperty/trap-is-undefined-target-is-proxy.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/deleteProperty/targetdesc-is-configurable-target-is-not-extensible.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/deleteProperty/trap-is-missing-target-is-proxy.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/deleteProperty/trap-is-not-callable-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/deleteProperty/trap-is-null-target-is-proxy.js"><reason></reason></test>
|
||||
@@ -1355,7 +1353,6 @@
|
||||
<test id="built-ins/Proxy/get-fn-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/get/trap-is-not-callable-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/getOwnPropertyDescriptor/result-type-is-not-object-nor-undefined-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/getOwnPropertyDescriptor/resultdesc-is-not-configurable-not-writable-targetdesc-is-writable.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/getOwnPropertyDescriptor/trap-is-not-callable-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/getPrototypeOf/trap-is-not-callable-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/has/trap-is-not-callable-realm.js"><reason></reason></test>
|
||||
|
||||
Reference in New Issue
Block a user