@lwrjs/client-modules 0.13.0-alpha.9 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Copyright (C) 2019 salesforce.com, inc.
3
3
  */
4
- var _URLCtor$prototype$LWS;
4
+ var _TrustedHTMLCtor$prot$LWS, _TrustedScriptCtor$pr$LWS, _URLCtor$prototype$LWS;
5
5
  const {
6
6
  apply: ReflectApply$LWS$1,
7
7
  construct: ReflectConstruct$LWS,
@@ -301,6 +301,7 @@ function createUnmaskableTraps$LWS(func$LWS) {
301
301
  return {
302
302
  defineProperty(target$LWS, key$LWS, desc$LWS) {
303
303
  // Defining forgeries of handshake properties is not allowed.
304
+ // istanbul ignore else: it is unnecessary to cover the else path here
304
305
  if (key$LWS === LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL$LWS) {
305
306
  throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
306
307
  }
@@ -312,12 +313,14 @@ function createUnmaskableTraps$LWS(func$LWS) {
312
313
  // does NOT exist.
313
314
  handshakeUnmaskFlag$LWS && (handshakeUnmaskFlag$LWS = handshake$LWS);
314
315
  const isUnmaskedSymbol$LWS = key$LWS === LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL$LWS;
316
+ // istanbul ignore else: it is unnecessary to cover the else path here
315
317
  if (handshakeUnmaskFlag$LWS) {
316
318
  // Exit without performing a [[Get]] for
317
319
  // `LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL` properties
318
320
  // because we know that when the
319
321
  // `handshakeUnmaskFlag` is ON that
320
322
  // there are NO shadowed values.
323
+ // istanbul ignore else: it is unnecessary to cover the else path here
321
324
  if (isUnmaskedSymbol$LWS) {
322
325
  return func$LWS;
323
326
  }
@@ -325,6 +328,7 @@ function createUnmaskableTraps$LWS(func$LWS) {
325
328
  const result$LWS = ReflectGet$LWS(target$LWS, key$LWS, receiver$LWS);
326
329
  // Getting forged values of `LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL`
327
330
  // properties is not allowed.
331
+ // istanbul ignore else: it is unnecessary to cover the else path here
328
332
  if (result$LWS !== undefined && isUnmaskedSymbol$LWS) {
329
333
  throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
330
334
  }
@@ -333,6 +337,7 @@ function createUnmaskableTraps$LWS(func$LWS) {
333
337
  getOwnPropertyDescriptor(target$LWS, key$LWS) {
334
338
  const result$LWS = ReflectGetOwnPropertyDescriptor$LWS(target$LWS, key$LWS);
335
339
  // Getting forged descriptors of handshake properties is not allowed.
340
+ // istanbul ignore else: it is unnecessary to cover the else path here
336
341
  if (result$LWS && key$LWS === LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL$LWS) {
337
342
  throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
338
343
  }
@@ -345,6 +350,7 @@ function createUnmaskableTraps$LWS(func$LWS) {
345
350
  handshakeUnmaskFlag$LWS = false;
346
351
  // Checking the existence of forged `LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL`
347
352
  // properties is not allowed.
353
+ // istanbul ignore else: it is unnecessary to cover the else path here
348
354
  if (isUnmaskedSymbol$LWS) {
349
355
  throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
350
356
  }
@@ -358,6 +364,7 @@ function createUnmaskableTraps$LWS(func$LWS) {
358
364
  },
359
365
  set(target$LWS, key$LWS, value$LWS, receiver$LWS) {
360
366
  // Setting forged values of handshake properties is not allowed.
367
+ // istanbul ignore else: it is unnecessary to cover the else path here
361
368
  if (key$LWS === LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL$LWS) {
362
369
  throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
363
370
  }
@@ -366,7 +373,7 @@ function createUnmaskableTraps$LWS(func$LWS) {
366
373
  };
367
374
  }
368
375
  function getUnmaskedFunction$LWS(func$LWS) {
369
- const unmasked$LWS = LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL$LWS in func$LWS ? undefined : func$LWS[LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL$LWS];
376
+ const unmasked$LWS = LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL$LWS in func$LWS ? /* istanbul ignore next */undefined : func$LWS[LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL$LWS];
370
377
  return unmasked$LWS === undefined ? func$LWS : unmasked$LWS;
371
378
  }
372
379
  function isMaskedFunction$LWS(value$LWS) {
@@ -564,6 +571,8 @@ const {
564
571
  toFixed: NumberProtoToFixed$LWS,
565
572
  valueOf: NumberProtoValueOf$LWS
566
573
  } = NumberCtor$LWS$1.prototype;
574
+
575
+ // @ts-nocheck
567
576
  const StringCtor$LWS$1 = String;
568
577
  const {
569
578
  prototype: StringProto$LWS$1
@@ -590,6 +599,12 @@ const quoteCharRegExpRegistry$LWS = {
590
599
  [CHAR_QUOTE_DOUBLE$LWS]: /\\?"/g,
591
600
  [CHAR_QUOTE_SINGLE$LWS]: /\\?'/g
592
601
  };
602
+ const TrustedHTMLCtor$LWS = typeof TrustedHTML === 'function' ? TrustedHTML : /* istanbul ignore next: unreachable in test env */undefined;
603
+ // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
604
+ const TrustedHTMLProtoToString$LWS = TrustedHTMLCtor$LWS == null || (_TrustedHTMLCtor$prot$LWS = TrustedHTMLCtor$LWS.prototype) == null ? void 0 : _TrustedHTMLCtor$prot$LWS.toString;
605
+ const TrustedScriptCtor$LWS = typeof TrustedScript === 'function' ? TrustedScript : /* istanbul ignore next: unreachable in test env */undefined;
606
+ // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
607
+ const TrustedScriptProtoToString$LWS = TrustedScriptCtor$LWS == null || (_TrustedScriptCtor$pr$LWS = TrustedScriptCtor$LWS.prototype) == null ? void 0 : _TrustedScriptCtor$pr$LWS.toString;
593
608
  const URLCtor$LWS = typeof URL === 'function' ? URL : /* istanbul ignore next: unreachable in test env */undefined;
594
609
  // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
595
610
  const URLProtoToString$LWS = URLCtor$LWS == null || (_URLCtor$prototype$LWS = URLCtor$LWS.prototype) == null ? void 0 : _URLCtor$prototype$LWS.toString;
@@ -655,6 +670,13 @@ function toSafeTemplateStringValue$LWS(value$LWS) {
655
670
  return ReflectApply$LWS$1(FunctionProtoToString$LWS, value$LWS, []);
656
671
  }
657
672
  if (typeof value$LWS === 'object' && value$LWS !== null) {
673
+ if (TrustedHTMLCtor$LWS && value$LWS instanceof TrustedHTMLCtor$LWS) {
674
+ return ReflectApply$LWS$1(TrustedHTMLProtoToString$LWS, value$LWS, []);
675
+ }
676
+ /* istanbul ignore next: unreachable in test env */
677
+ if (TrustedScriptCtor$LWS && value$LWS instanceof TrustedScriptCtor$LWS) {
678
+ return ReflectApply$LWS$1(TrustedScriptProtoToString$LWS, value$LWS, []);
679
+ }
658
680
  if (URLCtor$LWS && value$LWS instanceof URLCtor$LWS) {
659
681
  return ReflectApply$LWS$1(URLProtoToString$LWS, value$LWS, []);
660
682
  }
@@ -1021,6 +1043,7 @@ function isNearMembraneProxy$LWS$1(value$LWS) {
1021
1043
  return false;
1022
1044
  }
1023
1045
  const SEEN_OBJECTS$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1());
1046
+ // istanbul ignore next: this may be dead code, further investigation needed
1024
1047
  function cloneBoxedPrimitive$LWS(object$LWS) {
1025
1048
  return ObjectCtor$LWS$1(getNearMembraneProxySerializedValue$LWS$1(object$LWS));
1026
1049
  }
@@ -1060,6 +1083,7 @@ function cloneMap$LWS(map$LWS, queue$LWS) {
1060
1083
  }
1061
1084
  return clone$LWS;
1062
1085
  }
1086
+ // istanbul ignore next: this may be dead code, further investigation needed
1063
1087
  function cloneRegExp$LWS(regexp$LWS) {
1064
1088
  const {
1065
1089
  flags: flags$LWS,
@@ -1264,7 +1288,9 @@ function partialStructuredCloneInternal$LWS(value$LWS) {
1264
1288
  switch (brand$LWS) {
1265
1289
  // Step 12: Otherwise, if value has a [[RegExpMatcher]] internal slot...
1266
1290
  case TO_STRING_BRAND_REG_EXP$LWS:
1291
+ // istanbul ignore next: this may be dead code, further investigation needed
1267
1292
  cloneValue$LWS = cloneRegExp$LWS(originalValue$LWS);
1293
+ // istanbul ignore next: this may be dead code, further investigation needed
1268
1294
  break;
1269
1295
  // Step 7: If value has a [[BooleanData]] internal slot...
1270
1296
  case TO_STRING_BRAND_BOOLEAN$LWS$1:
@@ -1277,7 +1303,9 @@ function partialStructuredCloneInternal$LWS(value$LWS) {
1277
1303
  // Step 10: Otherwise, if value has a [[StringData]] internal slot...
1278
1304
  // eslint-disable-next-line no-fallthrough
1279
1305
  case TO_STRING_BRAND_STRING$LWS$1:
1306
+ // istanbul ignore next: this may be dead code, further investigation needed
1280
1307
  cloneValue$LWS = cloneBoxedPrimitive$LWS(originalValue$LWS);
1308
+ // istanbul ignore next: this may be dead code, further investigation needed
1281
1309
  break;
1282
1310
  }
1283
1311
  }
@@ -1331,7 +1359,7 @@ function consoleWarn$LWS(...args$LWS) {
1331
1359
  }
1332
1360
  let gaterEnabledFeatures$LWS = [];
1333
1361
  function isGaterEnabledFeature$LWS(featureName$LWS) {
1334
- return gaterEnabledFeatures$LWS.includes(`com.salesforce.locker.${featureName$LWS}`);
1362
+ return ReflectApply$LWS$1(ArrayProtoIncludes$LWS$1, gaterEnabledFeatures$LWS, [`com.salesforce.locker.${featureName$LWS}`]);
1335
1363
  }
1336
1364
  const trackedLiveTargets$LWS = toSafeWeakSet$LWS$1(new WeakSetCtor$LWS$1());
1337
1365
  function isTargetLive$LWS(target$LWS, targetTraits$LWS = 0 /* TargetTraits.None */) {
@@ -1414,6 +1442,10 @@ function trackAsLiveTarget$LWS(target$LWS) {
1414
1442
  trackedLiveTargets$LWS.add(target$LWS);
1415
1443
  return target$LWS;
1416
1444
  }
1445
+ const lockerFeatures$LWS = {};
1446
+ function isLockerFeatureEnabled$LWS(featureName$LWS) {
1447
+ return lockerFeatures$LWS[featureName$LWS];
1448
+ }
1417
1449
  const NS_HEAD$LWS = `${LOCKER_SERVICE_KEY$LWS}-`;
1418
1450
  const NS_TAIL$LWS = '$';
1419
1451
  const STORAGE_NS_HEAD$LWS = `${LOCKER_SERVICE_KEY$LWS}[`;
@@ -1457,7 +1489,7 @@ const {
1457
1489
  } = PromiseCtor$LWS.prototype;
1458
1490
  const PromiseResolve$LWS = PromiseCtor$LWS.resolve.bind(PromiseCtor$LWS);
1459
1491
  const PromiseReject$LWS = PromiseCtor$LWS.reject.bind(PromiseCtor$LWS);
1460
- /*! version: 0.22.2 */
1492
+ /*! version: 0.22.4 */
1461
1493
 
1462
1494
  /*!
1463
1495
  * Copyright (C) 2019 salesforce.com, inc.
@@ -1672,6 +1704,7 @@ function initWindowOpenChildWindow$LWS(win$LWS, url$LWS) {
1672
1704
  // than `url`.
1673
1705
  // `location.href` is a non-configurable property so can be accessed
1674
1706
  // directly.
1707
+ // istanbul ignore else: current tests have no way of expressing a state that would cause this condition to evaluate false
1675
1708
  if (location$LWS.href !== url$LWS) {
1676
1709
  // Opening and closing `doc` prevents the default browser
1677
1710
  // redirect behavior.
@@ -1686,6 +1719,57 @@ function initWindowOpenChildWindow$LWS(win$LWS, url$LWS) {
1686
1719
  }
1687
1720
  return win$LWS;
1688
1721
  }
1722
+ // This is only used by window.open() and document.open(x, y, z) distortions to
1723
+ // block access to unsafe properties of the child window that's returned by those
1724
+ // APIs. These properties must be otherwise available directly on the sandbox window,
1725
+ // or via iframe.contentWindow created within the sandbox.
1726
+ // To be effective, we mark the blocked thing with a symbol, so that can be detected by
1727
+ // the distortion, otherwise the distortion will replace whatever we define here with
1728
+ // whatever it provides.
1729
+ const CHILD_WINDOW_BLOCKED_PROPERTY_SYMBOL$LWS = SymbolFor$LWS$1('@@lwsChildWindowBlockedProperty');
1730
+ const CHILD_WINDOW_BLOCKED_PROPERTIES$LWS = ['eval', 'Function', 'setInterval', 'setTimeout'];
1731
+ function markForUnsafePropertyBlocking$LWS(childWindow$LWS) {
1732
+ // If this function somehow receives the rootWindow, just return it.
1733
+ if (!childWindow$LWS || childWindow$LWS === rootWindow$LWS$1) {
1734
+ return childWindow$LWS;
1735
+ }
1736
+ for (const blocked$LWS of CHILD_WINDOW_BLOCKED_PROPERTIES$LWS) {
1737
+ const descriptor$LWS = ReflectGetOwnPropertyDescriptor$LWS(childWindow$LWS, blocked$LWS);
1738
+ const replacement$LWS = /* istanbul ignore next: this replacement function will never actually be called */() => {};
1739
+ ReflectDefineProperty$LWS$1(replacement$LWS, CHILD_WINDOW_BLOCKED_PROPERTY_SYMBOL$LWS, {
1740
+ __proto__: null,
1741
+ configurable: false,
1742
+ enumerable: false,
1743
+ get() {
1744
+ return true;
1745
+ }
1746
+ });
1747
+ if (typeof childWindow$LWS[blocked$LWS] === 'function') {
1748
+ descriptor$LWS.value = replacement$LWS;
1749
+ }
1750
+ /* Eventually there will be other types of blocked properties
1751
+ else {
1752
+ descriptor.get = replacement;
1753
+ }
1754
+ */
1755
+ ReflectDefineProperty$LWS$1(childWindow$LWS, blocked$LWS, descriptor$LWS);
1756
+ }
1757
+ return childWindow$LWS;
1758
+ }
1759
+ function throwIfMarkedAsUnsafeInChildWindow$LWS(virtualEnvironmentEvaluator$LWS, name$LWS) {
1760
+ // This seemingly strange approach is necessary because this distortion will
1761
+ // otherwise replace whatever was force-assigned to the childWindow property
1762
+ // by markForUnsafePropertyBlocking with this distortion, effectively acting
1763
+ // as an UNDO of markForUnsafePropertyBlocking(). We have to dig into
1764
+ // the sandbox's global object and look at the actual property to see if it was
1765
+ // marked for unsafe property blocking, because indirect property (ie. eval) will bypass
1766
+ // any "this" property lookups.
1767
+ const getPossiblyBlockedPropertyFromSandbox$LWS = virtualEnvironmentEvaluator$LWS(`() => globalThis.${name$LWS}`);
1768
+ // istanbul ignore else: it is unnecessary to cover the else path here
1769
+ if (getPossiblyBlockedPropertyFromSandbox$LWS()[CHILD_WINDOW_BLOCKED_PROPERTY_SYMBOL$LWS]) {
1770
+ throw new LockerSecurityError$LWS(`Cannot call ${name$LWS} on this window.`);
1771
+ }
1772
+ }
1689
1773
  function isWindow$LWS(value$LWS) {
1690
1774
  if (typeof value$LWS === 'object' && value$LWS !== null && ObjectHasOwn$LWS$1(value$LWS, 'window') && value$LWS.window === value$LWS) {
1691
1775
  // Slower check that must certainly detect a window object.
@@ -1763,6 +1847,9 @@ class Validator$LWS {
1763
1847
  ReflectApply$LWS$1(ElementProtoInnerHTMLSetter$LWS, this._templates.right, [rightString$LWS]);
1764
1848
  return deepIsEqualNode$LWS(this._templates.left, this._templates.right);
1765
1849
  };
1850
+ // There is no reason to ever allow any HTML or XML that contains all three of these substrings.
1851
+ // eslint-disable-next-line class-methods-use-this
1852
+ this.isInherentlyUnsecure = input$LWS => ReflectApply$LWS$1(StringProtoIncludes$LWS, input$LWS, ['iframe']) && ReflectApply$LWS$1(StringProtoIncludes$LWS, input$LWS, ['script']) && ReflectApply$LWS$1(StringProtoIncludes$LWS, input$LWS, ['srcdoc']);
1766
1853
  this.isSharedElement = element$LWS => element$LWS === ReflectApply$LWS$1(DocumentProtoHeadGetter$LWS, this._document, []) || element$LWS === ReflectApply$LWS$1(DocumentProtoBodyGetter$LWS$1, this._document, []) || element$LWS === ReflectApply$LWS$1(DocumentProtoDocumentElementGetter$LWS, this._document, []);
1767
1854
  this._constructors = {
1768
1855
  HTMLLinkElement: HTMLLinkElement$LWS,
@@ -2116,7 +2203,7 @@ const {
2116
2203
  const XhrProtoResponseTextGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'responseText');
2117
2204
  const XhrProtoStatusGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'status');
2118
2205
  ObjectLookupOwnSetter$LWS(XhrProto$LWS, 'withCredentials');
2119
- /*! version: 0.22.2 */
2206
+ /*! version: 0.22.4 */
2120
2207
 
2121
2208
  /*!
2122
2209
  * Copyright (C) 2019 salesforce.com, inc.
@@ -2175,7 +2262,7 @@ function sanitizeURLForElement$LWS(url$LWS) {
2175
2262
  function sanitizeURLString$LWS(urlString$LWS) {
2176
2263
  return urlString$LWS === '' ? urlString$LWS : ReflectApply$LWS$1(StringProtoReplace$LWS, urlString$LWS, [newlinesAndTabsRegExp$LWS, '']);
2177
2264
  }
2178
- /*! version: 0.22.2 */
2265
+ /*! version: 0.22.4 */
2179
2266
 
2180
2267
  /*! @license DOMPurify 3.0.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.5/LICENSE */
2181
2268
 
@@ -3861,7 +3948,7 @@ try {
3861
3948
  // swallow
3862
3949
  }
3863
3950
  const trusted = createPolicy('trusted', policyOptions);
3864
- /*! version: 0.22.2 */
3951
+ /*! version: 0.22.4 */
3865
3952
 
3866
3953
  /*!
3867
3954
  * Copyright (C) 2019 salesforce.com, inc.
@@ -3941,6 +4028,7 @@ function createSantizerHooksRegistry$LWS(sandboxKey$LWS) {
3941
4028
  const {
3942
4029
  tagName: tagName$LWS
3943
4030
  } = data$LWS;
4031
+ // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
3944
4032
  const tagNameCheck$LWS = config$LWS == null || (_config$CUSTOM_ELEMEN$LWS = config$LWS.CUSTOM_ELEMENT_HANDLING) == null ? void 0 : _config$CUSTOM_ELEMEN$LWS.tagNameCheck;
3945
4033
  if (tagNameCheck$LWS && ReflectApply$LWS$1(RegExpProtoTest$LWS$1, tagNameCheck$LWS, [tagName$LWS]) &&
3946
4034
  // This MUST be called ONLY after we've ensured the previous
@@ -4109,6 +4197,7 @@ function uponSanitizeAttribute$LWS(node$LWS, data$LWS, _config$LWS) {
4109
4197
  // https://lit.dev/docs/components/events/
4110
4198
  // https://lit.dev/docs/templates/expressions/#property-expressions
4111
4199
  // https://lit.dev/docs/templates/expressions/#boolean-attribute-expressions
4200
+ // istanbul ignore next: this is tested under all normal CI runs, but is not included in coverage
4112
4201
  if (attrName$LWS && (ReflectApply$LWS$1(StringProtoStartsWith$LWS, attrName$LWS, ['@']) || ReflectApply$LWS$1(StringProtoStartsWith$LWS, attrName$LWS, ['.']) || ReflectApply$LWS$1(StringProtoStartsWith$LWS, attrName$LWS, ['?']))) {
4113
4202
  data$LWS.forceKeepAttr = true;
4114
4203
  }
@@ -4120,7 +4209,7 @@ function blobSanitizer$LWS(sandboxKey$LWS) {
4120
4209
  }
4121
4210
  return getSanitizerForConfig$LWS(sandboxKey$LWS, 'STRING_BLOB_HTML');
4122
4211
  }
4123
- /*! version: 0.22.2 */
4212
+ /*! version: 0.22.4 */
4124
4213
 
4125
4214
  /*!
4126
4215
  * Copyright (C) 2023 salesforce.com, inc.
@@ -4318,7 +4407,7 @@ function encloseSrcSetter$LWS(targetElement$LWS) {
4318
4407
  ReflectApply$LWS$1(ElementProtoSetAttributeNS$LWS, targetElement$LWS, [attributeNamespaceURI$LWS, attributeName$LWS, src$LWS]);
4319
4408
  };
4320
4409
  }
4321
- /*! version: 0.22.2 */
4410
+ /*! version: 0.22.4 */
4322
4411
 
4323
4412
  /*!
4324
4413
  * Copyright (C) 2019 salesforce.com, inc.
@@ -4373,8 +4462,12 @@ class VirtualRegistry$LWS {
4373
4462
  } else {
4374
4463
  // When there is already a PivotCtor for the given tagName, we need to ensure that
4375
4464
  // this definition doesn't have a conflicting formAssociated value for that tagName.
4465
+ //
4466
+ // NOTE: This is always going to be a definition that's been passed through
4467
+ // createDefinitionRecord(), so it will always have either a true or false value
4468
+ // (there will never be a need to provide a default value here)
4376
4469
  const {
4377
- formAssociated: formAssociated$LWS = false
4470
+ formAssociated: formAssociated$LWS
4378
4471
  } = definition$LWS;
4379
4472
  if (PivotCtor$LWS.formAssociated !== formAssociated$LWS) {
4380
4473
  throw new LockerSecurityError$LWS(`Cannot create a definition for <${tagName$LWS}> with "formAssociated = ${formAssociated$LWS}". Either use "formAssociated = ${PivotCtor$LWS.formAssociated}" for this component or rename the component to not conflict with <${tagName$LWS}>`);
@@ -5059,6 +5152,7 @@ document$LWS = globalObject$LWS.document) {
5059
5152
  function setCustomElementsRegistry$LWS(document$LWS, key$LWS) {
5060
5153
  currentRegistry$LWS = getSandboxCustomElementRegistry$LWS(document$LWS, key$LWS);
5061
5154
  }
5155
+ const DataTransferBlockedProperties$LWS = ['mozCursor', 'mozSourceNode', 'mozUserCancelled'];
5062
5156
  const attributeDistortionFactoriesCache$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1());
5063
5157
  const sandboxAttributeDistortionRegistryCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
5064
5158
  function finalizeAttributeDistortions$LWS(record$LWS) {
@@ -5209,6 +5303,45 @@ function initDistortionAuraUtilGlobalEval$LWS({
5209
5303
  }];
5210
5304
  };
5211
5305
  }
5306
+ function initDistortionBroadcastChannelPostMessage$LWS({
5307
+ globalObject: globalObject$LWS
5308
+ }) {
5309
+ const {
5310
+ BroadcastChannel: BroadcastChannel$LWS
5311
+ } = globalObject$LWS;
5312
+ // istanbul ignore if: this is a safety precaution, but currently unreachable via tests
5313
+ if (typeof BroadcastChannel$LWS !== 'function') {
5314
+ return noop$LWS$1;
5315
+ }
5316
+ const {
5317
+ prototype: {
5318
+ postMessage: originalPostMessage$LWS
5319
+ }
5320
+ } = BroadcastChannel$LWS;
5321
+ const distortionEntry$LWS = [originalPostMessage$LWS, function postMessage$LWS(...args$LWS) {
5322
+ try {
5323
+ return ReflectApply$LWS$1(originalPostMessage$LWS, this, args$LWS);
5324
+ } catch (error) {
5325
+ // We don't check if `error instance of DOMException` because
5326
+ // accessing `DOMException` of the `globalObject` will throw
5327
+ // an error for opaque windows.
5328
+ const {
5329
+ length: length$LWS
5330
+ } = args$LWS;
5331
+ if (length$LWS) {
5332
+ const message$LWS = args$LWS[0];
5333
+ if (isObject$LWS$1(message$LWS)) {
5334
+ args$LWS[0] = partialStructuredClone$LWS(message$LWS);
5335
+ return ReflectApply$LWS$1(originalPostMessage$LWS, this, args$LWS);
5336
+ }
5337
+ }
5338
+ throw error;
5339
+ }
5340
+ }];
5341
+ return function distortionBroadcastChannelPostMessage$LWS() {
5342
+ return distortionEntry$LWS;
5343
+ };
5344
+ }
5212
5345
 
5213
5346
  /* istanbul ignore next: only available in secure context */
5214
5347
  function initDistortionCacheStorageDelete$LWS({
@@ -5918,6 +6051,9 @@ function initDistortionDocumentExecCommand$LWS({
5918
6051
  if (loweredCommand$LWS === 'selectall' && this === rootDocument$LWS) {
5919
6052
  throwLockerSecurityError$LWS(command$LWS, this);
5920
6053
  }
6054
+ // Guard against TOCTOU attacks by forcing execCommand to receive whatever
6055
+ // the first read value of the provided command is.
6056
+ args$LWS[0] = command$LWS;
5921
6057
  if (length$LWS > 2) {
5922
6058
  const {
5923
6059
  2: unsanitizedValue$LWS
@@ -5982,6 +6118,9 @@ function initDistortionDocumentOpen$LWS({
5982
6118
  // https://developer.mozilla.org/en-US/docs/Web/API/Document/open#three-argument_document.open
5983
6119
  const normalizedArgs$LWS = normalizeWindowOpenArguments$LWS(args$LWS);
5984
6120
  const childWindow$LWS = ReflectApply$LWS$1(originalDocumentOpen$LWS, this, normalizedArgs$LWS);
6121
+ // W-16032332
6122
+ // Block access to unsafe child window properties
6123
+ markForUnsafePropertyBlocking$LWS(childWindow$LWS);
5985
6124
  if (childWindow$LWS) {
5986
6125
  initWindowOpenChildWindow$LWS(childWindow$LWS, normalizedArgs$LWS[0]);
5987
6126
  }
@@ -6016,6 +6155,7 @@ function initDistortionDocumentReplaceChildren$LWS({
6016
6155
  }
6017
6156
  function initDistortionDOMParserParseFromString$LWS({
6018
6157
  document: document$LWS,
6158
+ globalObject: globalObject$LWS,
6019
6159
  globalObject: {
6020
6160
  DOMParser: {
6021
6161
  prototype: {
@@ -6028,6 +6168,9 @@ function initDistortionDOMParserParseFromString$LWS({
6028
6168
  key: key$LWS
6029
6169
  }) {
6030
6170
  return [originalParseFromString$LWS, function parseFromString$LWS(...args$LWS) {
6171
+ const {
6172
+ isInherentlyUnsecure: isInherentlyUnsecure$LWS
6173
+ } = getValidator$LWS(document$LWS, globalObject$LWS);
6031
6174
  // DOMParser.prototype.parseFromString can only be called with
6032
6175
  // exactly two arguments. If it receives one argument, it will fail.
6033
6176
  // Some implementations will also fail if it receives more than two
@@ -6039,11 +6182,6 @@ function initDistortionDOMParserParseFromString$LWS({
6039
6182
  // of that argument.
6040
6183
  const string$LWS = toString$LWS(args$LWS[0]);
6041
6184
  const mimeType$LWS = toString$LWS(args$LWS[1]);
6042
- // This must be called to signal to the virtual
6043
- // CustomElementRegistry that the next thing created
6044
- // MAY CONTAIN a custom element, which must be marked for
6045
- // association to this sandbox.
6046
- setCustomElementsRegistry$LWS(document$LWS, key$LWS);
6047
6185
  let contentType$LWS;
6048
6186
  switch (mimeType$LWS) {
6049
6187
  case 'application/xhtml+xml':
@@ -6057,6 +6195,16 @@ function initDistortionDOMParserParseFromString$LWS({
6057
6195
  default:
6058
6196
  contentType$LWS = ContentType$LWS.HTML;
6059
6197
  }
6198
+ if (contentType$LWS === ContentType$LWS.XML) {
6199
+ if (isInherentlyUnsecure$LWS(string$LWS)) {
6200
+ throw new LockerSecurityError$LWS(`Cannot 'parseFromString' using an unsecure ${toSafeTemplateStringValue$LWS(string$LWS)}.`);
6201
+ }
6202
+ }
6203
+ // This must be called to signal to the virtual
6204
+ // CustomElementRegistry that the next thing created
6205
+ // MAY CONTAIN a custom element, which must be marked for
6206
+ // association to this sandbox.
6207
+ setCustomElementsRegistry$LWS(document$LWS, key$LWS);
6060
6208
  args$LWS[0] = lwsInternalPolicy$LWS.createHTML(string$LWS, key$LWS, contentType$LWS);
6061
6209
  }
6062
6210
  return ReflectApply$LWS$1(originalParseFromString$LWS, this, args$LWS);
@@ -6315,6 +6463,7 @@ function scriptPropertySetters$LWS(incomingThis$LWS, property$LWS, valueAsTruste
6315
6463
  return false;
6316
6464
  }
6317
6465
  const {
6466
+ isInherentlyUnsecure: isInherentlyUnsecure$3$LWS,
6318
6467
  isSharedElement: isSharedElement$n$LWS
6319
6468
  } = rootValidator$LWS;
6320
6469
  function initDistortionElementInnerHTMLSetter$LWS({
@@ -6358,6 +6507,9 @@ function initDistortionElementInnerHTMLSetter$LWS({
6358
6507
  const contentType$LWS = this instanceof SVGElement$LWS ? ContentType$LWS.SVG : ContentType$LWS.HTML;
6359
6508
  value$LWS = lwsInternalPolicy$LWS.createHTML(value$LWS, key$LWS, contentType$LWS);
6360
6509
  }
6510
+ if (isInherentlyUnsecure$3$LWS(value$LWS)) {
6511
+ throw new LockerSecurityError$LWS(`Cannot set 'innerHTML' using an unsecure ${toSafeTemplateStringValue$LWS(value$LWS)}.`);
6512
+ }
6361
6513
  ReflectApply$LWS$1(originalInnerHTMLSetter$LWS, this, [value$LWS]);
6362
6514
  }];
6363
6515
  };
@@ -6393,6 +6545,7 @@ function initDistortionElementInsertAdjacentElement$LWS({
6393
6545
  };
6394
6546
  }
6395
6547
  const {
6548
+ isInherentlyUnsecure: isInherentlyUnsecure$2$LWS,
6396
6549
  isSharedElement: isSharedElement$l$LWS
6397
6550
  } = rootValidator$LWS;
6398
6551
  const allowedElementHTMLRegExp$LWS = /^\s*<(link|script|style)/i;
@@ -6423,12 +6576,16 @@ function initDistortionElementInsertAdjacentHTML$LWS({
6423
6576
  setCustomElementsRegistry$LWS(document$LWS, key$LWS);
6424
6577
  const contentType$LWS = this instanceof SVGElement ? ContentType$LWS.SVG : ContentType$LWS.HTML;
6425
6578
  args$LWS[1] = lwsInternalPolicy$LWS.createHTML(args$LWS[1], key$LWS, contentType$LWS);
6579
+ if (isInherentlyUnsecure$2$LWS(args$LWS[1])) {
6580
+ throw new LockerSecurityError$LWS(`Cannot 'insertAdjacentHTML' using an unsecure ${toSafeTemplateStringValue$LWS(args$LWS[1])}.`);
6581
+ }
6426
6582
  }
6427
6583
  ReflectApply$LWS$1(originalInsertAdjacentHTML$LWS, this, args$LWS);
6428
6584
  }];
6429
6585
  };
6430
6586
  }
6431
6587
  const {
6588
+ isInherentlyUnsecure: isInherentlyUnsecure$1$LWS,
6432
6589
  isSharedElement: isSharedElement$k$LWS
6433
6590
  } = rootValidator$LWS;
6434
6591
  function initDistortionElementOuterHTMLSetter$LWS({
@@ -6451,7 +6608,11 @@ function initDistortionElementOuterHTMLSetter$LWS({
6451
6608
  // MAY CONTAIN a custom element, which must be marked for
6452
6609
  // association to this sandbox.
6453
6610
  setCustomElementsRegistry$LWS(document$LWS, key$LWS);
6454
- ReflectApply$LWS$1(originalOuterHTMLSetter$LWS, this, [lwsInternalPolicy$LWS.createHTML(value$LWS, key$LWS, ContentType$LWS.HTML)]);
6611
+ const html$LWS = lwsInternalPolicy$LWS.createHTML(value$LWS, key$LWS, ContentType$LWS.HTML);
6612
+ if (isInherentlyUnsecure$1$LWS(html$LWS)) {
6613
+ throw new LockerSecurityError$LWS(`Cannot set outerHTML using an unsecure ${toSafeTemplateStringValue$LWS(html$LWS)}.`);
6614
+ }
6615
+ ReflectApply$LWS$1(originalOuterHTMLSetter$LWS, this, [html$LWS]);
6455
6616
  }];
6456
6617
  };
6457
6618
  }
@@ -6760,6 +6921,7 @@ function initDistortionElementSetAttributeNS$LWS({
6760
6921
  };
6761
6922
  }
6762
6923
  const {
6924
+ isInherentlyUnsecure: isInherentlyUnsecure$LWS,
6763
6925
  isSharedElement: isSharedElement$f$LWS
6764
6926
  } = rootValidator$LWS;
6765
6927
  function initDistortionElementSetHTML$LWS({
@@ -6799,6 +6961,9 @@ function initDistortionElementSetHTML$LWS({
6799
6961
  const value$LWS = args$LWS[0];
6800
6962
  const contentType$LWS = this instanceof SVGElement$LWS ? ContentType$LWS.SVG : ContentType$LWS.HTML;
6801
6963
  args$LWS[0] = lwsInternalPolicy$LWS.createHTML(value$LWS, key$LWS, contentType$LWS);
6964
+ if (isInherentlyUnsecure$LWS(args$LWS[0])) {
6965
+ throw new LockerSecurityError$LWS(`Cannot 'setHTML' using an unsecure ${toSafeTemplateStringValue$LWS(args$LWS[0])}.`);
6966
+ }
6802
6967
  }
6803
6968
  ReflectApply$LWS$1(originalSetHTML$LWS, this, args$LWS);
6804
6969
  }];
@@ -6871,9 +7036,13 @@ function initDistortionEval$LWS({
6871
7036
  }
6872
7037
  }) {
6873
7038
  return function distortionEval$LWS({
6874
- sandboxEvaluator: sandboxEvaluator$LWS
7039
+ sandboxEvaluator: sandboxEvaluator$LWS,
7040
+ virtualEnvironmentEvaluator: virtualEnvironmentEvaluator$LWS
6875
7041
  }) {
6876
- return [originalEval$LWS, sourceText$LWS => sandboxEvaluator$LWS(transformSourceText$LWS(toString$LWS(sourceText$LWS)), UNCOMPILED_CONTEXT$LWS)];
7042
+ return [originalEval$LWS, function (sourceText$LWS) {
7043
+ throwIfMarkedAsUnsafeInChildWindow$LWS(virtualEnvironmentEvaluator$LWS, 'eval');
7044
+ return sandboxEvaluator$LWS(transformSourceText$LWS(toString$LWS(sourceText$LWS)), UNCOMPILED_CONTEXT$LWS);
7045
+ }];
6877
7046
  };
6878
7047
  }
6879
7048
  function createDistortedComposedPath$LWS(event$LWS, sandboxKey$LWS) {
@@ -6975,9 +7144,11 @@ function initDistortionFunction$LWS({
6975
7144
  }) {
6976
7145
  const funcFooterRegExp$LWS = /\n?}[^}]*$/;
6977
7146
  return function distortionFunction$LWS({
6978
- sandboxEvaluator: sandboxEvaluator$LWS
7147
+ sandboxEvaluator: sandboxEvaluator$LWS,
7148
+ virtualEnvironmentEvaluator: virtualEnvironmentEvaluator$LWS
6979
7149
  }) {
6980
7150
  return [originalFunction$LWS, function Function$LWS(...args$LWS) {
7151
+ throwIfMarkedAsUnsafeInChildWindow$LWS(virtualEnvironmentEvaluator$LWS, 'Function');
6981
7152
  // The `arguments` object has `Symbol.iterator` as an own
6982
7153
  // property, not inherited, so it avoids prototype pollution
6983
7154
  // attacks.
@@ -9078,7 +9249,7 @@ function createDistortionHrefAttributeFactoryInitializer$LWS(attributeName$LWS)
9078
9249
  }
9079
9250
  const initDistortionSVGUseElementHrefAttribute$LWS = createDistortionHrefAttributeFactoryInitializer$LWS('href');
9080
9251
  const initDistortionSVGUseElementXlinkHrefAttribute$LWS = createDistortionHrefAttributeFactoryInitializer$LWS('xlink:href');
9081
- function createTrustedTypesError$LWS(name$LWS = '') {
9252
+ function createTrustedTypesExceptionMessage$LWS(name$LWS) {
9082
9253
  return `Cannot create TrustedTypePolicy with '${name$LWS}' policy name.`;
9083
9254
  }
9084
9255
  function initDistortionTrustedTypePolicyFactoryCreatePolicy$LWS({
@@ -9097,15 +9268,17 @@ function initDistortionTrustedTypePolicyFactoryCreatePolicy$LWS({
9097
9268
  const name$LWS = args$LWS.length ? args$LWS[0] : /* istanbul ignore next: needs default platform behavior test */undefined;
9098
9269
  // istanbul ignore else: needs default platform behavior test
9099
9270
  if (name$LWS === 'default') {
9100
- throw new LockerSecurityError$LWS(createTrustedTypesError$LWS(name$LWS));
9271
+ throw new LockerSecurityError$LWS(createTrustedTypesExceptionMessage$LWS(name$LWS));
9101
9272
  }
9102
9273
  // If the policy is one of the CSP policies, it should be allowed
9103
9274
  try {
9104
9275
  // istanbul ignore next: needs default platform behavior test
9105
9276
  return ReflectApply$LWS$1(originalCreatePolicy$LWS, this, args$LWS);
9106
9277
  } catch (_unused3$LWS) {
9107
- consoleWarn$LWS(`${createTrustedTypesError$LWS(name$LWS)} Substituting with Lightning Web Security policy.`);
9278
+ // istanbul ignore next: this is tested, but currently cannot be tested in the coverage environment
9279
+ consoleWarn$LWS(`${createTrustedTypesExceptionMessage$LWS(name$LWS)} Substituting with Lightning Web Security policy.`);
9108
9280
  }
9281
+ // istanbul ignore next: this is tested, but currently cannot be tested in the coverage environment
9109
9282
  return trusted;
9110
9283
  }];
9111
9284
  return function distortionTrustedTypePolicyFactoryCreatePolicy$LWS() {
@@ -9113,6 +9286,7 @@ function initDistortionTrustedTypePolicyFactoryCreatePolicy$LWS({
9113
9286
  };
9114
9287
  }
9115
9288
  const HTML_MIME_TYPES_LIST$LWS = toSafeArray$LWS$1(['text/html', 'image/svg+xml', 'text/xml']);
9289
+ const createInsecureBlobErrorMessage$LWS = input$LWS => `Cannot 'createObjectURL' using an unsecure ${toSafeTemplateStringValue$LWS(input$LWS)}.`;
9116
9290
  function initDistortionURLCreateObjectURL$LWS({
9117
9291
  document: document$LWS,
9118
9292
  globalObject: globalObject$LWS,
@@ -9128,7 +9302,8 @@ function initDistortionURLCreateObjectURL$LWS({
9128
9302
  // needs to be bound to the global object of the magenta object (arbitrary
9129
9303
  // user-code created global objects).
9130
9304
  const {
9131
- isEqualDomString: isEqualDomString$LWS
9305
+ isEqualDomString: isEqualDomString$LWS,
9306
+ isInherentlyUnsecure: isInherentlyUnsecure$LWS
9132
9307
  } = getValidator$LWS(document$LWS, globalObject$LWS);
9133
9308
  return function distortionURLCreateObjectURL$LWS({
9134
9309
  key: key$LWS
@@ -9174,10 +9349,14 @@ function initDistortionURLCreateObjectURL$LWS({
9174
9349
  throw new LockerSecurityError$LWS(`Unable to verify ${toSafeTemplateStringValue$LWS(blobObject$LWS)} is secure.`);
9175
9350
  }
9176
9351
  const responseText$LWS = ReflectApply$LWS$1(XhrProtoResponseTextGetter$LWS, xhr$LWS, []);
9352
+ // W-15987833
9353
+ if (isInherentlyUnsecure$LWS(responseText$LWS)) {
9354
+ throw new LockerSecurityError$LWS(createInsecureBlobErrorMessage$LWS(blobObject$LWS));
9355
+ }
9177
9356
  const sanitized$LWS = sanitizer$LWS.sanitize(responseText$LWS);
9178
9357
  if (!isEqualDomString$LWS(trusted.createHTML(responseText$LWS), trusted.createHTML(sanitized$LWS))) {
9179
9358
  URLRevokeObjectURL$LWS(outURL$LWS);
9180
- throw new LockerSecurityError$LWS(`Cannot 'createObjectURL' using an unsecure ${toSafeTemplateStringValue$LWS(blobObject$LWS)}.`);
9359
+ throw new LockerSecurityError$LWS(createInsecureBlobErrorMessage$LWS(blobObject$LWS));
9181
9360
  }
9182
9361
  return outURL$LWS;
9183
9362
  }
@@ -9492,6 +9671,9 @@ function initDistortionWindowOpen$LWS({
9492
9671
  const distortionEntry$LWS = [originalWindowOpen$LWS, function open$LWS(...args$LWS) {
9493
9672
  const normalizedArgs$LWS = normalizeWindowOpenArguments$LWS(args$LWS);
9494
9673
  const childWindow$LWS = ReflectApply$LWS$1(originalWindowOpen$LWS, this, normalizedArgs$LWS);
9674
+ // W-16032332
9675
+ // Block access to unsafe child window properties
9676
+ markForUnsafePropertyBlocking$LWS(childWindow$LWS);
9495
9677
  // W-14218118
9496
9678
  // If the target is '_self', '_parent', or '_top', only makes one request
9497
9679
  if (normalizedArgs$LWS.length > 1) {
@@ -9559,9 +9741,11 @@ function initDistortionWindowSetInterval$LWS({
9559
9741
  }
9560
9742
  }) {
9561
9743
  return function distortionWndowSetInterval$LWS({
9562
- sandboxEvaluator: sandboxEvaluator$LWS
9744
+ sandboxEvaluator: sandboxEvaluator$LWS,
9745
+ virtualEnvironmentEvaluator: virtualEnvironmentEvaluator$LWS
9563
9746
  }) {
9564
9747
  return [originalSetInterval$LWS, function setInterval$LWS(...args$LWS) {
9748
+ throwIfMarkedAsUnsafeInChildWindow$LWS(virtualEnvironmentEvaluator$LWS, 'setInterval');
9565
9749
  if (args$LWS.length) {
9566
9750
  const {
9567
9751
  0: callback$LWS
@@ -9592,9 +9776,11 @@ function initDistortionWindowSetTimeout$LWS({
9592
9776
  }
9593
9777
  }) {
9594
9778
  return function distortionWindowSetTimeout$LWS({
9595
- sandboxEvaluator: sandboxEvaluator$LWS
9779
+ sandboxEvaluator: sandboxEvaluator$LWS,
9780
+ virtualEnvironmentEvaluator: virtualEnvironmentEvaluator$LWS
9596
9781
  }) {
9597
9782
  return [originalSetTimeout$LWS, function setTimeout$LWS(...args$LWS) {
9783
+ throwIfMarkedAsUnsafeInChildWindow$LWS(virtualEnvironmentEvaluator$LWS, 'setTimeout');
9598
9784
  if (args$LWS.length) {
9599
9785
  const {
9600
9786
  0: callback$LWS
@@ -9779,6 +9965,8 @@ Naming convention for DistortionFactory function types:
9779
9965
  distortion[ObjectName]Proto : used for the object prototype itself
9780
9966
  */
9781
9967
  const internalDistortionFactoryInitializers$LWS = [
9968
+ // BroadcastChannel
9969
+ initDistortionBroadcastChannelPostMessage$LWS,
9782
9970
  // CSSStyleRule
9783
9971
  initDistortionCSSStyleRuleStyleGetter$LWS,
9784
9972
  // Document
@@ -9901,9 +10089,9 @@ initDistortionElementAfter$LWS, initDistortionElementAppend$LWS, initDistortionE
9901
10089
  // initDistortionNodeAppendChild,
9902
10090
  initDistortionNodeInsertBefore$LWS]);
9903
10091
  const externalKeyedDistortionFactoryInitializers$LWS = internalKeyedDistortionFactoryInitializers$LWS;
9904
- toSafeMap$LWS$1(new MapCtor$LWS$1([[initDistortionCacheStorageDelete$LWS, 'caches'], [initDistortionCacheStorageHas$LWS, 'caches'], [initDistortionCacheStorageKeys$LWS, 'caches'], [initDistortionCacheStorageMatch$LWS, 'caches'], [initDistortionCacheStorageOpen$LWS, 'caches'], [initDistortionCookieStoreDelete$LWS, 'cookieStore'], [initDistortionCookieStoreGet$LWS, 'cookieStore'], [initDistortionCookieStoreGetAll$LWS, 'cookieStore'], [initDistortionCookieStoreOnChange$LWS, 'cookieStore'], [initDistortionCookieStoreSet$LWS, 'cookieStore'], [initDistortionCSSStyleRuleStyleGetter$LWS, 'style'], [initDistortionCustomElementRegistryDefine$LWS, 'customElements'], [initDistortionCustomElementRegistryGet$LWS, 'customElements'], [initDistortionCustomElementRegistryUpgrade$LWS, 'customElements'], [initDistortionCustomElementRegistryWhenDefined$LWS, 'customElements'], [initDistortionDocumentCookieGetter$LWS, 'documentCookie'], [initDistortionDocumentCookieSetter$LWS, 'documentCookie'], [initDistortionDocumentDomainSetter$LWS, 'documentDomain'], [initDistortionDocumentExecCommand$LWS, 'documentExecCommand'], [initDistortionDOMParserParseFromString$LWS, 'domParserParseFromString'], [initDistortionElementAfter$LWS, 'element'], [initDistortionElementAppend$LWS, 'element'], [initDistortionElementAttributesGetter$LWS, 'attributes'], [initDistortionElementBefore$LWS, 'element'], [initDistortionElementGetInnerHTML$LWS, 'innerHTML'], [initDistortionElementInnerHTMLSetter$LWS, 'innerHTML'], [initDistortionElementInsertAdjacentElement$LWS, 'element'], [initDistortionElementInsertAdjacentHTML$LWS, 'element'], [initDistortionElementOuterHTMLSetter$LWS, 'element'], [initDistortionElementPrepend$LWS, 'element'], [initDistortionElementRemove$LWS, 'element'], [initDistortionElementReplaceChildren$LWS, 'element'], [initDistortionElementReplaceWith$LWS, 'element'], [initDistortionElementSetAttribute$LWS, 'attributes'], [initDistortionElementSetAttributeNode$LWS, 'attributes'], [initDistortionElementSetAttributeNodeNS$LWS, 'attributes'], [initDistortionElementSetAttributeNS$LWS, 'attributes'], [initDistortionElementSetHTML$LWS, 'element'], [initDistortionElementToggleAttribute$LWS, 'attributes'], [initDistortionHistoryPushState$LWS, 'history'], [initDistortionHistoryReplaceState$LWS, 'history'], [initDistortionHTMLElementDatasetGetter$LWS, 'dataset'], [initDistortionHTMLElementStyleGetter$LWS, 'style'], [initDistortionHTMLScriptElementSrcGetter$LWS, 'script'], [initDistortionHTMLScriptElementSrcSetter$LWS, 'script'], [initDistortionHTMLScriptElementTextSetter$LWS, 'script'], [initDistortionIDBObjectStoreAdd$LWS, 'indexedDB'], [initDistortionIDBObjectStorePut$LWS, 'indexedDB'], [initDistortionLocalStorage$LWS, 'storage'], [initDistortionMessagePortPostMessage$LWS, 'postMessage'], [initDistortionNamedNodeMapSetNamedItem$LWS, 'attributes'], [initDistortionNamedNodeMapSetNamedItemNS$LWS, 'attributes'], [initDistortionNavigatorSendBeacon$LWS, 'navigatorSendBeacon'], [initDistortionNodeInsertBefore$LWS, 'node'], [initDistortionNodeRemoveChild$LWS, 'node'], [initDistortionNodeReplaceChild$LWS, 'node'], [initDistortionNodeTextContentGetter$LWS, 'node'], [initDistortionNodeTextContentSetter$LWS, 'node'], [initDistortionNodeValueSetter$LWS, 'node'], [initDistortionNotificationCtor$LWS, 'notification'], [initDistortionPerformanceMark$LWS, 'performance'], [initDistortionPerformanceMarkCtor$LWS, 'performance'], [initDistortionPerformanceMeasure$LWS, 'performance'], [initDistortionRangeCreateContextualFragment$LWS, 'range'], [initDistortionRangeDeleteContents$LWS, 'range'], [initDistortionRangeExtractContents$LWS, 'range'], [initDistortionRangeInsertNode$LWS, 'range'], [initDistortionRangeSelectNode$LWS, 'range'], [initDistortionRangeSelectNodeContents$LWS, 'range'], [initDistortionRangeSetEnd$LWS, 'range'], [initDistortionRangeSetEndAfter$LWS, 'range'], [initDistortionRangeSetEndBefore$LWS, 'range'], [initDistortionRangeSetStart$LWS, 'range'], [initDistortionRangeSetStartAfter$LWS, 'range'], [initDistortionRangeSetStartBefore$LWS, 'range'], [initDistortionRangeSurroundContents$LWS, 'range'], [initDistortionSelectionCollapse$LWS, 'selection'], [initDistortionSelectionExtend$LWS, 'selection'], [initDistortionSelectionSelectAllChildren$LWS, 'selection'], [initDistortionSelectionSetBaseAndExtent$LWS, 'selection'], [initDistortionSelectionSetPosition$LWS, 'selection'], [initDistortionSessionStorage$LWS, 'storage'], [initDistortionShadowRootInnerHTMLSetter$LWS, 'innerHTML'], [initDistortionStorage$LWS, 'storage'], [initDistortionStorageClear$LWS, 'storage'], [initDistortionStorageGetItem$LWS, 'storage'], [initDistortionStorageKey$LWS, 'storage'], [initDistortionStorageLength$LWS, 'storage'], [initDistortionStorageRemoveItem$LWS, 'storage'], [initDistortionStorageSetItem$LWS, 'storage'], [initDistortionSVGElementDatasetGetter$LWS, 'dataset'], [initDistortionSVGElementStyleGetter$LWS, 'style'], [initDistortionSVGScriptElementHrefGetter$LWS, 'script'], [initDistortionSVGScriptElementHrefSetter$LWS, 'script'], [initDistortionWindowFetch$LWS, 'windowFetch'], [initDistortionWindowFramesGetter$LWS, 'windowFrames'], [initDistortionWindowGetComputedStyle$LWS, 'style'], [initDistortionWindowLengthGetter$LWS, 'windowFrames'], [initDistortionWindowPostMessage$LWS, 'postMessage'], [initDistortionWindowSetInterval$LWS, 'setInterval'], [initDistortionWindowSetTimeout$LWS, 'setTimeout'], [initDistortionXMLHttpRequestResponseGetter$LWS, 'xhr'], [initDistortionXMLHttpRequestResponseXMLGetter$LWS, 'xhr']]));
9905
- const DocumentBlockedProperties$LWS = ['createProcessingInstruction', 'exitFullscreen', 'fullscreen', 'fullscreenElement', 'fullscreenEnabled', 'mozCancelFullScreen', 'mozFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'onfullscreenchange', 'onfullscreenerror', 'onmozfullscreenchange', 'onmozfullscreenerror', 'onrejectionhandled', 'onunhandledrejection', 'releaseCapture', 'releaseEvents', 'webkitFullScreenKeyboardInputAllowed', 'write', 'writeln'];
9906
- const ElementBlockedProperties$LWS = ['mozRequestFullScreen', 'onfullscreenchange', 'onfullscreenerror', 'requestFullscreen', 'webkitRequestFullScreen', 'webkitRequestFullscreen'];
10092
+ const distortionFactoryInitializerToggleSwitches$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1([[initDistortionCacheStorageDelete$LWS, 'caches'], [initDistortionCacheStorageHas$LWS, 'caches'], [initDistortionCacheStorageKeys$LWS, 'caches'], [initDistortionCacheStorageMatch$LWS, 'caches'], [initDistortionCacheStorageOpen$LWS, 'caches'], [initDistortionCookieStoreDelete$LWS, 'cookieStore'], [initDistortionCookieStoreGet$LWS, 'cookieStore'], [initDistortionCookieStoreGetAll$LWS, 'cookieStore'], [initDistortionCookieStoreOnChange$LWS, 'cookieStore'], [initDistortionCookieStoreSet$LWS, 'cookieStore'], [initDistortionCSSStyleRuleStyleGetter$LWS, 'style'], [initDistortionCustomElementRegistryDefine$LWS, 'customElements'], [initDistortionCustomElementRegistryGet$LWS, 'customElements'], [initDistortionCustomElementRegistryUpgrade$LWS, 'customElements'], [initDistortionCustomElementRegistryWhenDefined$LWS, 'customElements'], [initDistortionDocumentCookieGetter$LWS, 'documentCookie'], [initDistortionDocumentCookieSetter$LWS, 'documentCookie'], [initDistortionDocumentDomainSetter$LWS, 'documentDomain'], [initDistortionDocumentExecCommand$LWS, 'documentExecCommand'], [initDistortionDOMParserParseFromString$LWS, 'domParserParseFromString'], [initDistortionElementAfter$LWS, 'element'], [initDistortionElementAppend$LWS, 'element'], [initDistortionElementAttributesGetter$LWS, 'attributes'], [initDistortionElementBefore$LWS, 'element'], [initDistortionElementGetInnerHTML$LWS, 'innerHTML'], [initDistortionElementInnerHTMLSetter$LWS, 'innerHTML'], [initDistortionElementInsertAdjacentElement$LWS, 'element'], [initDistortionElementInsertAdjacentHTML$LWS, 'element'], [initDistortionElementOuterHTMLSetter$LWS, 'element'], [initDistortionElementPrepend$LWS, 'element'], [initDistortionElementRemove$LWS, 'element'], [initDistortionElementReplaceChildren$LWS, 'element'], [initDistortionElementReplaceWith$LWS, 'element'], [initDistortionElementSetAttribute$LWS, 'attributes'], [initDistortionElementSetAttributeNode$LWS, 'attributes'], [initDistortionElementSetAttributeNodeNS$LWS, 'attributes'], [initDistortionElementSetAttributeNS$LWS, 'attributes'], [initDistortionElementSetHTML$LWS, 'element'], [initDistortionElementToggleAttribute$LWS, 'attributes'], [initDistortionHistoryPushState$LWS, 'history'], [initDistortionHistoryReplaceState$LWS, 'history'], [initDistortionHTMLElementDatasetGetter$LWS, 'dataset'], [initDistortionHTMLElementStyleGetter$LWS, 'style'], [initDistortionHTMLScriptElementSrcGetter$LWS, 'script'], [initDistortionHTMLScriptElementSrcSetter$LWS, 'script'], [initDistortionHTMLScriptElementTextSetter$LWS, 'script'], [initDistortionIDBObjectStoreAdd$LWS, 'indexedDB'], [initDistortionIDBObjectStorePut$LWS, 'indexedDB'], [initDistortionLocalStorage$LWS, 'storage'], [initDistortionMessagePortPostMessage$LWS, 'postMessage'], [initDistortionNamedNodeMapSetNamedItem$LWS, 'attributes'], [initDistortionNamedNodeMapSetNamedItemNS$LWS, 'attributes'], [initDistortionNavigatorSendBeacon$LWS, 'navigatorSendBeacon'], [initDistortionNodeInsertBefore$LWS, 'node'], [initDistortionNodeRemoveChild$LWS, 'node'], [initDistortionNodeReplaceChild$LWS, 'node'], [initDistortionNodeTextContentGetter$LWS, 'node'], [initDistortionNodeTextContentSetter$LWS, 'node'], [initDistortionNodeValueSetter$LWS, 'node'], [initDistortionNotificationCtor$LWS, 'notification'], [initDistortionPerformanceMark$LWS, 'performance'], [initDistortionPerformanceMarkCtor$LWS, 'performance'], [initDistortionPerformanceMeasure$LWS, 'performance'], [initDistortionRangeCreateContextualFragment$LWS, 'range'], [initDistortionRangeDeleteContents$LWS, 'range'], [initDistortionRangeExtractContents$LWS, 'range'], [initDistortionRangeInsertNode$LWS, 'range'], [initDistortionRangeSelectNode$LWS, 'range'], [initDistortionRangeSelectNodeContents$LWS, 'range'], [initDistortionRangeSetEnd$LWS, 'range'], [initDistortionRangeSetEndAfter$LWS, 'range'], [initDistortionRangeSetEndBefore$LWS, 'range'], [initDistortionRangeSetStart$LWS, 'range'], [initDistortionRangeSetStartAfter$LWS, 'range'], [initDistortionRangeSetStartBefore$LWS, 'range'], [initDistortionRangeSurroundContents$LWS, 'range'], [initDistortionSelectionCollapse$LWS, 'selection'], [initDistortionSelectionExtend$LWS, 'selection'], [initDistortionSelectionSelectAllChildren$LWS, 'selection'], [initDistortionSelectionSetBaseAndExtent$LWS, 'selection'], [initDistortionSelectionSetPosition$LWS, 'selection'], [initDistortionSessionStorage$LWS, 'storage'], [initDistortionShadowRootInnerHTMLSetter$LWS, 'innerHTML'], [initDistortionStorage$LWS, 'storage'], [initDistortionStorageClear$LWS, 'storage'], [initDistortionStorageGetItem$LWS, 'storage'], [initDistortionStorageKey$LWS, 'storage'], [initDistortionStorageLength$LWS, 'storage'], [initDistortionStorageRemoveItem$LWS, 'storage'], [initDistortionStorageSetItem$LWS, 'storage'], [initDistortionSVGElementDatasetGetter$LWS, 'dataset'], [initDistortionSVGElementStyleGetter$LWS, 'style'], [initDistortionSVGScriptElementHrefGetter$LWS, 'script'], [initDistortionSVGScriptElementHrefSetter$LWS, 'script'], [initDistortionWindowFetch$LWS, 'windowFetch'], [initDistortionWindowFramesGetter$LWS, 'windowFrames'], [initDistortionWindowGetComputedStyle$LWS, 'style'], [initDistortionWindowLengthGetter$LWS, 'windowFrames'], [initDistortionWindowPostMessage$LWS, 'postMessage'], [initDistortionWindowSetInterval$LWS, 'setInterval'], [initDistortionWindowSetTimeout$LWS, 'setTimeout'], [initDistortionXMLHttpRequestResponseGetter$LWS, 'xhr'], [initDistortionXMLHttpRequestResponseXMLGetter$LWS, 'xhr']]));
10093
+ const DocumentBlockedProperties$LWS = ['createProcessingInstruction', 'exitFullscreen', 'fullscreen', 'fullscreenElement', 'fullscreenEnabled', 'mozCancelFullScreen', 'mozFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'onfullscreenchange', 'onfullscreenerror', 'onmozfullscreenchange', 'onmozfullscreenerror', 'onrejectionhandled', 'onunhandledrejection', 'parseHTMLUnsafe', 'releaseCapture', 'releaseEvents', 'webkitFullScreenKeyboardInputAllowed', 'write', 'writeln'];
10094
+ const ElementBlockedProperties$LWS = ['mozRequestFullScreen', 'onfullscreenchange', 'onfullscreenerror', 'requestFullscreen', 'setHTMLUnsafe', 'webkitRequestFullScreen', 'webkitRequestFullscreen'];
9907
10095
  const EventBlockedProperties$LWS = ['originalTarget', 'explicitOriginalTarget'];
9908
10096
  const HTMLElementBlockedAttributes$LWS = ['nonce'];
9909
10097
  const HTMLElementBlockedProperties$LWS = ['nonce', 'onrejectionhandled', 'onunhandledrejection'];
@@ -9920,7 +10108,7 @@ const SVGElementBlockedProperties$LWS = ['nonce'];
9920
10108
  const UIEventBlockedProperties$LWS = ['rangeParent'];
9921
10109
  const WindowBlockedProperties$LWS = ['find', 'requestFileSystem', 'webkitRequestFileSystem'];
9922
10110
  const XSLTProcessorBlockedProperties$LWS = ['transformToDocument', 'transformToFragment'];
9923
- /*! version: 0.22.2 */
10111
+ /*! version: 0.22.4 */
9924
10112
 
9925
10113
  /*!
9926
10114
  * Copyright (C) 2019 salesforce.com, inc.
@@ -9960,15 +10148,143 @@ function getSandboxRegistry$LWS(document$LWS) {
9960
10148
  const LightningWebSecurity$LWS = {
9961
10149
  __proto__: null
9962
10150
  };
9963
- toSafeMap$LWS$1(new MapCtor$LWS$1());
10151
+ // Flag to allow distortions to be "toggle-able".
10152
+ const ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS = LOCKER_UNMINIFIED_FLAG$LWS$1 || /* istanbul ignore next */false || /* istanbul ignore next */false;
10153
+ const distortionFactoryToToggleSwitch$LWS = ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS ? toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1()) : /* istanbul ignore next */null;
10154
+ const sandboxToDistortionEntryToToggleSwitchRegistry$LWS = ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS ? toSafeWeakMap$LWS$1(
10155
+ // The value must be a Map because its entries are iterated over in lws.ts
10156
+ new WeakMapCtor$LWS$1()) : /* istanbul ignore next */null;
10157
+ const sandboxToDisabledDistortionToggleSwitches$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1());
10158
+ function setSandboxDistortionToggleState$LWS(record$LWS, toggleSwitchName$LWS, state$LWS) {
10159
+ const disabledDistortionToggleSwitches$LWS = sandboxToDisabledDistortionToggleSwitches$LWS.get(record$LWS);
10160
+ if (state$LWS) {
10161
+ disabledDistortionToggleSwitches$LWS == null || disabledDistortionToggleSwitches$LWS.delete(toggleSwitchName$LWS);
10162
+ } else {
10163
+ disabledDistortionToggleSwitches$LWS == null || disabledDistortionToggleSwitches$LWS.add(toggleSwitchName$LWS);
10164
+ }
10165
+ }
10166
+ function getSandboxDistortionToggleState$LWS(record$LWS, toggleSwitchName$LWS) {
10167
+ const disabledDistortionToggleSwitches$LWS = sandboxToDisabledDistortionToggleSwitches$LWS.get(record$LWS);
10168
+ // If there are active toggle switches, check for the presense of the specific
10169
+ // toggle switch name in question. If the toggle switch name is present, then
10170
+ // the distortion is disabled:
10171
+ //
10172
+ // Distortion is enabled? Return true
10173
+ // Distortion is disabled? Return false
10174
+ return !disabledDistortionToggleSwitches$LWS.has(toggleSwitchName$LWS);
10175
+ }
10176
+ // Will be assigned the composed object value as:
10177
+ //
10178
+ // namespaces = {
10179
+ // ...ns = {
10180
+ // distortions: {
10181
+ // ...distortion toggle switch flag: true | false
10182
+ // }
10183
+ // }
10184
+ // }
10185
+ //
10186
+ // This is created once and only upon the first access of $LWS.namespaces
10187
+ let namespaces$LWS = null;
10188
+ // This should only be created in DEBUG/COVERAGE mode
10189
+ if (ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS) {
10190
+ ReflectDefineProperty$LWS$1(LightningWebSecurity$LWS, 'namespaces', {
10191
+ __proto__: null,
10192
+ enumerable: true,
10193
+ configurable: false,
10194
+ get() {
10195
+ // Ensure that the above described namespaces object is only createed once.
10196
+ if (!namespaces$LWS) {
10197
+ namespaces$LWS = {
10198
+ __proto__: null
10199
+ };
10200
+ // Use the current document to get the sandbox registry to derive a list
10201
+ // of all sandbox keys corresponding to all created sandboxes.
10202
+ const registry$LWS = getSandboxRegistry$LWS(document);
10203
+ const sandboxKeys$LWS = ReflectApply$LWS$1(ObjectKeys$LWS$1, null, [registry$LWS]);
10204
+ // Construct a list of distortion flags (as object accessors) for each sandbox,
10205
+ // accessible by sandbox key.
10206
+ for (const sandboxKey$LWS of sandboxKeys$LWS) {
10207
+ const record$LWS = registry$LWS[sandboxKey$LWS];
10208
+ // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
10209
+ const distortionToggleSwitchRegistry$LWS = sandboxToDistortionEntryToToggleSwitchRegistry$LWS == null ? void 0 : sandboxToDistortionEntryToToggleSwitchRegistry$LWS.get(record$LWS);
10210
+ const seenFlags$LWS = toSafeSet$LWS(new SetCtor$LWS$1());
10211
+ const distortions$LWS = {
10212
+ __proto__: null
10213
+ };
10214
+ namespaces$LWS[sandboxKey$LWS] = {
10215
+ __proto__: null,
10216
+ distortions: distortions$LWS
10217
+ };
10218
+ for (const {
10219
+ 1: flag$LWS
10220
+ } of distortionToggleSwitchRegistry$LWS) {
10221
+ if (!seenFlags$LWS.has(flag$LWS)) {
10222
+ seenFlags$LWS.add(flag$LWS);
10223
+ ReflectDefineProperty$LWS$1(namespaces$LWS[sandboxKey$LWS].distortions, flag$LWS, {
10224
+ __proto__: null,
10225
+ enumerable: true,
10226
+ configurable: false,
10227
+ get() {
10228
+ return getSandboxDistortionToggleState$LWS(record$LWS, flag$LWS);
10229
+ },
10230
+ set(flagValue$LWS) {
10231
+ return setSandboxDistortionToggleState$LWS(record$LWS, flag$LWS, flagValue$LWS);
10232
+ }
10233
+ });
10234
+ }
10235
+ }
10236
+ ObjectPreventExtensions$LWS(distortions$LWS);
10237
+ }
10238
+ ObjectPreventExtensions$LWS(namespaces$LWS);
10239
+ }
10240
+ return namespaces$LWS;
10241
+ }
10242
+ });
10243
+ ReflectDefineProperty$LWS$1(window, '$LWS', {
10244
+ __proto__: null,
10245
+ enumerable: false,
10246
+ configurable: false,
10247
+ writable: false,
10248
+ value: LightningWebSecurity$LWS
10249
+ });
10250
+ }
9964
10251
  ObjectFreeze$LWS$1(LightningWebSecurity$LWS);
10252
+ function createDistortionToggleSwitchWrapper$LWS(sandboxKey$LWS, toggleSwitchName$LWS, proxyMaskedFunctionDistortion$LWS, originalValue$LWS) {
10253
+ // The distortion function value wrapper is necessary because these switches can only be activated _after_
10254
+ // the sandbox is created, which means the distortion registry has already been processed, with redefined
10255
+ // descriptors already set. Once that is done, there is no way to affect the behavior of a distortion
10256
+ // during runtime without wrapping the distortion function value with a function that side channel communicates
10257
+ // with the exposed flags interface.
10258
+ // eslint-disable-next-line @typescript-eslint/no-loop-func
10259
+ return function (...args$LWS) {
10260
+ var _root$LWS$namespaces$LWS;
10261
+ const {
10262
+ $LWS: root$LWS
10263
+ } = rootWindow$LWS$1;
10264
+ // If no toggleSwitchName is defined, then always use the distorted value
10265
+ // If a toggleSwitchName exists and the corresponding flag in this sandbox
10266
+ // has been set to false, then the distortion is toggled off and we need to
10267
+ // use the undistorted value
10268
+ let useDistortedValue$LWS = root$LWS == null || (_root$LWS$namespaces$LWS = root$LWS.namespaces) == null || (_root$LWS$namespaces$LWS = _root$LWS$namespaces$LWS[sandboxKey$LWS]) == null ? void 0 : _root$LWS$namespaces$LWS.distortions[toggleSwitchName$LWS];
10269
+ // If there is a toggleSwitchName, but there is currently no
10270
+ // boolean value for that toggleSwitchName, then use the distorted value.
10271
+ if (useDistortedValue$LWS === undefined) {
10272
+ useDistortedValue$LWS = true;
10273
+ }
10274
+ const constructOrApplyTarget$LWS = useDistortedValue$LWS ? proxyMaskedFunctionDistortion$LWS : originalValue$LWS;
10275
+ if (new.target) {
10276
+ return ReflectConstruct$LWS(constructOrApplyTarget$LWS, args$LWS, new.target);
10277
+ }
10278
+ return ReflectApply$LWS$1(constructOrApplyTarget$LWS, this, args$LWS);
10279
+ };
10280
+ }
9965
10281
  const distortionFactoriesCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
9966
10282
  const opaqueWindowPostMessageDistortionFactoryCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
9967
10283
  // WebKit based browsers have a bug that prematurely removes distortion entries
9968
10284
  // from the distortions weak map.
9969
10285
  const SUPPORTS_DISTORTIONS_WEAK_MAP$LWS = !IS_WEBKIT_BROWSER$LWS;
9970
10286
  function createDistortionEntries$LWS(record$LWS, factories$LWS) {
9971
- toSafeMap$LWS$1(new MapCtor$LWS$1());
10287
+ const distortionEntryToToggleSwitch$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1());
9972
10288
  const entries$LWS = [];
9973
10289
  for (let i$LWS = 0, {
9974
10290
  length: length$LWS
@@ -9982,7 +10298,21 @@ function createDistortionEntries$LWS(record$LWS, factories$LWS) {
9982
10298
  } = entry$LWS;
9983
10299
  if (typeof originalValue$LWS === 'function') {
9984
10300
  const proxyMaskedFunctionDistortion$LWS = proxyMaskFunctionDistortion$LWS(record$LWS, factory$LWS, distortedValue$LWS, originalValue$LWS);
9985
- entries$LWS[entries$LWS.length] = [originalValue$LWS, proxyMaskedFunctionDistortion$LWS];
10301
+ const toggleSwitchName$LWS = ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS && ( /* istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator */distortionFactoryToToggleSwitch$LWS == null ? void 0 : distortionFactoryToToggleSwitch$LWS.get(factory$LWS));
10302
+ let distortionToggleSwitchWrapperOrProxyMaskedFunction$LWS = proxyMaskedFunctionDistortion$LWS;
10303
+ if (ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS && toggleSwitchName$LWS) {
10304
+ distortionToggleSwitchWrapperOrProxyMaskedFunction$LWS = createDistortionToggleSwitchWrapper$LWS(record$LWS.key, toggleSwitchName$LWS, proxyMaskedFunctionDistortion$LWS, originalValue$LWS);
10305
+ // If the distorted API originated in a window created via window.open or
10306
+ // document.open, it may be marked as an unsafe property. If so, we need
10307
+ // to transfer the original value's marker to the wrapped toggle switch
10308
+ // function to ensure that the distortion itself can find the marker when
10309
+ // checking if it needs to be blocked.
10310
+ if (originalValue$LWS[CHILD_WINDOW_BLOCKED_PROPERTY_SYMBOL$LWS]) {
10311
+ const descriptor$LWS = ReflectGetOwnPropertyDescriptor$LWS(originalValue$LWS, CHILD_WINDOW_BLOCKED_PROPERTY_SYMBOL$LWS);
10312
+ ReflectDefineProperty$LWS$1(distortionToggleSwitchWrapperOrProxyMaskedFunction$LWS, CHILD_WINDOW_BLOCKED_PROPERTY_SYMBOL$LWS, descriptor$LWS);
10313
+ }
10314
+ }
10315
+ entries$LWS[entries$LWS.length] = [originalValue$LWS, toggleSwitchName$LWS ? distortionToggleSwitchWrapperOrProxyMaskedFunction$LWS : proxyMaskedFunctionDistortion$LWS];
9986
10316
  } else {
9987
10317
  // istanbul ignore else: current tests have no way of expressing a state that would cause this condition to evaluate false
9988
10318
  if (typeof originalValue$LWS === 'object' && originalValue$LWS !== null) {
@@ -9991,8 +10321,20 @@ function createDistortionEntries$LWS(record$LWS, factories$LWS) {
9991
10321
  entries$LWS[entries$LWS.length] = entry$LWS;
9992
10322
  }
9993
10323
  }
10324
+ if (ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS) {
10325
+ /* istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator */
10326
+ const toggleSwitchName$LWS = distortionFactoryToToggleSwitch$LWS == null ? void 0 : distortionFactoryToToggleSwitch$LWS.get(factory$LWS);
10327
+ if (toggleSwitchName$LWS) {
10328
+ // Map the just added distortion entry to this toggle switch name
10329
+ distortionEntryToToggleSwitch$LWS.set(entries$LWS[entries$LWS.length - 1], toggleSwitchName$LWS);
10330
+ }
10331
+ }
9994
10332
  }
9995
10333
  }
10334
+ if (ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS) {
10335
+ sandboxToDistortionEntryToToggleSwitchRegistry$LWS == null || sandboxToDistortionEntryToToggleSwitchRegistry$LWS.set(record$LWS, distortionEntryToToggleSwitch$LWS);
10336
+ sandboxToDisabledDistortionToggleSwitches$LWS.set(record$LWS, toSafeSet$LWS(new SetCtor$LWS$1()));
10337
+ }
9996
10338
  return entries$LWS;
9997
10339
  }
9998
10340
  function createDistortionMap$LWS(entries$LWS) {
@@ -10028,6 +10370,7 @@ function getDistortionFactories$LWS(record$LWS) {
10028
10370
  addBlockedAttributeDistortionFactoryInitializers$LWS(HTMLIFrameElement$LWS, 'HTMLIFrameElement', HTMLIFrameElementBlockedAttributes$LWS, initializers$LWS);
10029
10371
  addBlockedAttributeDistortionFactoryInitializers$LWS(HTMLScriptElement$LWS, 'HTMLScriptElement', HTMLScriptElementBlockedAttributes$LWS, initializers$LWS);
10030
10372
  addBlockedAttributeDistortionFactoryInitializers$LWS(SVGElement$LWS, 'SVGElement', SVGElementBlockedAttributes$LWS, initializers$LWS);
10373
+ addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, DataTransfer.prototype, DataTransferBlockedProperties$LWS, initializers$LWS);
10031
10374
  addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, Document$LWS.prototype, DocumentBlockedProperties$LWS, initializers$LWS);
10032
10375
  addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, Element$LWS.prototype, ElementBlockedProperties$LWS, initializers$LWS);
10033
10376
  addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, Event$LWS.prototype, EventBlockedProperties$LWS, initializers$LWS);
@@ -10049,7 +10392,19 @@ function getDistortionFactories$LWS(record$LWS) {
10049
10392
  for (let i$LWS = 0, {
10050
10393
  length: length$LWS
10051
10394
  } = factories$LWS; i$LWS < length$LWS; i$LWS += 1) {
10395
+ let toggleSwitchName$LWS;
10396
+ // Restrict this operation to debug/development/coverage mode only
10397
+ if (ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS) {
10398
+ toggleSwitchName$LWS = distortionFactoryInitializerToggleSwitches$LWS.get(initializers$LWS[i$LWS]);
10399
+ }
10052
10400
  factories$LWS[i$LWS] = initializers$LWS[i$LWS](record$LWS);
10401
+ // Restrict this operation to debug/development/coverage mode only.
10402
+ // Since we actually need the _factory_ to when creating the toggle-able
10403
+ // distortion wrapper, map the factory provided by the initializer to the
10404
+ // toggle switch name.
10405
+ if (ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS && toggleSwitchName$LWS) {
10406
+ distortionFactoryToToggleSwitch$LWS == null || distortionFactoryToToggleSwitch$LWS.set(factories$LWS[i$LWS], toggleSwitchName$LWS);
10407
+ }
10053
10408
  }
10054
10409
  // Finalize attribute distortions last because the attribute registry is
10055
10410
  // populated by the other distortion factories.
@@ -14933,9 +15288,9 @@ function createEvalHelpersFactoryArgs$LWS(record$LWS) {
14933
15288
  prototype: HTMLScriptElementProto$LWS
14934
15289
  }
14935
15290
  },
14936
- root: root$LWS
15291
+ root: _root$LWS
14937
15292
  } = record$LWS;
14938
- const isRootRecord$LWS = record$LWS === root$LWS;
15293
+ const isRootRecord$LWS = record$LWS === _root$LWS;
14939
15294
  const forOfStateCache$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1());
14940
15295
  const resourcePromiseCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
14941
15296
  const resourceStatusCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
@@ -15131,7 +15486,7 @@ function toSourceText$LWS(value$LWS, sourceType$LWS) {
15131
15486
  // tools from mistaking the regexp or the replacement string for an
15132
15487
  // actual source mapping URL.
15133
15488
  /\/\/# sandbox(?=MappingURL=.*?\s*$)/, '//# source']);
15134
- sourceText$LWS = `\n//# LWS Version = "0.22.2"\n${sourceText$LWS}`;
15489
+ sourceText$LWS = `\n//# LWS Version = "0.22.4"\n${sourceText$LWS}`;
15135
15490
  return sourceType$LWS === 1 /* SourceType.Module */ && indexOfPragma$LWS(sourceText$LWS, 'use strict') === -1 ?
15136
15491
  // Append "'use strict'" to the extracted function body so it is
15137
15492
  // evaluated in strict mode.
@@ -15218,7 +15573,7 @@ function createVirtualEnvironment$LWS(record$LWS) {
15218
15573
  globalObject: globalObject$LWS,
15219
15574
  instrumentation: instrumentation$LWS,
15220
15575
  key: key$LWS,
15221
- root: root$LWS,
15576
+ root: _root$LWS,
15222
15577
  root: {
15223
15578
  distortions: distortions$LWS
15224
15579
  },
@@ -15279,7 +15634,7 @@ function createVirtualEnvironment$LWS(record$LWS) {
15279
15634
  globalObject: originalTarget$LWS,
15280
15635
  key: key$LWS,
15281
15636
  type: type$LWS
15282
- }, root$LWS);
15637
+ }, _root$LWS);
15283
15638
  return originalTarget$LWS;
15284
15639
  }
15285
15640
  // eslint-disable-next-line no-empty
@@ -15310,7 +15665,7 @@ function createVirtualEnvironment$LWS(record$LWS) {
15310
15665
  globalObject: originalTargetWindow$LWS,
15311
15666
  key: key$LWS,
15312
15667
  type: type$LWS
15313
- }, root$LWS);
15668
+ }, _root$LWS);
15314
15669
  }
15315
15670
  return originalTarget$LWS;
15316
15671
  },
@@ -15321,7 +15676,9 @@ function createVirtualEnvironment$LWS(record$LWS) {
15321
15676
  ObjectAssign$LWS$1({}, DEFAULT_ENDOWMENTS_DESCRIPTOR_MAP$LWS, ObjectGetOwnPropertyDescriptors$LWS(endowments$LWS)) : DEFAULT_ENDOWMENTS_DESCRIPTOR_MAP$LWS,
15322
15677
  instrumentation: instrumentation$LWS,
15323
15678
  remapTypedArrays: remapTypedArrays$LWS,
15324
- keepAlive: IFRAME_KEEP_ALIVE_FLAG$LWS,
15679
+ keepAlive:
15680
+ // istanbul ignore next: cannot test isLockerFeatureEnabled
15681
+ !remapTypedArrays$LWS && isLockerFeatureEnabled$LWS('isLockerNextForOmnistudioEnabled') || IFRAME_KEEP_ALIVE_FLAG$LWS,
15325
15682
  liveTargetCallback: isTargetLive$LWS,
15326
15683
  signSourceCallback: sourceText$LWS => trusted.createScript(sourceText$LWS)
15327
15684
  });
@@ -15400,7 +15757,7 @@ function createOpaqueSecondaryWindowSandboxRecord$LWS({
15400
15757
  key: key$LWS,
15401
15758
  // istanbul ignore next: destructured default assignments are not correctly instrumented
15402
15759
  type: type$LWS = /* istannul ignore next: nothing works to ignore these */getDefaultType$LWS(key$LWS)
15403
- }, root$LWS) {
15760
+ }, _root$LWS) {
15404
15761
  const sandboxRegistry$LWS = getOpaqueSandboxRegistry$LWS(globalObject$LWS);
15405
15762
  let record$LWS = sandboxRegistry$LWS[key$LWS];
15406
15763
  // istanbul ignore if: calls that would evaluate to true here ARE tested (see packages/integration-karma/test/distortions/HTMLIFrameElement/untrusted/snippets.js, "doesNotThrowOnCreationOrAccessOfCrossOriginIframeContentWindow"), but reported as uncovered
@@ -15413,7 +15770,7 @@ function createOpaqueSecondaryWindowSandboxRecord$LWS({
15413
15770
  LOCKER_VERBOSE_INSTRUMENTATION_FLAG: LOCKER_VERBOSE_INSTRUMENTATION_FLAG$LWS,
15414
15771
  distortions: distortions$LWS,
15415
15772
  instrumentation: instrumentation$LWS
15416
- } = root$LWS;
15773
+ } = _root$LWS;
15417
15774
  record$LWS = {
15418
15775
  BASIC_INSTRUMENTATION_DATA: BASIC_INSTRUMENTATION_DATA$LWS,
15419
15776
  LOCKER_INSTRUMENTATION_FLAG: LOCKER_INSTRUMENTATION_FLAG$LWS,
@@ -15427,7 +15784,7 @@ function createOpaqueSecondaryWindowSandboxRecord$LWS({
15427
15784
  helpers: EMPTY_EVAL_HELPERS$LWS,
15428
15785
  instrumentation: instrumentation$LWS,
15429
15786
  key: key$LWS,
15430
- root: root$LWS,
15787
+ root: _root$LWS,
15431
15788
  sandboxEvaluator: noop$LWS$1,
15432
15789
  type: type$LWS,
15433
15790
  virtualEnvironmentEvaluator: noop$LWS$1
@@ -15460,7 +15817,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15460
15817
  key: key$LWS,
15461
15818
  // istanbul ignore next: destructured default assignments are not correctly instrumented
15462
15819
  type: type$LWS = /* istanbul ignore next: currently unreachable via tests */getDefaultType$LWS(key$LWS)
15463
- }, root$LWS) {
15820
+ }, _root$LWS) {
15464
15821
  const sandboxRegistry$LWS = getSandboxRegistry$LWS(document$LWS);
15465
15822
  let record$LWS = sandboxRegistry$LWS[key$LWS];
15466
15823
  if (record$LWS) {
@@ -15472,7 +15829,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15472
15829
  LOCKER_VERBOSE_INSTRUMENTATION_FLAG: LOCKER_VERBOSE_INSTRUMENTATION_FLAG$LWS,
15473
15830
  distortions: distortions$LWS,
15474
15831
  instrumentation: instrumentation$LWS
15475
- } = root$LWS;
15832
+ } = _root$LWS;
15476
15833
  const {
15477
15834
  location: location$LWS,
15478
15835
  top: top$LWS
@@ -15500,7 +15857,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15500
15857
  helpers: EMPTY_EVAL_HELPERS$LWS,
15501
15858
  instrumentation: instrumentation$LWS,
15502
15859
  key: key$LWS,
15503
- root: root$LWS,
15860
+ root: _root$LWS,
15504
15861
  sandboxEvaluator: noop$LWS$1,
15505
15862
  type: type$LWS,
15506
15863
  virtualEnvironmentEvaluator: noop$LWS$1
@@ -15553,7 +15910,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15553
15910
  globalObject: globalObject$LWS,
15554
15911
  key: key$LWS,
15555
15912
  type: type$LWS
15556
- }, root$LWS);
15913
+ }, _root$LWS);
15557
15914
  }
15558
15915
  } catch (_unused40$LWS) {
15559
15916
  // istanbul ignore next: this is a safety precaution that is unreachable via tests
@@ -15561,7 +15918,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15561
15918
  globalObject: globalObject$LWS,
15562
15919
  key: key$LWS,
15563
15920
  type: type$LWS
15564
- }, root$LWS);
15921
+ }, _root$LWS);
15565
15922
  }
15566
15923
  };
15567
15924
  const frameElement$LWS = ReflectApply$LWS$1(WindowFrameElementGetter$LWS, globalObject$LWS, []);
@@ -15600,7 +15957,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15600
15957
  globalObject: globalObject$LWS,
15601
15958
  key: key$LWS,
15602
15959
  type: type$LWS
15603
- }, root$LWS);
15960
+ }, _root$LWS);
15604
15961
  }
15605
15962
  });
15606
15963
  },
@@ -15789,11 +16146,12 @@ function wrapPlatformResourceLoader$LWS(dep$LWS, key$LWS) {
15789
16146
  const trustedGlobals$LWS = config$LWS.trustedGlobals;
15790
16147
  if ((trustedGlobals$LWS == null ? void 0 : trustedGlobals$LWS.length) > 0) {
15791
16148
  return dep$LWS.loadScript(thisArg$LWS, url$LWS).then(() => {
15792
- const installGlobals$LWS = sandbox$LWS.virtualEnvironmentEvaluator(`(list) => list.forEach(([key, value]) => window[key] = value)`);
15793
- const globals$LWS = [];
15794
- for (let i$LWS = 0; i$LWS < trustedGlobals$LWS.length; i$LWS++) {
15795
- globals$LWS.push([trustedGlobals$LWS[i$LWS], window[trustedGlobals$LWS[i$LWS]]]);
15796
- }
16149
+ const installGlobals$LWS = sandbox$LWS.virtualEnvironmentEvaluator(`(list) => list.forEach(([key, get, set]) => Object.defineProperty(window, key, { get, set, configurable: true, enumerable: true }));`);
16150
+ const globals$LWS = trustedGlobals$LWS.map(globalName$LWS => [globalName$LWS, function get$LWS() {
16151
+ return window[globalName$LWS];
16152
+ }, function set$LWS(value$LWS) {
16153
+ window[globalName$LWS] = value$LWS;
16154
+ }]);
15797
16155
  installGlobals$LWS(globals$LWS);
15798
16156
  });
15799
16157
  }
@@ -15808,7 +16166,7 @@ function wrapPlatformResourceLoader$LWS(dep$LWS, key$LWS) {
15808
16166
  depRegistry$LWS.set(dep$LWS, secureDep$LWS);
15809
16167
  return secureDep$LWS;
15810
16168
  }
15811
- /*! version: 0.22.2 */
16169
+ /*! version: 0.22.4 */
15812
16170
 
15813
16171
  const loaderDefine = globalThis.LWR.define;
15814
16172