@lwrjs/client-modules 0.13.0-alpha.8 → 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,17 +10148,145 @@ 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);
9965
10252
  // If ENABLE_DISTORTION_TOGGLE_SWITCHES = false, this will just be undefined
9966
10253
  const $LWS = window.$LWS;
10254
+ function createDistortionToggleSwitchWrapper$LWS(sandboxKey$LWS, toggleSwitchName$LWS, proxyMaskedFunctionDistortion$LWS, originalValue$LWS) {
10255
+ // The distortion function value wrapper is necessary because these switches can only be activated _after_
10256
+ // the sandbox is created, which means the distortion registry has already been processed, with redefined
10257
+ // descriptors already set. Once that is done, there is no way to affect the behavior of a distortion
10258
+ // during runtime without wrapping the distortion function value with a function that side channel communicates
10259
+ // with the exposed flags interface.
10260
+ // eslint-disable-next-line @typescript-eslint/no-loop-func
10261
+ return function (...args$LWS) {
10262
+ var _root$LWS$namespaces$LWS;
10263
+ const {
10264
+ $LWS: root$LWS
10265
+ } = rootWindow$LWS$1;
10266
+ // If no toggleSwitchName is defined, then always use the distorted value
10267
+ // If a toggleSwitchName exists and the corresponding flag in this sandbox
10268
+ // has been set to false, then the distortion is toggled off and we need to
10269
+ // use the undistorted value
10270
+ 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];
10271
+ // If there is a toggleSwitchName, but there is currently no
10272
+ // boolean value for that toggleSwitchName, then use the distorted value.
10273
+ if (useDistortedValue$LWS === undefined) {
10274
+ useDistortedValue$LWS = true;
10275
+ }
10276
+ const constructOrApplyTarget$LWS = useDistortedValue$LWS ? proxyMaskedFunctionDistortion$LWS : originalValue$LWS;
10277
+ if (new.target) {
10278
+ return ReflectConstruct$LWS(constructOrApplyTarget$LWS, args$LWS, new.target);
10279
+ }
10280
+ return ReflectApply$LWS$1(constructOrApplyTarget$LWS, this, args$LWS);
10281
+ };
10282
+ }
9967
10283
  const distortionFactoriesCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
9968
10284
  const opaqueWindowPostMessageDistortionFactoryCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
9969
10285
  // WebKit based browsers have a bug that prematurely removes distortion entries
9970
10286
  // from the distortions weak map.
9971
10287
  const SUPPORTS_DISTORTIONS_WEAK_MAP$LWS = !IS_WEBKIT_BROWSER$LWS;
9972
10288
  function createDistortionEntries$LWS(record$LWS, factories$LWS) {
9973
- toSafeMap$LWS$1(new MapCtor$LWS$1());
10289
+ const distortionEntryToToggleSwitch$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1());
9974
10290
  const entries$LWS = [];
9975
10291
  for (let i$LWS = 0, {
9976
10292
  length: length$LWS
@@ -9984,7 +10300,21 @@ function createDistortionEntries$LWS(record$LWS, factories$LWS) {
9984
10300
  } = entry$LWS;
9985
10301
  if (typeof originalValue$LWS === 'function') {
9986
10302
  const proxyMaskedFunctionDistortion$LWS = proxyMaskFunctionDistortion$LWS(record$LWS, factory$LWS, distortedValue$LWS, originalValue$LWS);
9987
- entries$LWS[entries$LWS.length] = [originalValue$LWS, proxyMaskedFunctionDistortion$LWS];
10303
+ 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));
10304
+ let distortionToggleSwitchWrapperOrProxyMaskedFunction$LWS = proxyMaskedFunctionDistortion$LWS;
10305
+ if (ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS && toggleSwitchName$LWS) {
10306
+ distortionToggleSwitchWrapperOrProxyMaskedFunction$LWS = createDistortionToggleSwitchWrapper$LWS(record$LWS.key, toggleSwitchName$LWS, proxyMaskedFunctionDistortion$LWS, originalValue$LWS);
10307
+ // If the distorted API originated in a window created via window.open or
10308
+ // document.open, it may be marked as an unsafe property. If so, we need
10309
+ // to transfer the original value's marker to the wrapped toggle switch
10310
+ // function to ensure that the distortion itself can find the marker when
10311
+ // checking if it needs to be blocked.
10312
+ if (originalValue$LWS[CHILD_WINDOW_BLOCKED_PROPERTY_SYMBOL$LWS]) {
10313
+ const descriptor$LWS = ReflectGetOwnPropertyDescriptor$LWS(originalValue$LWS, CHILD_WINDOW_BLOCKED_PROPERTY_SYMBOL$LWS);
10314
+ ReflectDefineProperty$LWS$1(distortionToggleSwitchWrapperOrProxyMaskedFunction$LWS, CHILD_WINDOW_BLOCKED_PROPERTY_SYMBOL$LWS, descriptor$LWS);
10315
+ }
10316
+ }
10317
+ entries$LWS[entries$LWS.length] = [originalValue$LWS, toggleSwitchName$LWS ? distortionToggleSwitchWrapperOrProxyMaskedFunction$LWS : proxyMaskedFunctionDistortion$LWS];
9988
10318
  } else {
9989
10319
  // istanbul ignore else: current tests have no way of expressing a state that would cause this condition to evaluate false
9990
10320
  if (typeof originalValue$LWS === 'object' && originalValue$LWS !== null) {
@@ -9993,8 +10323,20 @@ function createDistortionEntries$LWS(record$LWS, factories$LWS) {
9993
10323
  entries$LWS[entries$LWS.length] = entry$LWS;
9994
10324
  }
9995
10325
  }
10326
+ if (ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS) {
10327
+ /* 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 */
10328
+ const toggleSwitchName$LWS = distortionFactoryToToggleSwitch$LWS == null ? void 0 : distortionFactoryToToggleSwitch$LWS.get(factory$LWS);
10329
+ if (toggleSwitchName$LWS) {
10330
+ // Map the just added distortion entry to this toggle switch name
10331
+ distortionEntryToToggleSwitch$LWS.set(entries$LWS[entries$LWS.length - 1], toggleSwitchName$LWS);
10332
+ }
10333
+ }
9996
10334
  }
9997
10335
  }
10336
+ if (ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS) {
10337
+ sandboxToDistortionEntryToToggleSwitchRegistry$LWS == null || sandboxToDistortionEntryToToggleSwitchRegistry$LWS.set(record$LWS, distortionEntryToToggleSwitch$LWS);
10338
+ sandboxToDisabledDistortionToggleSwitches$LWS.set(record$LWS, toSafeSet$LWS(new SetCtor$LWS$1()));
10339
+ }
9998
10340
  return entries$LWS;
9999
10341
  }
10000
10342
  function createDistortionMap$LWS(entries$LWS) {
@@ -10030,6 +10372,7 @@ function getDistortionFactories$LWS(record$LWS) {
10030
10372
  addBlockedAttributeDistortionFactoryInitializers$LWS(HTMLIFrameElement$LWS, 'HTMLIFrameElement', HTMLIFrameElementBlockedAttributes$LWS, initializers$LWS);
10031
10373
  addBlockedAttributeDistortionFactoryInitializers$LWS(HTMLScriptElement$LWS, 'HTMLScriptElement', HTMLScriptElementBlockedAttributes$LWS, initializers$LWS);
10032
10374
  addBlockedAttributeDistortionFactoryInitializers$LWS(SVGElement$LWS, 'SVGElement', SVGElementBlockedAttributes$LWS, initializers$LWS);
10375
+ addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, DataTransfer.prototype, DataTransferBlockedProperties$LWS, initializers$LWS);
10033
10376
  addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, Document$LWS.prototype, DocumentBlockedProperties$LWS, initializers$LWS);
10034
10377
  addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, Element$LWS.prototype, ElementBlockedProperties$LWS, initializers$LWS);
10035
10378
  addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, Event$LWS.prototype, EventBlockedProperties$LWS, initializers$LWS);
@@ -10051,7 +10394,19 @@ function getDistortionFactories$LWS(record$LWS) {
10051
10394
  for (let i$LWS = 0, {
10052
10395
  length: length$LWS
10053
10396
  } = factories$LWS; i$LWS < length$LWS; i$LWS += 1) {
10397
+ let toggleSwitchName$LWS;
10398
+ // Restrict this operation to debug/development/coverage mode only
10399
+ if (ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS) {
10400
+ toggleSwitchName$LWS = distortionFactoryInitializerToggleSwitches$LWS.get(initializers$LWS[i$LWS]);
10401
+ }
10054
10402
  factories$LWS[i$LWS] = initializers$LWS[i$LWS](record$LWS);
10403
+ // Restrict this operation to debug/development/coverage mode only.
10404
+ // Since we actually need the _factory_ to when creating the toggle-able
10405
+ // distortion wrapper, map the factory provided by the initializer to the
10406
+ // toggle switch name.
10407
+ if (ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS && toggleSwitchName$LWS) {
10408
+ distortionFactoryToToggleSwitch$LWS == null || distortionFactoryToToggleSwitch$LWS.set(factories$LWS[i$LWS], toggleSwitchName$LWS);
10409
+ }
10055
10410
  }
10056
10411
  // Finalize attribute distortions last because the attribute registry is
10057
10412
  // populated by the other distortion factories.
@@ -14935,9 +15290,9 @@ function createEvalHelpersFactoryArgs$LWS(record$LWS) {
14935
15290
  prototype: HTMLScriptElementProto$LWS
14936
15291
  }
14937
15292
  },
14938
- root: root$LWS
15293
+ root: _root$LWS
14939
15294
  } = record$LWS;
14940
- const isRootRecord$LWS = record$LWS === root$LWS;
15295
+ const isRootRecord$LWS = record$LWS === _root$LWS;
14941
15296
  const forOfStateCache$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1());
14942
15297
  const resourcePromiseCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
14943
15298
  const resourceStatusCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
@@ -15133,7 +15488,7 @@ function toSourceText$LWS(value$LWS, sourceType$LWS) {
15133
15488
  // tools from mistaking the regexp or the replacement string for an
15134
15489
  // actual source mapping URL.
15135
15490
  /\/\/# sandbox(?=MappingURL=.*?\s*$)/, '//# source']);
15136
- sourceText$LWS = `\n//# LWS Version = "0.22.2"\n${sourceText$LWS}`;
15491
+ sourceText$LWS = `\n//# LWS Version = "0.22.4"\n${sourceText$LWS}`;
15137
15492
  return sourceType$LWS === 1 /* SourceType.Module */ && indexOfPragma$LWS(sourceText$LWS, 'use strict') === -1 ?
15138
15493
  // Append "'use strict'" to the extracted function body so it is
15139
15494
  // evaluated in strict mode.
@@ -15220,7 +15575,7 @@ function createVirtualEnvironment$LWS(record$LWS) {
15220
15575
  globalObject: globalObject$LWS,
15221
15576
  instrumentation: instrumentation$LWS,
15222
15577
  key: key$LWS,
15223
- root: root$LWS,
15578
+ root: _root$LWS,
15224
15579
  root: {
15225
15580
  distortions: distortions$LWS
15226
15581
  },
@@ -15281,7 +15636,7 @@ function createVirtualEnvironment$LWS(record$LWS) {
15281
15636
  globalObject: originalTarget$LWS,
15282
15637
  key: key$LWS,
15283
15638
  type: type$LWS
15284
- }, root$LWS);
15639
+ }, _root$LWS);
15285
15640
  return originalTarget$LWS;
15286
15641
  }
15287
15642
  // eslint-disable-next-line no-empty
@@ -15312,7 +15667,7 @@ function createVirtualEnvironment$LWS(record$LWS) {
15312
15667
  globalObject: originalTargetWindow$LWS,
15313
15668
  key: key$LWS,
15314
15669
  type: type$LWS
15315
- }, root$LWS);
15670
+ }, _root$LWS);
15316
15671
  }
15317
15672
  return originalTarget$LWS;
15318
15673
  },
@@ -15323,7 +15678,9 @@ function createVirtualEnvironment$LWS(record$LWS) {
15323
15678
  ObjectAssign$LWS$1({}, DEFAULT_ENDOWMENTS_DESCRIPTOR_MAP$LWS, ObjectGetOwnPropertyDescriptors$LWS(endowments$LWS)) : DEFAULT_ENDOWMENTS_DESCRIPTOR_MAP$LWS,
15324
15679
  instrumentation: instrumentation$LWS,
15325
15680
  remapTypedArrays: remapTypedArrays$LWS,
15326
- keepAlive: IFRAME_KEEP_ALIVE_FLAG$LWS,
15681
+ keepAlive:
15682
+ // istanbul ignore next: cannot test isLockerFeatureEnabled
15683
+ !remapTypedArrays$LWS && isLockerFeatureEnabled$LWS('isLockerNextForOmnistudioEnabled') || IFRAME_KEEP_ALIVE_FLAG$LWS,
15327
15684
  liveTargetCallback: isTargetLive$LWS,
15328
15685
  signSourceCallback: sourceText$LWS => trusted.createScript(sourceText$LWS)
15329
15686
  });
@@ -15402,7 +15759,7 @@ function createOpaqueSecondaryWindowSandboxRecord$LWS({
15402
15759
  key: key$LWS,
15403
15760
  // istanbul ignore next: destructured default assignments are not correctly instrumented
15404
15761
  type: type$LWS = /* istannul ignore next: nothing works to ignore these */getDefaultType$LWS(key$LWS)
15405
- }, root$LWS) {
15762
+ }, _root$LWS) {
15406
15763
  const sandboxRegistry$LWS = getOpaqueSandboxRegistry$LWS(globalObject$LWS);
15407
15764
  let record$LWS = sandboxRegistry$LWS[key$LWS];
15408
15765
  // 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
@@ -15415,7 +15772,7 @@ function createOpaqueSecondaryWindowSandboxRecord$LWS({
15415
15772
  LOCKER_VERBOSE_INSTRUMENTATION_FLAG: LOCKER_VERBOSE_INSTRUMENTATION_FLAG$LWS,
15416
15773
  distortions: distortions$LWS,
15417
15774
  instrumentation: instrumentation$LWS
15418
- } = root$LWS;
15775
+ } = _root$LWS;
15419
15776
  record$LWS = {
15420
15777
  BASIC_INSTRUMENTATION_DATA: BASIC_INSTRUMENTATION_DATA$LWS,
15421
15778
  LOCKER_INSTRUMENTATION_FLAG: LOCKER_INSTRUMENTATION_FLAG$LWS,
@@ -15429,7 +15786,7 @@ function createOpaqueSecondaryWindowSandboxRecord$LWS({
15429
15786
  helpers: EMPTY_EVAL_HELPERS$LWS,
15430
15787
  instrumentation: instrumentation$LWS,
15431
15788
  key: key$LWS,
15432
- root: root$LWS,
15789
+ root: _root$LWS,
15433
15790
  sandboxEvaluator: noop$LWS$1,
15434
15791
  type: type$LWS,
15435
15792
  virtualEnvironmentEvaluator: noop$LWS$1
@@ -15462,7 +15819,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15462
15819
  key: key$LWS,
15463
15820
  // istanbul ignore next: destructured default assignments are not correctly instrumented
15464
15821
  type: type$LWS = /* istanbul ignore next: currently unreachable via tests */getDefaultType$LWS(key$LWS)
15465
- }, root$LWS) {
15822
+ }, _root$LWS) {
15466
15823
  const sandboxRegistry$LWS = getSandboxRegistry$LWS(document$LWS);
15467
15824
  let record$LWS = sandboxRegistry$LWS[key$LWS];
15468
15825
  if (record$LWS) {
@@ -15474,7 +15831,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15474
15831
  LOCKER_VERBOSE_INSTRUMENTATION_FLAG: LOCKER_VERBOSE_INSTRUMENTATION_FLAG$LWS,
15475
15832
  distortions: distortions$LWS,
15476
15833
  instrumentation: instrumentation$LWS
15477
- } = root$LWS;
15834
+ } = _root$LWS;
15478
15835
  const {
15479
15836
  location: location$LWS,
15480
15837
  top: top$LWS
@@ -15502,7 +15859,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15502
15859
  helpers: EMPTY_EVAL_HELPERS$LWS,
15503
15860
  instrumentation: instrumentation$LWS,
15504
15861
  key: key$LWS,
15505
- root: root$LWS,
15862
+ root: _root$LWS,
15506
15863
  sandboxEvaluator: noop$LWS$1,
15507
15864
  type: type$LWS,
15508
15865
  virtualEnvironmentEvaluator: noop$LWS$1
@@ -15555,7 +15912,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15555
15912
  globalObject: globalObject$LWS,
15556
15913
  key: key$LWS,
15557
15914
  type: type$LWS
15558
- }, root$LWS);
15915
+ }, _root$LWS);
15559
15916
  }
15560
15917
  } catch (_unused40$LWS) {
15561
15918
  // istanbul ignore next: this is a safety precaution that is unreachable via tests
@@ -15563,7 +15920,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15563
15920
  globalObject: globalObject$LWS,
15564
15921
  key: key$LWS,
15565
15922
  type: type$LWS
15566
- }, root$LWS);
15923
+ }, _root$LWS);
15567
15924
  }
15568
15925
  };
15569
15926
  const frameElement$LWS = ReflectApply$LWS$1(WindowFrameElementGetter$LWS, globalObject$LWS, []);
@@ -15602,7 +15959,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15602
15959
  globalObject: globalObject$LWS,
15603
15960
  key: key$LWS,
15604
15961
  type: type$LWS
15605
- }, root$LWS);
15962
+ }, _root$LWS);
15606
15963
  }
15607
15964
  });
15608
15965
  },
@@ -15821,11 +16178,12 @@ function wrapPlatformResourceLoader$LWS(dep$LWS, key$LWS) {
15821
16178
  const trustedGlobals$LWS = config$LWS.trustedGlobals;
15822
16179
  if ((trustedGlobals$LWS == null ? void 0 : trustedGlobals$LWS.length) > 0) {
15823
16180
  return dep$LWS.loadScript(thisArg$LWS, url$LWS).then(() => {
15824
- const installGlobals$LWS = sandbox$LWS.virtualEnvironmentEvaluator(`(list) => list.forEach(([key, value]) => window[key] = value)`);
15825
- const globals$LWS = [];
15826
- for (let i$LWS = 0; i$LWS < trustedGlobals$LWS.length; i$LWS++) {
15827
- globals$LWS.push([trustedGlobals$LWS[i$LWS], window[trustedGlobals$LWS[i$LWS]]]);
15828
- }
16181
+ const installGlobals$LWS = sandbox$LWS.virtualEnvironmentEvaluator(`(list) => list.forEach(([key, get, set]) => Object.defineProperty(window, key, { get, set, configurable: true, enumerable: true }));`);
16182
+ const globals$LWS = trustedGlobals$LWS.map(globalName$LWS => [globalName$LWS, function get$LWS() {
16183
+ return window[globalName$LWS];
16184
+ }, function set$LWS(value$LWS) {
16185
+ window[globalName$LWS] = value$LWS;
16186
+ }]);
15829
16187
  installGlobals$LWS(globals$LWS);
15830
16188
  });
15831
16189
  }
@@ -15840,7 +16198,7 @@ function wrapPlatformResourceLoader$LWS(dep$LWS, key$LWS) {
15840
16198
  depRegistry$LWS.set(dep$LWS, secureDep$LWS);
15841
16199
  return secureDep$LWS;
15842
16200
  }
15843
- /*! version: 0.22.2 */
16201
+ /*! version: 0.22.4 */
15844
16202
 
15845
16203
  export { $LWS, CORE_SANDBOX_KEY$LWS as CORE_SANDBOX_KEY, createRootWindowSandboxRecord$LWS as createRootWindowSandboxRecord, evaluateFunction$LWS as evaluateFunction, evaluateInCoreSandbox$LWS as evaluateInCoreSandbox, evaluateInSandbox$LWS as evaluateInSandbox, trusted, wrapDependency$LWS as wrapDependency };
15846
16204
  //# sourceMappingURL=lockerSandbox.js.map