@lwrjs/client-modules 0.13.0-alpha.25 → 0.13.0-alpha.27

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
  }
@@ -1461,7 +1489,7 @@ const {
1461
1489
  } = PromiseCtor$LWS.prototype;
1462
1490
  const PromiseResolve$LWS = PromiseCtor$LWS.resolve.bind(PromiseCtor$LWS);
1463
1491
  const PromiseReject$LWS = PromiseCtor$LWS.reject.bind(PromiseCtor$LWS);
1464
- /*! version: 0.22.3 */
1492
+ /*! version: 0.22.4 */
1465
1493
 
1466
1494
  /*!
1467
1495
  * Copyright (C) 2019 salesforce.com, inc.
@@ -1676,6 +1704,7 @@ function initWindowOpenChildWindow$LWS(win$LWS, url$LWS) {
1676
1704
  // than `url`.
1677
1705
  // `location.href` is a non-configurable property so can be accessed
1678
1706
  // directly.
1707
+ // istanbul ignore else: current tests have no way of expressing a state that would cause this condition to evaluate false
1679
1708
  if (location$LWS.href !== url$LWS) {
1680
1709
  // Opening and closing `doc` prevents the default browser
1681
1710
  // redirect behavior.
@@ -1690,6 +1719,57 @@ function initWindowOpenChildWindow$LWS(win$LWS, url$LWS) {
1690
1719
  }
1691
1720
  return win$LWS;
1692
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
+ }
1693
1773
  function isWindow$LWS(value$LWS) {
1694
1774
  if (typeof value$LWS === 'object' && value$LWS !== null && ObjectHasOwn$LWS$1(value$LWS, 'window') && value$LWS.window === value$LWS) {
1695
1775
  // Slower check that must certainly detect a window object.
@@ -1767,6 +1847,9 @@ class Validator$LWS {
1767
1847
  ReflectApply$LWS$1(ElementProtoInnerHTMLSetter$LWS, this._templates.right, [rightString$LWS]);
1768
1848
  return deepIsEqualNode$LWS(this._templates.left, this._templates.right);
1769
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']);
1770
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, []);
1771
1854
  this._constructors = {
1772
1855
  HTMLLinkElement: HTMLLinkElement$LWS,
@@ -2120,7 +2203,7 @@ const {
2120
2203
  const XhrProtoResponseTextGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'responseText');
2121
2204
  const XhrProtoStatusGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'status');
2122
2205
  ObjectLookupOwnSetter$LWS(XhrProto$LWS, 'withCredentials');
2123
- /*! version: 0.22.3 */
2206
+ /*! version: 0.22.4 */
2124
2207
 
2125
2208
  /*!
2126
2209
  * Copyright (C) 2019 salesforce.com, inc.
@@ -2179,7 +2262,7 @@ function sanitizeURLForElement$LWS(url$LWS) {
2179
2262
  function sanitizeURLString$LWS(urlString$LWS) {
2180
2263
  return urlString$LWS === '' ? urlString$LWS : ReflectApply$LWS$1(StringProtoReplace$LWS, urlString$LWS, [newlinesAndTabsRegExp$LWS, '']);
2181
2264
  }
2182
- /*! version: 0.22.3 */
2265
+ /*! version: 0.22.4 */
2183
2266
 
2184
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 */
2185
2268
 
@@ -3865,7 +3948,7 @@ try {
3865
3948
  // swallow
3866
3949
  }
3867
3950
  const trusted = createPolicy('trusted', policyOptions);
3868
- /*! version: 0.22.3 */
3951
+ /*! version: 0.22.4 */
3869
3952
 
3870
3953
  /*!
3871
3954
  * Copyright (C) 2019 salesforce.com, inc.
@@ -3945,6 +4028,7 @@ function createSantizerHooksRegistry$LWS(sandboxKey$LWS) {
3945
4028
  const {
3946
4029
  tagName: tagName$LWS
3947
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
3948
4032
  const tagNameCheck$LWS = config$LWS == null || (_config$CUSTOM_ELEMEN$LWS = config$LWS.CUSTOM_ELEMENT_HANDLING) == null ? void 0 : _config$CUSTOM_ELEMEN$LWS.tagNameCheck;
3949
4033
  if (tagNameCheck$LWS && ReflectApply$LWS$1(RegExpProtoTest$LWS$1, tagNameCheck$LWS, [tagName$LWS]) &&
3950
4034
  // This MUST be called ONLY after we've ensured the previous
@@ -4113,6 +4197,7 @@ function uponSanitizeAttribute$LWS(node$LWS, data$LWS, _config$LWS) {
4113
4197
  // https://lit.dev/docs/components/events/
4114
4198
  // https://lit.dev/docs/templates/expressions/#property-expressions
4115
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
4116
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, ['?']))) {
4117
4202
  data$LWS.forceKeepAttr = true;
4118
4203
  }
@@ -4124,7 +4209,7 @@ function blobSanitizer$LWS(sandboxKey$LWS) {
4124
4209
  }
4125
4210
  return getSanitizerForConfig$LWS(sandboxKey$LWS, 'STRING_BLOB_HTML');
4126
4211
  }
4127
- /*! version: 0.22.3 */
4212
+ /*! version: 0.22.4 */
4128
4213
 
4129
4214
  /*!
4130
4215
  * Copyright (C) 2023 salesforce.com, inc.
@@ -4322,7 +4407,7 @@ function encloseSrcSetter$LWS(targetElement$LWS) {
4322
4407
  ReflectApply$LWS$1(ElementProtoSetAttributeNS$LWS, targetElement$LWS, [attributeNamespaceURI$LWS, attributeName$LWS, src$LWS]);
4323
4408
  };
4324
4409
  }
4325
- /*! version: 0.22.3 */
4410
+ /*! version: 0.22.4 */
4326
4411
 
4327
4412
  /*!
4328
4413
  * Copyright (C) 2019 salesforce.com, inc.
@@ -4377,8 +4462,12 @@ class VirtualRegistry$LWS {
4377
4462
  } else {
4378
4463
  // When there is already a PivotCtor for the given tagName, we need to ensure that
4379
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)
4380
4469
  const {
4381
- formAssociated: formAssociated$LWS = false
4470
+ formAssociated: formAssociated$LWS
4382
4471
  } = definition$LWS;
4383
4472
  if (PivotCtor$LWS.formAssociated !== formAssociated$LWS) {
4384
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}>`);
@@ -5214,6 +5303,45 @@ function initDistortionAuraUtilGlobalEval$LWS({
5214
5303
  }];
5215
5304
  };
5216
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
+ }
5217
5345
 
5218
5346
  /* istanbul ignore next: only available in secure context */
5219
5347
  function initDistortionCacheStorageDelete$LWS({
@@ -5923,6 +6051,9 @@ function initDistortionDocumentExecCommand$LWS({
5923
6051
  if (loweredCommand$LWS === 'selectall' && this === rootDocument$LWS) {
5924
6052
  throwLockerSecurityError$LWS(command$LWS, this);
5925
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;
5926
6057
  if (length$LWS > 2) {
5927
6058
  const {
5928
6059
  2: unsanitizedValue$LWS
@@ -5987,6 +6118,9 @@ function initDistortionDocumentOpen$LWS({
5987
6118
  // https://developer.mozilla.org/en-US/docs/Web/API/Document/open#three-argument_document.open
5988
6119
  const normalizedArgs$LWS = normalizeWindowOpenArguments$LWS(args$LWS);
5989
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);
5990
6124
  if (childWindow$LWS) {
5991
6125
  initWindowOpenChildWindow$LWS(childWindow$LWS, normalizedArgs$LWS[0]);
5992
6126
  }
@@ -6021,6 +6155,7 @@ function initDistortionDocumentReplaceChildren$LWS({
6021
6155
  }
6022
6156
  function initDistortionDOMParserParseFromString$LWS({
6023
6157
  document: document$LWS,
6158
+ globalObject: globalObject$LWS,
6024
6159
  globalObject: {
6025
6160
  DOMParser: {
6026
6161
  prototype: {
@@ -6033,6 +6168,9 @@ function initDistortionDOMParserParseFromString$LWS({
6033
6168
  key: key$LWS
6034
6169
  }) {
6035
6170
  return [originalParseFromString$LWS, function parseFromString$LWS(...args$LWS) {
6171
+ const {
6172
+ isInherentlyUnsecure: isInherentlyUnsecure$LWS
6173
+ } = getValidator$LWS(document$LWS, globalObject$LWS);
6036
6174
  // DOMParser.prototype.parseFromString can only be called with
6037
6175
  // exactly two arguments. If it receives one argument, it will fail.
6038
6176
  // Some implementations will also fail if it receives more than two
@@ -6044,11 +6182,6 @@ function initDistortionDOMParserParseFromString$LWS({
6044
6182
  // of that argument.
6045
6183
  const string$LWS = toString$LWS(args$LWS[0]);
6046
6184
  const mimeType$LWS = toString$LWS(args$LWS[1]);
6047
- // This must be called to signal to the virtual
6048
- // CustomElementRegistry that the next thing created
6049
- // MAY CONTAIN a custom element, which must be marked for
6050
- // association to this sandbox.
6051
- setCustomElementsRegistry$LWS(document$LWS, key$LWS);
6052
6185
  let contentType$LWS;
6053
6186
  switch (mimeType$LWS) {
6054
6187
  case 'application/xhtml+xml':
@@ -6062,6 +6195,16 @@ function initDistortionDOMParserParseFromString$LWS({
6062
6195
  default:
6063
6196
  contentType$LWS = ContentType$LWS.HTML;
6064
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);
6065
6208
  args$LWS[0] = lwsInternalPolicy$LWS.createHTML(string$LWS, key$LWS, contentType$LWS);
6066
6209
  }
6067
6210
  return ReflectApply$LWS$1(originalParseFromString$LWS, this, args$LWS);
@@ -6320,6 +6463,7 @@ function scriptPropertySetters$LWS(incomingThis$LWS, property$LWS, valueAsTruste
6320
6463
  return false;
6321
6464
  }
6322
6465
  const {
6466
+ isInherentlyUnsecure: isInherentlyUnsecure$3$LWS,
6323
6467
  isSharedElement: isSharedElement$n$LWS
6324
6468
  } = rootValidator$LWS;
6325
6469
  function initDistortionElementInnerHTMLSetter$LWS({
@@ -6363,6 +6507,9 @@ function initDistortionElementInnerHTMLSetter$LWS({
6363
6507
  const contentType$LWS = this instanceof SVGElement$LWS ? ContentType$LWS.SVG : ContentType$LWS.HTML;
6364
6508
  value$LWS = lwsInternalPolicy$LWS.createHTML(value$LWS, key$LWS, contentType$LWS);
6365
6509
  }
6510
+ if (isInherentlyUnsecure$3$LWS(value$LWS)) {
6511
+ throw new LockerSecurityError$LWS(`Cannot set 'innerHTML' using an unsecure ${toSafeTemplateStringValue$LWS(value$LWS)}.`);
6512
+ }
6366
6513
  ReflectApply$LWS$1(originalInnerHTMLSetter$LWS, this, [value$LWS]);
6367
6514
  }];
6368
6515
  };
@@ -6398,6 +6545,7 @@ function initDistortionElementInsertAdjacentElement$LWS({
6398
6545
  };
6399
6546
  }
6400
6547
  const {
6548
+ isInherentlyUnsecure: isInherentlyUnsecure$2$LWS,
6401
6549
  isSharedElement: isSharedElement$l$LWS
6402
6550
  } = rootValidator$LWS;
6403
6551
  const allowedElementHTMLRegExp$LWS = /^\s*<(link|script|style)/i;
@@ -6428,12 +6576,16 @@ function initDistortionElementInsertAdjacentHTML$LWS({
6428
6576
  setCustomElementsRegistry$LWS(document$LWS, key$LWS);
6429
6577
  const contentType$LWS = this instanceof SVGElement ? ContentType$LWS.SVG : ContentType$LWS.HTML;
6430
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
+ }
6431
6582
  }
6432
6583
  ReflectApply$LWS$1(originalInsertAdjacentHTML$LWS, this, args$LWS);
6433
6584
  }];
6434
6585
  };
6435
6586
  }
6436
6587
  const {
6588
+ isInherentlyUnsecure: isInherentlyUnsecure$1$LWS,
6437
6589
  isSharedElement: isSharedElement$k$LWS
6438
6590
  } = rootValidator$LWS;
6439
6591
  function initDistortionElementOuterHTMLSetter$LWS({
@@ -6456,7 +6608,11 @@ function initDistortionElementOuterHTMLSetter$LWS({
6456
6608
  // MAY CONTAIN a custom element, which must be marked for
6457
6609
  // association to this sandbox.
6458
6610
  setCustomElementsRegistry$LWS(document$LWS, key$LWS);
6459
- 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]);
6460
6616
  }];
6461
6617
  };
6462
6618
  }
@@ -6765,6 +6921,7 @@ function initDistortionElementSetAttributeNS$LWS({
6765
6921
  };
6766
6922
  }
6767
6923
  const {
6924
+ isInherentlyUnsecure: isInherentlyUnsecure$LWS,
6768
6925
  isSharedElement: isSharedElement$f$LWS
6769
6926
  } = rootValidator$LWS;
6770
6927
  function initDistortionElementSetHTML$LWS({
@@ -6804,6 +6961,9 @@ function initDistortionElementSetHTML$LWS({
6804
6961
  const value$LWS = args$LWS[0];
6805
6962
  const contentType$LWS = this instanceof SVGElement$LWS ? ContentType$LWS.SVG : ContentType$LWS.HTML;
6806
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
+ }
6807
6967
  }
6808
6968
  ReflectApply$LWS$1(originalSetHTML$LWS, this, args$LWS);
6809
6969
  }];
@@ -6876,9 +7036,13 @@ function initDistortionEval$LWS({
6876
7036
  }
6877
7037
  }) {
6878
7038
  return function distortionEval$LWS({
6879
- sandboxEvaluator: sandboxEvaluator$LWS
7039
+ sandboxEvaluator: sandboxEvaluator$LWS,
7040
+ virtualEnvironmentEvaluator: virtualEnvironmentEvaluator$LWS
6880
7041
  }) {
6881
- 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
+ }];
6882
7046
  };
6883
7047
  }
6884
7048
  function createDistortedComposedPath$LWS(event$LWS, sandboxKey$LWS) {
@@ -6980,9 +7144,11 @@ function initDistortionFunction$LWS({
6980
7144
  }) {
6981
7145
  const funcFooterRegExp$LWS = /\n?}[^}]*$/;
6982
7146
  return function distortionFunction$LWS({
6983
- sandboxEvaluator: sandboxEvaluator$LWS
7147
+ sandboxEvaluator: sandboxEvaluator$LWS,
7148
+ virtualEnvironmentEvaluator: virtualEnvironmentEvaluator$LWS
6984
7149
  }) {
6985
7150
  return [originalFunction$LWS, function Function$LWS(...args$LWS) {
7151
+ throwIfMarkedAsUnsafeInChildWindow$LWS(virtualEnvironmentEvaluator$LWS, 'Function');
6986
7152
  // The `arguments` object has `Symbol.iterator` as an own
6987
7153
  // property, not inherited, so it avoids prototype pollution
6988
7154
  // attacks.
@@ -9083,7 +9249,7 @@ function createDistortionHrefAttributeFactoryInitializer$LWS(attributeName$LWS)
9083
9249
  }
9084
9250
  const initDistortionSVGUseElementHrefAttribute$LWS = createDistortionHrefAttributeFactoryInitializer$LWS('href');
9085
9251
  const initDistortionSVGUseElementXlinkHrefAttribute$LWS = createDistortionHrefAttributeFactoryInitializer$LWS('xlink:href');
9086
- function createTrustedTypesError$LWS(name$LWS = '') {
9252
+ function createTrustedTypesExceptionMessage$LWS(name$LWS) {
9087
9253
  return `Cannot create TrustedTypePolicy with '${name$LWS}' policy name.`;
9088
9254
  }
9089
9255
  function initDistortionTrustedTypePolicyFactoryCreatePolicy$LWS({
@@ -9102,15 +9268,17 @@ function initDistortionTrustedTypePolicyFactoryCreatePolicy$LWS({
9102
9268
  const name$LWS = args$LWS.length ? args$LWS[0] : /* istanbul ignore next: needs default platform behavior test */undefined;
9103
9269
  // istanbul ignore else: needs default platform behavior test
9104
9270
  if (name$LWS === 'default') {
9105
- throw new LockerSecurityError$LWS(createTrustedTypesError$LWS(name$LWS));
9271
+ throw new LockerSecurityError$LWS(createTrustedTypesExceptionMessage$LWS(name$LWS));
9106
9272
  }
9107
9273
  // If the policy is one of the CSP policies, it should be allowed
9108
9274
  try {
9109
9275
  // istanbul ignore next: needs default platform behavior test
9110
9276
  return ReflectApply$LWS$1(originalCreatePolicy$LWS, this, args$LWS);
9111
9277
  } catch (_unused3$LWS) {
9112
- 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.`);
9113
9280
  }
9281
+ // istanbul ignore next: this is tested, but currently cannot be tested in the coverage environment
9114
9282
  return trusted;
9115
9283
  }];
9116
9284
  return function distortionTrustedTypePolicyFactoryCreatePolicy$LWS() {
@@ -9118,6 +9286,7 @@ function initDistortionTrustedTypePolicyFactoryCreatePolicy$LWS({
9118
9286
  };
9119
9287
  }
9120
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)}.`;
9121
9290
  function initDistortionURLCreateObjectURL$LWS({
9122
9291
  document: document$LWS,
9123
9292
  globalObject: globalObject$LWS,
@@ -9133,7 +9302,8 @@ function initDistortionURLCreateObjectURL$LWS({
9133
9302
  // needs to be bound to the global object of the magenta object (arbitrary
9134
9303
  // user-code created global objects).
9135
9304
  const {
9136
- isEqualDomString: isEqualDomString$LWS
9305
+ isEqualDomString: isEqualDomString$LWS,
9306
+ isInherentlyUnsecure: isInherentlyUnsecure$LWS
9137
9307
  } = getValidator$LWS(document$LWS, globalObject$LWS);
9138
9308
  return function distortionURLCreateObjectURL$LWS({
9139
9309
  key: key$LWS
@@ -9179,10 +9349,14 @@ function initDistortionURLCreateObjectURL$LWS({
9179
9349
  throw new LockerSecurityError$LWS(`Unable to verify ${toSafeTemplateStringValue$LWS(blobObject$LWS)} is secure.`);
9180
9350
  }
9181
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
+ }
9182
9356
  const sanitized$LWS = sanitizer$LWS.sanitize(responseText$LWS);
9183
9357
  if (!isEqualDomString$LWS(trusted.createHTML(responseText$LWS), trusted.createHTML(sanitized$LWS))) {
9184
9358
  URLRevokeObjectURL$LWS(outURL$LWS);
9185
- throw new LockerSecurityError$LWS(`Cannot 'createObjectURL' using an unsecure ${toSafeTemplateStringValue$LWS(blobObject$LWS)}.`);
9359
+ throw new LockerSecurityError$LWS(createInsecureBlobErrorMessage$LWS(blobObject$LWS));
9186
9360
  }
9187
9361
  return outURL$LWS;
9188
9362
  }
@@ -9497,6 +9671,9 @@ function initDistortionWindowOpen$LWS({
9497
9671
  const distortionEntry$LWS = [originalWindowOpen$LWS, function open$LWS(...args$LWS) {
9498
9672
  const normalizedArgs$LWS = normalizeWindowOpenArguments$LWS(args$LWS);
9499
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);
9500
9677
  // W-14218118
9501
9678
  // If the target is '_self', '_parent', or '_top', only makes one request
9502
9679
  if (normalizedArgs$LWS.length > 1) {
@@ -9564,9 +9741,11 @@ function initDistortionWindowSetInterval$LWS({
9564
9741
  }
9565
9742
  }) {
9566
9743
  return function distortionWndowSetInterval$LWS({
9567
- sandboxEvaluator: sandboxEvaluator$LWS
9744
+ sandboxEvaluator: sandboxEvaluator$LWS,
9745
+ virtualEnvironmentEvaluator: virtualEnvironmentEvaluator$LWS
9568
9746
  }) {
9569
9747
  return [originalSetInterval$LWS, function setInterval$LWS(...args$LWS) {
9748
+ throwIfMarkedAsUnsafeInChildWindow$LWS(virtualEnvironmentEvaluator$LWS, 'setInterval');
9570
9749
  if (args$LWS.length) {
9571
9750
  const {
9572
9751
  0: callback$LWS
@@ -9597,9 +9776,11 @@ function initDistortionWindowSetTimeout$LWS({
9597
9776
  }
9598
9777
  }) {
9599
9778
  return function distortionWindowSetTimeout$LWS({
9600
- sandboxEvaluator: sandboxEvaluator$LWS
9779
+ sandboxEvaluator: sandboxEvaluator$LWS,
9780
+ virtualEnvironmentEvaluator: virtualEnvironmentEvaluator$LWS
9601
9781
  }) {
9602
9782
  return [originalSetTimeout$LWS, function setTimeout$LWS(...args$LWS) {
9783
+ throwIfMarkedAsUnsafeInChildWindow$LWS(virtualEnvironmentEvaluator$LWS, 'setTimeout');
9603
9784
  if (args$LWS.length) {
9604
9785
  const {
9605
9786
  0: callback$LWS
@@ -9784,6 +9965,8 @@ Naming convention for DistortionFactory function types:
9784
9965
  distortion[ObjectName]Proto : used for the object prototype itself
9785
9966
  */
9786
9967
  const internalDistortionFactoryInitializers$LWS = [
9968
+ // BroadcastChannel
9969
+ initDistortionBroadcastChannelPostMessage$LWS,
9787
9970
  // CSSStyleRule
9788
9971
  initDistortionCSSStyleRuleStyleGetter$LWS,
9789
9972
  // Document
@@ -9906,9 +10089,9 @@ initDistortionElementAfter$LWS, initDistortionElementAppend$LWS, initDistortionE
9906
10089
  // initDistortionNodeAppendChild,
9907
10090
  initDistortionNodeInsertBefore$LWS]);
9908
10091
  const externalKeyedDistortionFactoryInitializers$LWS = internalKeyedDistortionFactoryInitializers$LWS;
9909
- 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']]));
9910
- const DocumentBlockedProperties$LWS = ['createProcessingInstruction', 'exitFullscreen', 'fullscreen', 'fullscreenElement', 'fullscreenEnabled', 'mozCancelFullScreen', 'mozFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'onfullscreenchange', 'onfullscreenerror', 'onmozfullscreenchange', 'onmozfullscreenerror', 'onrejectionhandled', 'onunhandledrejection', 'releaseCapture', 'releaseEvents', 'webkitFullScreenKeyboardInputAllowed', 'write', 'writeln'];
9911
- 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'];
9912
10095
  const EventBlockedProperties$LWS = ['originalTarget', 'explicitOriginalTarget'];
9913
10096
  const HTMLElementBlockedAttributes$LWS = ['nonce'];
9914
10097
  const HTMLElementBlockedProperties$LWS = ['nonce', 'onrejectionhandled', 'onunhandledrejection'];
@@ -9925,7 +10108,7 @@ const SVGElementBlockedProperties$LWS = ['nonce'];
9925
10108
  const UIEventBlockedProperties$LWS = ['rangeParent'];
9926
10109
  const WindowBlockedProperties$LWS = ['find', 'requestFileSystem', 'webkitRequestFileSystem'];
9927
10110
  const XSLTProcessorBlockedProperties$LWS = ['transformToDocument', 'transformToFragment'];
9928
- /*! version: 0.22.3 */
10111
+ /*! version: 0.22.4 */
9929
10112
 
9930
10113
  /*!
9931
10114
  * Copyright (C) 2019 salesforce.com, inc.
@@ -9965,15 +10148,143 @@ function getSandboxRegistry$LWS(document$LWS) {
9965
10148
  const LightningWebSecurity$LWS = {
9966
10149
  __proto__: null
9967
10150
  };
9968
- 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
+ }
9969
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
+ }
9970
10281
  const distortionFactoriesCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
9971
10282
  const opaqueWindowPostMessageDistortionFactoryCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
9972
10283
  // WebKit based browsers have a bug that prematurely removes distortion entries
9973
10284
  // from the distortions weak map.
9974
10285
  const SUPPORTS_DISTORTIONS_WEAK_MAP$LWS = !IS_WEBKIT_BROWSER$LWS;
9975
10286
  function createDistortionEntries$LWS(record$LWS, factories$LWS) {
9976
- toSafeMap$LWS$1(new MapCtor$LWS$1());
10287
+ const distortionEntryToToggleSwitch$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1());
9977
10288
  const entries$LWS = [];
9978
10289
  for (let i$LWS = 0, {
9979
10290
  length: length$LWS
@@ -9987,7 +10298,21 @@ function createDistortionEntries$LWS(record$LWS, factories$LWS) {
9987
10298
  } = entry$LWS;
9988
10299
  if (typeof originalValue$LWS === 'function') {
9989
10300
  const proxyMaskedFunctionDistortion$LWS = proxyMaskFunctionDistortion$LWS(record$LWS, factory$LWS, distortedValue$LWS, originalValue$LWS);
9990
- 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];
9991
10316
  } else {
9992
10317
  // istanbul ignore else: current tests have no way of expressing a state that would cause this condition to evaluate false
9993
10318
  if (typeof originalValue$LWS === 'object' && originalValue$LWS !== null) {
@@ -9996,8 +10321,20 @@ function createDistortionEntries$LWS(record$LWS, factories$LWS) {
9996
10321
  entries$LWS[entries$LWS.length] = entry$LWS;
9997
10322
  }
9998
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
+ }
9999
10332
  }
10000
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
+ }
10001
10338
  return entries$LWS;
10002
10339
  }
10003
10340
  function createDistortionMap$LWS(entries$LWS) {
@@ -10055,7 +10392,19 @@ function getDistortionFactories$LWS(record$LWS) {
10055
10392
  for (let i$LWS = 0, {
10056
10393
  length: length$LWS
10057
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
+ }
10058
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
+ }
10059
10408
  }
10060
10409
  // Finalize attribute distortions last because the attribute registry is
10061
10410
  // populated by the other distortion factories.
@@ -14939,9 +15288,9 @@ function createEvalHelpersFactoryArgs$LWS(record$LWS) {
14939
15288
  prototype: HTMLScriptElementProto$LWS
14940
15289
  }
14941
15290
  },
14942
- root: root$LWS
15291
+ root: _root$LWS
14943
15292
  } = record$LWS;
14944
- const isRootRecord$LWS = record$LWS === root$LWS;
15293
+ const isRootRecord$LWS = record$LWS === _root$LWS;
14945
15294
  const forOfStateCache$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1());
14946
15295
  const resourcePromiseCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
14947
15296
  const resourceStatusCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
@@ -15137,7 +15486,7 @@ function toSourceText$LWS(value$LWS, sourceType$LWS) {
15137
15486
  // tools from mistaking the regexp or the replacement string for an
15138
15487
  // actual source mapping URL.
15139
15488
  /\/\/# sandbox(?=MappingURL=.*?\s*$)/, '//# source']);
15140
- sourceText$LWS = `\n//# LWS Version = "0.22.3"\n${sourceText$LWS}`;
15489
+ sourceText$LWS = `\n//# LWS Version = "0.22.4"\n${sourceText$LWS}`;
15141
15490
  return sourceType$LWS === 1 /* SourceType.Module */ && indexOfPragma$LWS(sourceText$LWS, 'use strict') === -1 ?
15142
15491
  // Append "'use strict'" to the extracted function body so it is
15143
15492
  // evaluated in strict mode.
@@ -15224,7 +15573,7 @@ function createVirtualEnvironment$LWS(record$LWS) {
15224
15573
  globalObject: globalObject$LWS,
15225
15574
  instrumentation: instrumentation$LWS,
15226
15575
  key: key$LWS,
15227
- root: root$LWS,
15576
+ root: _root$LWS,
15228
15577
  root: {
15229
15578
  distortions: distortions$LWS
15230
15579
  },
@@ -15285,7 +15634,7 @@ function createVirtualEnvironment$LWS(record$LWS) {
15285
15634
  globalObject: originalTarget$LWS,
15286
15635
  key: key$LWS,
15287
15636
  type: type$LWS
15288
- }, root$LWS);
15637
+ }, _root$LWS);
15289
15638
  return originalTarget$LWS;
15290
15639
  }
15291
15640
  // eslint-disable-next-line no-empty
@@ -15316,7 +15665,7 @@ function createVirtualEnvironment$LWS(record$LWS) {
15316
15665
  globalObject: originalTargetWindow$LWS,
15317
15666
  key: key$LWS,
15318
15667
  type: type$LWS
15319
- }, root$LWS);
15668
+ }, _root$LWS);
15320
15669
  }
15321
15670
  return originalTarget$LWS;
15322
15671
  },
@@ -15327,7 +15676,9 @@ function createVirtualEnvironment$LWS(record$LWS) {
15327
15676
  ObjectAssign$LWS$1({}, DEFAULT_ENDOWMENTS_DESCRIPTOR_MAP$LWS, ObjectGetOwnPropertyDescriptors$LWS(endowments$LWS)) : DEFAULT_ENDOWMENTS_DESCRIPTOR_MAP$LWS,
15328
15677
  instrumentation: instrumentation$LWS,
15329
15678
  remapTypedArrays: remapTypedArrays$LWS,
15330
- keepAlive: !remapTypedArrays$LWS && isLockerFeatureEnabled$LWS('isLockerNextForOmnistudioEnabled') || 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,
15331
15682
  liveTargetCallback: isTargetLive$LWS,
15332
15683
  signSourceCallback: sourceText$LWS => trusted.createScript(sourceText$LWS)
15333
15684
  });
@@ -15406,7 +15757,7 @@ function createOpaqueSecondaryWindowSandboxRecord$LWS({
15406
15757
  key: key$LWS,
15407
15758
  // istanbul ignore next: destructured default assignments are not correctly instrumented
15408
15759
  type: type$LWS = /* istannul ignore next: nothing works to ignore these */getDefaultType$LWS(key$LWS)
15409
- }, root$LWS) {
15760
+ }, _root$LWS) {
15410
15761
  const sandboxRegistry$LWS = getOpaqueSandboxRegistry$LWS(globalObject$LWS);
15411
15762
  let record$LWS = sandboxRegistry$LWS[key$LWS];
15412
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
@@ -15419,7 +15770,7 @@ function createOpaqueSecondaryWindowSandboxRecord$LWS({
15419
15770
  LOCKER_VERBOSE_INSTRUMENTATION_FLAG: LOCKER_VERBOSE_INSTRUMENTATION_FLAG$LWS,
15420
15771
  distortions: distortions$LWS,
15421
15772
  instrumentation: instrumentation$LWS
15422
- } = root$LWS;
15773
+ } = _root$LWS;
15423
15774
  record$LWS = {
15424
15775
  BASIC_INSTRUMENTATION_DATA: BASIC_INSTRUMENTATION_DATA$LWS,
15425
15776
  LOCKER_INSTRUMENTATION_FLAG: LOCKER_INSTRUMENTATION_FLAG$LWS,
@@ -15433,7 +15784,7 @@ function createOpaqueSecondaryWindowSandboxRecord$LWS({
15433
15784
  helpers: EMPTY_EVAL_HELPERS$LWS,
15434
15785
  instrumentation: instrumentation$LWS,
15435
15786
  key: key$LWS,
15436
- root: root$LWS,
15787
+ root: _root$LWS,
15437
15788
  sandboxEvaluator: noop$LWS$1,
15438
15789
  type: type$LWS,
15439
15790
  virtualEnvironmentEvaluator: noop$LWS$1
@@ -15466,7 +15817,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15466
15817
  key: key$LWS,
15467
15818
  // istanbul ignore next: destructured default assignments are not correctly instrumented
15468
15819
  type: type$LWS = /* istanbul ignore next: currently unreachable via tests */getDefaultType$LWS(key$LWS)
15469
- }, root$LWS) {
15820
+ }, _root$LWS) {
15470
15821
  const sandboxRegistry$LWS = getSandboxRegistry$LWS(document$LWS);
15471
15822
  let record$LWS = sandboxRegistry$LWS[key$LWS];
15472
15823
  if (record$LWS) {
@@ -15478,7 +15829,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15478
15829
  LOCKER_VERBOSE_INSTRUMENTATION_FLAG: LOCKER_VERBOSE_INSTRUMENTATION_FLAG$LWS,
15479
15830
  distortions: distortions$LWS,
15480
15831
  instrumentation: instrumentation$LWS
15481
- } = root$LWS;
15832
+ } = _root$LWS;
15482
15833
  const {
15483
15834
  location: location$LWS,
15484
15835
  top: top$LWS
@@ -15506,7 +15857,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15506
15857
  helpers: EMPTY_EVAL_HELPERS$LWS,
15507
15858
  instrumentation: instrumentation$LWS,
15508
15859
  key: key$LWS,
15509
- root: root$LWS,
15860
+ root: _root$LWS,
15510
15861
  sandboxEvaluator: noop$LWS$1,
15511
15862
  type: type$LWS,
15512
15863
  virtualEnvironmentEvaluator: noop$LWS$1
@@ -15559,7 +15910,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15559
15910
  globalObject: globalObject$LWS,
15560
15911
  key: key$LWS,
15561
15912
  type: type$LWS
15562
- }, root$LWS);
15913
+ }, _root$LWS);
15563
15914
  }
15564
15915
  } catch (_unused40$LWS) {
15565
15916
  // istanbul ignore next: this is a safety precaution that is unreachable via tests
@@ -15567,7 +15918,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15567
15918
  globalObject: globalObject$LWS,
15568
15919
  key: key$LWS,
15569
15920
  type: type$LWS
15570
- }, root$LWS);
15921
+ }, _root$LWS);
15571
15922
  }
15572
15923
  };
15573
15924
  const frameElement$LWS = ReflectApply$LWS$1(WindowFrameElementGetter$LWS, globalObject$LWS, []);
@@ -15606,7 +15957,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15606
15957
  globalObject: globalObject$LWS,
15607
15958
  key: key$LWS,
15608
15959
  type: type$LWS
15609
- }, root$LWS);
15960
+ }, _root$LWS);
15610
15961
  }
15611
15962
  });
15612
15963
  },
@@ -15815,7 +16166,7 @@ function wrapPlatformResourceLoader$LWS(dep$LWS, key$LWS) {
15815
16166
  depRegistry$LWS.set(dep$LWS, secureDep$LWS);
15816
16167
  return secureDep$LWS;
15817
16168
  }
15818
- /*! version: 0.22.3 */
16169
+ /*! version: 0.22.4 */
15819
16170
 
15820
16171
  const loaderDefine = globalThis.LWR.define;
15821
16172