@@ -195,8 +195,7 @@ 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
+ BOOL JavascriptProxy::GetPropertyDescriptorTrap (PropertyId propertyId, PropertyDescriptor* resultDescriptor, ScriptContext* requestContext)
200
199
{
201
200
PROBE_STACK (GetScriptContext (), Js::Constants::MinStackDefault);
202
201
@@ -223,17 +222,17 @@ namespace Js
223
222
224
223
Assert ((static_cast <DynamicType*>(GetType ()))->GetTypeHandler ()->GetPropertyCount () == 0 ||
225
224
(static_cast <DynamicType*>(GetType ()))->GetTypeHandler ()->GetPropertyId (GetScriptContext (), 0 ) == InternalPropertyIds::WeakMapKeyMap);
225
+
226
226
JavascriptFunction* gOPDMethod = GetMethodHelper (PropertyIds::getOwnPropertyDescriptor, requestContext);
227
227
228
228
// 7. If trap is undefined, then
229
229
// a.Return the result of calling the[[GetOwnProperty]] internal method of target with argument P.
230
230
if (nullptr == gOPDMethod || GetScriptContext ()->IsHeapEnumInProgress ())
231
231
{
232
232
resultDescriptor->SetFromProxy (false );
233
- return fn (targetObj);
233
+ return JavascriptOperators::GetOwnPropertyDescriptor (targetObj, propertyId, requestContext, resultDescriptor );
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,10 +272,13 @@ namespace Js
274
272
{
275
273
JavascriptError::ThrowTypeError (requestContext, JSERR_InconsistentTrapResult, _u (" getOwnPropertyDescriptor" ));
276
274
}
277
- if (!target->IsExtensible ())
275
+
276
+ // do not use "target" here, the trap may have caused it to change
277
+ if (!targetObj->IsExtensible ())
278
278
{
279
279
JavascriptError::ThrowTypeError (requestContext, JSERR_InconsistentTrapResult, _u (" getOwnPropertyDescriptor" ));
280
280
}
281
+
281
282
return FALSE ;
282
283
}
283
284
@@ -293,7 +294,8 @@ namespace Js
293
294
// i.Throw a TypeError exception.
294
295
// 22. Return resultDesc.
295
296
296
- BOOL isTargetExtensible = target->IsExtensible ();
297
+ // do not use "target" here, the trap may have caused it to change
298
+ BOOL isTargetExtensible = targetObj->IsExtensible ();
297
299
BOOL toProperty = JavascriptOperators::ToPropertyDescriptor (getResult, resultDescriptor, requestContext);
298
300
if (!toProperty && isTargetExtensible)
299
301
{
@@ -1246,16 +1248,6 @@ namespace Js
1246
1248
return trapResult;
1247
1249
}
1248
1250
1249
- BOOL JavascriptProxy::GetDefaultPropertyDescriptor (PropertyDescriptor& descriptor)
1250
- {
1251
- if (target == nullptr )
1252
- {
1253
- JavascriptError::ThrowTypeError (GetScriptContext (), JSERR_ErrorOnRevokedProxy, _u (" " ));
1254
- }
1255
-
1256
- return target->GetDefaultPropertyDescriptor (descriptor);
1257
- }
1258
-
1259
1251
// 7.3.12 in ES 2015. While this should have been no observable behavior change. Till there is obvious change warrant this
1260
1252
// to be moved to JavascriptOperators, let's keep it in proxy only first.
1261
1253
BOOL JavascriptProxy::TestIntegrityLevel (IntegrityLevel integrityLevel, RecyclableObject* obj, ScriptContext* scriptContext)
@@ -1672,12 +1664,7 @@ namespace Js
1672
1664
BOOL JavascriptProxy::GetOwnPropertyDescriptor (RecyclableObject* obj, PropertyId propertyId, ScriptContext* requestContext, PropertyDescriptor* propertyDescriptor)
1673
1665
{
1674
1666
JavascriptProxy* proxy = JavascriptProxy::FromVar (obj);
1675
- auto fn = [&](RecyclableObject *targetObj)-> BOOL {
1676
- return JavascriptOperators::GetOwnPropertyDescriptor (targetObj, propertyId, requestContext, propertyDescriptor);
1677
- };
1678
- auto getPropertyId = [&]() -> PropertyId {return propertyId; };
1679
- BOOL foundProperty = proxy->GetPropertyDescriptorTrap (obj, fn, getPropertyId, propertyDescriptor, requestContext);
1680
- return foundProperty;
1667
+ return proxy->GetPropertyDescriptorTrap (propertyId, propertyDescriptor, requestContext);
1681
1668
}
1682
1669
1683
1670
0 commit comments