MCPcopy Create free account
hub / github.com/appium/appium / syncShadowProperty

Function syncShadowProperty

packages/execute-driver-plugin/lib/vm-host-binding.ts:388–407  ·  view source on GitHub ↗

* Synchronizes a single property from `hostTarget` onto `shadowTarget` when required by V8 * Proxy invariants (e.g. non-configurable properties, array `length`, or non-extensible targets).

(
  shadowTarget: HostTarget,
  hostTarget: HostTarget,
  prop: string | symbol,
)

Source from the content-addressed store, hash-verified

386 * Proxy invariants (e.g. non-configurable properties, array `length`, or non-extensible targets).
387 */
388function syncShadowProperty(
389 shadowTarget: HostTarget,
390 hostTarget: HostTarget,
391 prop: string | symbol,
392): PropertyDescriptor | undefined {
393 const hostDesc = Reflect.getOwnPropertyDescriptor(hostTarget, prop);
394 if (!hostDesc) {
395 const shadowDesc = Reflect.getOwnPropertyDescriptor(shadowTarget, prop);
396 if (shadowDesc?.configurable) {
397 Reflect.deleteProperty(shadowTarget, prop);
398 }
399 return undefined;
400 }
401 const wrappedDesc = mapDescriptorForSandbox(hostDesc);
402 const shadowDesc = Reflect.getOwnPropertyDescriptor(shadowTarget, prop);
403 if (!wrappedDesc.configurable || shadowDesc !== undefined || !Reflect.isExtensible(shadowTarget)) {
404 Reflect.defineProperty(shadowTarget, prop, wrappedDesc);
405 }
406 return wrappedDesc;
407}
408
409function pruneShadowKeys(shadowTarget: HostTarget, hostKeySet: ReadonlySet<string | symbol>): Array<string | symbol> {
410 const retainedNonConfigurable: Array<string | symbol> = [];

Callers 6

definePropertyFunction · 0.85
getFunction · 0.85
getOwnPropertyDescriptorFunction · 0.85
hasFunction · 0.85
ownKeysFunction · 0.85
setFunction · 0.85

Calls 1

mapDescriptorForSandboxFunction · 0.85

Tested by

no test coverage detected