@@ -1699,6 +1699,7 @@ namespace Js
1699
1699
1700
1700
BOOL JavascriptProxy::DefineOwnPropertyDescriptor (RecyclableObject* obj, PropertyId propId, const PropertyDescriptor& descriptor, bool throwOnError, ScriptContext* requestContext)
1701
1701
{
1702
+ // #sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc
1702
1703
PROBE_STACK (requestContext, Js::Constants::MinStackDefault);
1703
1704
1704
1705
// Reject implicit call
@@ -1712,10 +1713,11 @@ namespace Js
1712
1713
JavascriptProxy* proxy = JavascriptProxy::FromVar (obj);
1713
1714
1714
1715
// 1. Assert: IsPropertyKey(P) is true.
1715
- // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O .
1716
+ // 2. Let handler be O. [[ProxyHandler]].
1716
1717
RecyclableObject *handlerObj = proxy->MarshalHandler (requestContext);
1717
1718
1718
1719
// 3. If handler is null, then throw a TypeError exception.
1720
+ // 4. Assert: Type(handler) is Object.
1719
1721
if (handlerObj == nullptr )
1720
1722
{
1721
1723
// the proxy has been revoked; TypeError.
@@ -1724,13 +1726,12 @@ namespace Js
1724
1726
JavascriptError::ThrowTypeError (requestContext, JSERR_ErrorOnRevokedProxy, _u (" definePropertyDescriptor" ));
1725
1727
}
1726
1728
1727
- // 4 . Let target be the value of the [[ProxyTarget]] internal slot of O .
1729
+ // 5 . Let target be O. [[ProxyTarget]].
1728
1730
RecyclableObject *targetObj = proxy->MarshalTarget (requestContext);
1729
1731
1730
- // 5. Let trap be the result of GetMethod(handler, "defineProperty").
1731
- // 6. ReturnIfAbrupt(trap).
1732
+ // 6. Let trap be ? GetMethod(handler, "defineProperty").
1732
1733
// 7. If trap is undefined, then
1733
- // a.Return the result of calling the [[DefineOwnProperty]] internal method of target with arguments P and Desc.
1734
+ // a. Return ? target. [[DefineOwnProperty]](P, Desc) .
1734
1735
JavascriptFunction* defineOwnPropertyMethod = proxy->GetMethodHelper (PropertyIds::defineProperty, requestContext);
1735
1736
1736
1737
Assert (!requestContext->IsHeapEnumInProgress ());
@@ -1740,18 +1741,10 @@ namespace Js
1740
1741
}
1741
1742
1742
1743
// 8. Let descObj be FromPropertyDescriptor(Desc).
1743
- // 9. NOTE If Desc was originally generated from an object using ToPropertyDescriptor, then descObj will be that original object.
1744
- // 10. Let trapResult be the result of calling the[[Call]] internal method of trap with handler as the this value and a new List containing target, P, and descObj.
1745
- // 11. Let booleanTrapResult be ToBoolean(trapResult).
1746
- // 12. ReturnIfAbrupt(booleanTrapResult).
1747
- // 13. If booleanTrapResult is false, then return false.
1748
- // 14. Let targetDesc be the result of calling the[[GetOwnProperty]] internal method of target with argument P.
1749
- // 15. ReturnIfAbrupt(targetDesc).
1750
- Var descVar = descriptor.GetOriginal ();
1751
- if (descVar == nullptr )
1752
- {
1753
- descVar = JavascriptOperators::FromPropertyDescriptor (descriptor, requestContext);
1754
- }
1744
+ // 9. Let booleanTrapResult be ToBoolean(? Call(trap, handler, << target, P, descObj >> )).
1745
+ // 10. If booleanTrapResult is false, then return false.
1746
+ // 11. Let targetDesc be ? target.[[GetOwnProperty]](P).
1747
+ Var descVar = JavascriptOperators::FromPropertyDescriptor (descriptor, requestContext);
1755
1748
1756
1749
Var propertyName = GetName (requestContext, propId);
1757
1750
@@ -1766,18 +1759,17 @@ namespace Js
1766
1759
return defineResult;
1767
1760
}
1768
1761
1769
- // 16. Let extensibleTarget be the result of IsExtensible(target).
1770
- // 17. ReturnIfAbrupt(extensibleTarget).
1771
- // 18. If Desc has a[[Configurable]] field and if Desc.[[Configurable]] is false, then
1762
+ // 12. Let extensibleTarget be ? IsExtensible(target).
1763
+ // 13. If Desc has a[[Configurable]] field and if Desc.[[Configurable]] is false, then
1772
1764
// a.Let settingConfigFalse be true.
1773
- // 19 . Else let settingConfigFalse be false.
1774
- // 20 . If targetDesc is undefined, then
1765
+ // 14 . Else let settingConfigFalse be false.
1766
+ // 15 . If targetDesc is undefined, then
1775
1767
// a.If extensibleTarget is false, then throw a TypeError exception.
1776
1768
// b.If settingConfigFalse is true, then throw a TypeError exception.
1777
- // 21 . Else targetDesc is not undefined,
1769
+ // 16 . Else targetDesc is not undefined,
1778
1770
// a.If IsCompatiblePropertyDescriptor(extensibleTarget, Desc, targetDesc) is false, then throw a TypeError exception.
1779
1771
// b.If settingConfigFalse is true and targetDesc.[[Configurable]] is true, then throw a TypeError exception.
1780
- // 22 . Return true.
1772
+ // 17 . Return true.
1781
1773
PropertyDescriptor targetDescriptor;
1782
1774
BOOL hasProperty = JavascriptOperators::GetOwnPropertyDescriptor (targetObj, propId, requestContext, &targetDescriptor);
1783
1775
BOOL isExtensible = targetObj->IsExtensible ();
0 commit comments