@@ -195,8 +195,8 @@ namespace Js
195
195
target = nullptr ;
196
196
}
197
197
198
- template <class Fn , class GetPropertyIdFunc >
199
- BOOL JavascriptProxy::GetPropertyDescriptorTrap (Var originalInstance, Fn fn, GetPropertyIdFunc getPropertyId , PropertyDescriptor* resultDescriptor, ScriptContext* requestContext)
198
+ template <class Fn >
199
+ BOOL JavascriptProxy::GetPropertyDescriptorTrap (Var originalInstance, Fn fn, PropertyId propertyId , PropertyDescriptor* resultDescriptor, ScriptContext* requestContext)
200
200
{
201
201
PROBE_STACK (GetScriptContext (), Js::Constants::MinStackDefault);
202
202
@@ -233,7 +233,6 @@ namespace Js
233
233
return fn (targetObj);
234
234
}
235
235
236
- PropertyId propertyId = getPropertyId ();
237
236
Var propertyName = GetName (requestContext, propertyId);
238
237
239
238
Assert (JavascriptString::Is (propertyName) || JavascriptSymbol::Is (propertyName));
@@ -254,9 +253,8 @@ namespace Js
254
253
// 11. Let targetDesc be the result of calling the[[GetOwnProperty]] internal method of target with argument P.
255
254
// 12. ReturnIfAbrupt(targetDesc).
256
255
PropertyDescriptor targetDescriptor;
257
- BOOL hasProperty;
256
+ BOOL hasProperty = JavascriptOperators::GetOwnPropertyDescriptor (targetObj, propertyId, requestContext, &targetDescriptor) ;
258
257
259
- hasProperty = JavascriptOperators::GetOwnPropertyDescriptor (targetObj, getPropertyId (), requestContext, &targetDescriptor);
260
258
// 13. If trapResultObj is undefined, then
261
259
// a.If targetDesc is undefined, then return undefined.
262
260
// b.If targetDesc.[[Configurable]] is false, then throw a TypeError exception.
@@ -274,7 +272,7 @@ namespace Js
274
272
{
275
273
JavascriptError::ThrowTypeError (requestContext, JSERR_InconsistentTrapResult, _u (" getOwnPropertyDescriptor" ));
276
274
}
277
- if (!target ->IsExtensible ())
275
+ if (!targetObj ->IsExtensible ())
278
276
{
279
277
JavascriptError::ThrowTypeError (requestContext, JSERR_InconsistentTrapResult, _u (" getOwnPropertyDescriptor" ));
280
278
}
@@ -1250,7 +1248,10 @@ namespace Js
1250
1248
{
1251
1249
if (target == nullptr )
1252
1250
{
1253
- JavascriptError::ThrowTypeError (GetScriptContext (), JSERR_ErrorOnRevokedProxy, _u (" " ));
1251
+ // We only can get here through GetOwnPropertyDescriptor, which would check that proxy is not revoked and throw if necessary.
1252
+ // It may still be possible for the `target` to become null after the validation, for example if a trap handler revokes the proxy.
1253
+ // Just return FALSE in such cases.
1254
+ return FALSE ;
1254
1255
}
1255
1256
1256
1257
return target->GetDefaultPropertyDescriptor (descriptor);
@@ -1675,8 +1676,8 @@ namespace Js
1675
1676
auto fn = [&](RecyclableObject *targetObj)-> BOOL {
1676
1677
return JavascriptOperators::GetOwnPropertyDescriptor (targetObj, propertyId, requestContext, propertyDescriptor);
1677
1678
};
1678
- auto getPropertyId = [&]() -> PropertyId { return propertyId; };
1679
- BOOL foundProperty = proxy->GetPropertyDescriptorTrap (obj, fn, getPropertyId , propertyDescriptor, requestContext);
1679
+
1680
+ BOOL foundProperty = proxy->GetPropertyDescriptorTrap (obj, fn, propertyId , propertyDescriptor, requestContext);
1680
1681
return foundProperty;
1681
1682
}
1682
1683
0 commit comments