@lwrjs/client-modules 0.13.0-alpha.3 → 0.13.0-alpha.30

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.
Files changed (25) hide show
  1. package/build/bundle/prod/lwr/lockerDefine/lockerDefine.js +1 -1
  2. package/build/bundle/prod/lwr/servicesESM/servicesESM.js +1 -1
  3. package/build/es/modules/lwr/declarativeShadow/declarativeShadow.d.ts +2 -0
  4. package/build/es/modules/lwr/declarativeShadow/declarativeShadow.js +27 -0
  5. package/build/es/modules/lwr/environment/environment.d.ts +6 -0
  6. package/build/es/modules/lwr/environment/environment.js +11 -0
  7. package/build/es/modules/lwr/init/init.d.ts +23 -0
  8. package/build/es/modules/lwr/init/init.js +118 -0
  9. package/build/es/modules/lwr/lockerSandbox/lockerSandbox.d.ts +2 -0
  10. package/build/es/modules/lwr/lockerSandbox/lockerSandbox.js +2 -0
  11. package/build/es/modules/lwr/metrics/metrics.d.ts +35 -0
  12. package/build/es/modules/lwr/metrics/metrics.js +39 -0
  13. package/build/es/modules/lwr/profiler/profiler.d.ts +28 -0
  14. package/build/es/modules/lwr/profiler/profiler.js +67 -0
  15. package/build/es/modules/lwr/serverDataCallback/serverDataCallback.d.ts +7 -0
  16. package/build/es/modules/lwr/serverDataCallback/serverDataCallback.js +11 -0
  17. package/build/modules/lwr/hmr/hmr.js +30 -26
  18. package/build/modules/lwr/init/init.js +0 -6
  19. package/build/modules/lwr/lockerDefine/lockerDefine.js +431 -52
  20. package/build/modules/lwr/lockerSandbox/lockerSandbox.js +431 -52
  21. package/build/modules/lwr/metrics/metrics.js +1 -1
  22. package/build/modules/lwr/serverDataCallback/serverDataCallback.js +16 -0
  23. package/build/modules/lwr/servicesESM/servicesESM.js +2 -4
  24. package/package.json +7 -6
  25. package/build/modules/lwr/hmr/util/swap.js +0 -12
@@ -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
  }
@@ -1329,6 +1357,10 @@ const {
1329
1357
  function consoleWarn$LWS(...args$LWS) {
1330
1358
  ReflectApply$LWS$1(consoleWarnRef$LWS, consoleRef$LWS, args$LWS);
1331
1359
  }
1360
+ let gaterEnabledFeatures$LWS = [];
1361
+ function isGaterEnabledFeature$LWS(featureName$LWS) {
1362
+ return ReflectApply$LWS$1(ArrayProtoIncludes$LWS$1, gaterEnabledFeatures$LWS, [`com.salesforce.locker.${featureName$LWS}`]);
1363
+ }
1332
1364
  const trackedLiveTargets$LWS = toSafeWeakSet$LWS$1(new WeakSetCtor$LWS$1());
1333
1365
  function isTargetLive$LWS(target$LWS, targetTraits$LWS = 0 /* TargetTraits.None */) {
1334
1366
  if (targetTraits$LWS & 1 /* TargetTraits.IsArray */ || targetTraits$LWS & 2 /* TargetTraits.IsArrayBufferView */ || targetTraits$LWS & 64 /* TargetTraits.Revoked */ || target$LWS === null || target$LWS === undefined || target$LWS === ObjectProto$LWS$1 || target$LWS === RegExpProto$LWS$1) {
@@ -1410,6 +1442,10 @@ function trackAsLiveTarget$LWS(target$LWS) {
1410
1442
  trackedLiveTargets$LWS.add(target$LWS);
1411
1443
  return target$LWS;
1412
1444
  }
1445
+ const lockerFeatures$LWS = {};
1446
+ function isLockerFeatureEnabled$LWS(featureName$LWS) {
1447
+ return lockerFeatures$LWS[featureName$LWS];
1448
+ }
1413
1449
  const NS_HEAD$LWS = `${LOCKER_SERVICE_KEY$LWS}-`;
1414
1450
  const NS_TAIL$LWS = '$';
1415
1451
  const STORAGE_NS_HEAD$LWS = `${LOCKER_SERVICE_KEY$LWS}[`;
@@ -1453,7 +1489,7 @@ const {
1453
1489
  } = PromiseCtor$LWS.prototype;
1454
1490
  const PromiseResolve$LWS = PromiseCtor$LWS.resolve.bind(PromiseCtor$LWS);
1455
1491
  const PromiseReject$LWS = PromiseCtor$LWS.reject.bind(PromiseCtor$LWS);
1456
- /*! version: 0.22.1 */
1492
+ /*! version: 0.22.4 */
1457
1493
 
1458
1494
  /*!
1459
1495
  * Copyright (C) 2019 salesforce.com, inc.
@@ -1668,6 +1704,7 @@ function initWindowOpenChildWindow$LWS(win$LWS, url$LWS) {
1668
1704
  // than `url`.
1669
1705
  // `location.href` is a non-configurable property so can be accessed
1670
1706
  // directly.
1707
+ // istanbul ignore else: current tests have no way of expressing a state that would cause this condition to evaluate false
1671
1708
  if (location$LWS.href !== url$LWS) {
1672
1709
  // Opening and closing `doc` prevents the default browser
1673
1710
  // redirect behavior.
@@ -1682,6 +1719,57 @@ function initWindowOpenChildWindow$LWS(win$LWS, url$LWS) {
1682
1719
  }
1683
1720
  return win$LWS;
1684
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
+ }
1685
1773
  function isWindow$LWS(value$LWS) {
1686
1774
  if (typeof value$LWS === 'object' && value$LWS !== null && ObjectHasOwn$LWS$1(value$LWS, 'window') && value$LWS.window === value$LWS) {
1687
1775
  // Slower check that must certainly detect a window object.
@@ -1759,6 +1847,9 @@ class Validator$LWS {
1759
1847
  ReflectApply$LWS$1(ElementProtoInnerHTMLSetter$LWS, this._templates.right, [rightString$LWS]);
1760
1848
  return deepIsEqualNode$LWS(this._templates.left, this._templates.right);
1761
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']);
1762
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, []);
1763
1854
  this._constructors = {
1764
1855
  HTMLLinkElement: HTMLLinkElement$LWS,
@@ -2112,7 +2203,7 @@ const {
2112
2203
  const XhrProtoResponseTextGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'responseText');
2113
2204
  const XhrProtoStatusGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'status');
2114
2205
  ObjectLookupOwnSetter$LWS(XhrProto$LWS, 'withCredentials');
2115
- /*! version: 0.22.1 */
2206
+ /*! version: 0.22.4 */
2116
2207
 
2117
2208
  /*!
2118
2209
  * Copyright (C) 2019 salesforce.com, inc.
@@ -2171,7 +2262,7 @@ function sanitizeURLForElement$LWS(url$LWS) {
2171
2262
  function sanitizeURLString$LWS(urlString$LWS) {
2172
2263
  return urlString$LWS === '' ? urlString$LWS : ReflectApply$LWS$1(StringProtoReplace$LWS, urlString$LWS, [newlinesAndTabsRegExp$LWS, '']);
2173
2264
  }
2174
- /*! version: 0.22.1 */
2265
+ /*! version: 0.22.4 */
2175
2266
 
2176
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 */
2177
2268
 
@@ -3857,7 +3948,7 @@ try {
3857
3948
  // swallow
3858
3949
  }
3859
3950
  const trusted = createPolicy('trusted', policyOptions);
3860
- /*! version: 0.22.1 */
3951
+ /*! version: 0.22.4 */
3861
3952
 
3862
3953
  /*!
3863
3954
  * Copyright (C) 2019 salesforce.com, inc.
@@ -3937,6 +4028,7 @@ function createSantizerHooksRegistry$LWS(sandboxKey$LWS) {
3937
4028
  const {
3938
4029
  tagName: tagName$LWS
3939
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
3940
4032
  const tagNameCheck$LWS = config$LWS == null || (_config$CUSTOM_ELEMEN$LWS = config$LWS.CUSTOM_ELEMENT_HANDLING) == null ? void 0 : _config$CUSTOM_ELEMEN$LWS.tagNameCheck;
3941
4033
  if (tagNameCheck$LWS && ReflectApply$LWS$1(RegExpProtoTest$LWS$1, tagNameCheck$LWS, [tagName$LWS]) &&
3942
4034
  // This MUST be called ONLY after we've ensured the previous
@@ -4105,6 +4197,7 @@ function uponSanitizeAttribute$LWS(node$LWS, data$LWS, _config$LWS) {
4105
4197
  // https://lit.dev/docs/components/events/
4106
4198
  // https://lit.dev/docs/templates/expressions/#property-expressions
4107
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
4108
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, ['?']))) {
4109
4202
  data$LWS.forceKeepAttr = true;
4110
4203
  }
@@ -4116,7 +4209,7 @@ function blobSanitizer$LWS(sandboxKey$LWS) {
4116
4209
  }
4117
4210
  return getSanitizerForConfig$LWS(sandboxKey$LWS, 'STRING_BLOB_HTML');
4118
4211
  }
4119
- /*! version: 0.22.1 */
4212
+ /*! version: 0.22.4 */
4120
4213
 
4121
4214
  /*!
4122
4215
  * Copyright (C) 2023 salesforce.com, inc.
@@ -4314,7 +4407,7 @@ function encloseSrcSetter$LWS(targetElement$LWS) {
4314
4407
  ReflectApply$LWS$1(ElementProtoSetAttributeNS$LWS, targetElement$LWS, [attributeNamespaceURI$LWS, attributeName$LWS, src$LWS]);
4315
4408
  };
4316
4409
  }
4317
- /*! version: 0.22.1 */
4410
+ /*! version: 0.22.4 */
4318
4411
 
4319
4412
  /*!
4320
4413
  * Copyright (C) 2019 salesforce.com, inc.
@@ -4369,8 +4462,12 @@ class VirtualRegistry$LWS {
4369
4462
  } else {
4370
4463
  // When there is already a PivotCtor for the given tagName, we need to ensure that
4371
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)
4372
4469
  const {
4373
- formAssociated: formAssociated$LWS = false
4470
+ formAssociated: formAssociated$LWS
4374
4471
  } = definition$LWS;
4375
4472
  if (PivotCtor$LWS.formAssociated !== formAssociated$LWS) {
4376
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}>`);
@@ -5055,6 +5152,7 @@ document$LWS = globalObject$LWS.document) {
5055
5152
  function setCustomElementsRegistry$LWS(document$LWS, key$LWS) {
5056
5153
  currentRegistry$LWS = getSandboxCustomElementRegistry$LWS(document$LWS, key$LWS);
5057
5154
  }
5155
+ const DataTransferBlockedProperties$LWS = ['mozCursor', 'mozSourceNode', 'mozUserCancelled'];
5058
5156
  const attributeDistortionFactoriesCache$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1());
5059
5157
  const sandboxAttributeDistortionRegistryCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
5060
5158
  function finalizeAttributeDistortions$LWS(record$LWS) {
@@ -5205,6 +5303,45 @@ function initDistortionAuraUtilGlobalEval$LWS({
5205
5303
  }];
5206
5304
  };
5207
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
+ }
5208
5345
 
5209
5346
  /* istanbul ignore next: only available in secure context */
5210
5347
  function initDistortionCacheStorageDelete$LWS({
@@ -5914,6 +6051,9 @@ function initDistortionDocumentExecCommand$LWS({
5914
6051
  if (loweredCommand$LWS === 'selectall' && this === rootDocument$LWS) {
5915
6052
  throwLockerSecurityError$LWS(command$LWS, this);
5916
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;
5917
6057
  if (length$LWS > 2) {
5918
6058
  const {
5919
6059
  2: unsanitizedValue$LWS
@@ -5978,6 +6118,9 @@ function initDistortionDocumentOpen$LWS({
5978
6118
  // https://developer.mozilla.org/en-US/docs/Web/API/Document/open#three-argument_document.open
5979
6119
  const normalizedArgs$LWS = normalizeWindowOpenArguments$LWS(args$LWS);
5980
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);
5981
6124
  if (childWindow$LWS) {
5982
6125
  initWindowOpenChildWindow$LWS(childWindow$LWS, normalizedArgs$LWS[0]);
5983
6126
  }
@@ -6012,6 +6155,7 @@ function initDistortionDocumentReplaceChildren$LWS({
6012
6155
  }
6013
6156
  function initDistortionDOMParserParseFromString$LWS({
6014
6157
  document: document$LWS,
6158
+ globalObject: globalObject$LWS,
6015
6159
  globalObject: {
6016
6160
  DOMParser: {
6017
6161
  prototype: {
@@ -6024,6 +6168,9 @@ function initDistortionDOMParserParseFromString$LWS({
6024
6168
  key: key$LWS
6025
6169
  }) {
6026
6170
  return [originalParseFromString$LWS, function parseFromString$LWS(...args$LWS) {
6171
+ const {
6172
+ isInherentlyUnsecure: isInherentlyUnsecure$LWS
6173
+ } = getValidator$LWS(document$LWS, globalObject$LWS);
6027
6174
  // DOMParser.prototype.parseFromString can only be called with
6028
6175
  // exactly two arguments. If it receives one argument, it will fail.
6029
6176
  // Some implementations will also fail if it receives more than two
@@ -6035,11 +6182,6 @@ function initDistortionDOMParserParseFromString$LWS({
6035
6182
  // of that argument.
6036
6183
  const string$LWS = toString$LWS(args$LWS[0]);
6037
6184
  const mimeType$LWS = toString$LWS(args$LWS[1]);
6038
- // This must be called to signal to the virtual
6039
- // CustomElementRegistry that the next thing created
6040
- // MAY CONTAIN a custom element, which must be marked for
6041
- // association to this sandbox.
6042
- setCustomElementsRegistry$LWS(document$LWS, key$LWS);
6043
6185
  let contentType$LWS;
6044
6186
  switch (mimeType$LWS) {
6045
6187
  case 'application/xhtml+xml':
@@ -6053,6 +6195,16 @@ function initDistortionDOMParserParseFromString$LWS({
6053
6195
  default:
6054
6196
  contentType$LWS = ContentType$LWS.HTML;
6055
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);
6056
6208
  args$LWS[0] = lwsInternalPolicy$LWS.createHTML(string$LWS, key$LWS, contentType$LWS);
6057
6209
  }
6058
6210
  return ReflectApply$LWS$1(originalParseFromString$LWS, this, args$LWS);
@@ -6311,6 +6463,7 @@ function scriptPropertySetters$LWS(incomingThis$LWS, property$LWS, valueAsTruste
6311
6463
  return false;
6312
6464
  }
6313
6465
  const {
6466
+ isInherentlyUnsecure: isInherentlyUnsecure$3$LWS,
6314
6467
  isSharedElement: isSharedElement$n$LWS
6315
6468
  } = rootValidator$LWS;
6316
6469
  function initDistortionElementInnerHTMLSetter$LWS({
@@ -6354,6 +6507,9 @@ function initDistortionElementInnerHTMLSetter$LWS({
6354
6507
  const contentType$LWS = this instanceof SVGElement$LWS ? ContentType$LWS.SVG : ContentType$LWS.HTML;
6355
6508
  value$LWS = lwsInternalPolicy$LWS.createHTML(value$LWS, key$LWS, contentType$LWS);
6356
6509
  }
6510
+ if (isInherentlyUnsecure$3$LWS(value$LWS)) {
6511
+ throw new LockerSecurityError$LWS(`Cannot set 'innerHTML' using an unsecure ${toSafeTemplateStringValue$LWS(value$LWS)}.`);
6512
+ }
6357
6513
  ReflectApply$LWS$1(originalInnerHTMLSetter$LWS, this, [value$LWS]);
6358
6514
  }];
6359
6515
  };
@@ -6389,6 +6545,7 @@ function initDistortionElementInsertAdjacentElement$LWS({
6389
6545
  };
6390
6546
  }
6391
6547
  const {
6548
+ isInherentlyUnsecure: isInherentlyUnsecure$2$LWS,
6392
6549
  isSharedElement: isSharedElement$l$LWS
6393
6550
  } = rootValidator$LWS;
6394
6551
  const allowedElementHTMLRegExp$LWS = /^\s*<(link|script|style)/i;
@@ -6419,12 +6576,16 @@ function initDistortionElementInsertAdjacentHTML$LWS({
6419
6576
  setCustomElementsRegistry$LWS(document$LWS, key$LWS);
6420
6577
  const contentType$LWS = this instanceof SVGElement ? ContentType$LWS.SVG : ContentType$LWS.HTML;
6421
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
+ }
6422
6582
  }
6423
6583
  ReflectApply$LWS$1(originalInsertAdjacentHTML$LWS, this, args$LWS);
6424
6584
  }];
6425
6585
  };
6426
6586
  }
6427
6587
  const {
6588
+ isInherentlyUnsecure: isInherentlyUnsecure$1$LWS,
6428
6589
  isSharedElement: isSharedElement$k$LWS
6429
6590
  } = rootValidator$LWS;
6430
6591
  function initDistortionElementOuterHTMLSetter$LWS({
@@ -6447,7 +6608,11 @@ function initDistortionElementOuterHTMLSetter$LWS({
6447
6608
  // MAY CONTAIN a custom element, which must be marked for
6448
6609
  // association to this sandbox.
6449
6610
  setCustomElementsRegistry$LWS(document$LWS, key$LWS);
6450
- 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]);
6451
6616
  }];
6452
6617
  };
6453
6618
  }
@@ -6756,6 +6921,7 @@ function initDistortionElementSetAttributeNS$LWS({
6756
6921
  };
6757
6922
  }
6758
6923
  const {
6924
+ isInherentlyUnsecure: isInherentlyUnsecure$LWS,
6759
6925
  isSharedElement: isSharedElement$f$LWS
6760
6926
  } = rootValidator$LWS;
6761
6927
  function initDistortionElementSetHTML$LWS({
@@ -6795,6 +6961,9 @@ function initDistortionElementSetHTML$LWS({
6795
6961
  const value$LWS = args$LWS[0];
6796
6962
  const contentType$LWS = this instanceof SVGElement$LWS ? ContentType$LWS.SVG : ContentType$LWS.HTML;
6797
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
+ }
6798
6967
  }
6799
6968
  ReflectApply$LWS$1(originalSetHTML$LWS, this, args$LWS);
6800
6969
  }];
@@ -6867,9 +7036,13 @@ function initDistortionEval$LWS({
6867
7036
  }
6868
7037
  }) {
6869
7038
  return function distortionEval$LWS({
6870
- sandboxEvaluator: sandboxEvaluator$LWS
7039
+ sandboxEvaluator: sandboxEvaluator$LWS,
7040
+ virtualEnvironmentEvaluator: virtualEnvironmentEvaluator$LWS
6871
7041
  }) {
6872
- 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
+ }];
6873
7046
  };
6874
7047
  }
6875
7048
  function createDistortedComposedPath$LWS(event$LWS, sandboxKey$LWS) {
@@ -6971,9 +7144,11 @@ function initDistortionFunction$LWS({
6971
7144
  }) {
6972
7145
  const funcFooterRegExp$LWS = /\n?}[^}]*$/;
6973
7146
  return function distortionFunction$LWS({
6974
- sandboxEvaluator: sandboxEvaluator$LWS
7147
+ sandboxEvaluator: sandboxEvaluator$LWS,
7148
+ virtualEnvironmentEvaluator: virtualEnvironmentEvaluator$LWS
6975
7149
  }) {
6976
7150
  return [originalFunction$LWS, function Function$LWS(...args$LWS) {
7151
+ throwIfMarkedAsUnsafeInChildWindow$LWS(virtualEnvironmentEvaluator$LWS, 'Function');
6977
7152
  // The `arguments` object has `Symbol.iterator` as an own
6978
7153
  // property, not inherited, so it avoids prototype pollution
6979
7154
  // attacks.
@@ -9074,7 +9249,7 @@ function createDistortionHrefAttributeFactoryInitializer$LWS(attributeName$LWS)
9074
9249
  }
9075
9250
  const initDistortionSVGUseElementHrefAttribute$LWS = createDistortionHrefAttributeFactoryInitializer$LWS('href');
9076
9251
  const initDistortionSVGUseElementXlinkHrefAttribute$LWS = createDistortionHrefAttributeFactoryInitializer$LWS('xlink:href');
9077
- function createTrustedTypesError$LWS(name$LWS = '') {
9252
+ function createTrustedTypesExceptionMessage$LWS(name$LWS) {
9078
9253
  return `Cannot create TrustedTypePolicy with '${name$LWS}' policy name.`;
9079
9254
  }
9080
9255
  function initDistortionTrustedTypePolicyFactoryCreatePolicy$LWS({
@@ -9093,15 +9268,17 @@ function initDistortionTrustedTypePolicyFactoryCreatePolicy$LWS({
9093
9268
  const name$LWS = args$LWS.length ? args$LWS[0] : /* istanbul ignore next: needs default platform behavior test */undefined;
9094
9269
  // istanbul ignore else: needs default platform behavior test
9095
9270
  if (name$LWS === 'default') {
9096
- throw new LockerSecurityError$LWS(createTrustedTypesError$LWS(name$LWS));
9271
+ throw new LockerSecurityError$LWS(createTrustedTypesExceptionMessage$LWS(name$LWS));
9097
9272
  }
9098
9273
  // If the policy is one of the CSP policies, it should be allowed
9099
9274
  try {
9100
9275
  // istanbul ignore next: needs default platform behavior test
9101
9276
  return ReflectApply$LWS$1(originalCreatePolicy$LWS, this, args$LWS);
9102
9277
  } catch (_unused3$LWS) {
9103
- 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.`);
9104
9280
  }
9281
+ // istanbul ignore next: this is tested, but currently cannot be tested in the coverage environment
9105
9282
  return trusted;
9106
9283
  }];
9107
9284
  return function distortionTrustedTypePolicyFactoryCreatePolicy$LWS() {
@@ -9109,6 +9286,7 @@ function initDistortionTrustedTypePolicyFactoryCreatePolicy$LWS({
9109
9286
  };
9110
9287
  }
9111
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)}.`;
9112
9290
  function initDistortionURLCreateObjectURL$LWS({
9113
9291
  document: document$LWS,
9114
9292
  globalObject: globalObject$LWS,
@@ -9124,7 +9302,8 @@ function initDistortionURLCreateObjectURL$LWS({
9124
9302
  // needs to be bound to the global object of the magenta object (arbitrary
9125
9303
  // user-code created global objects).
9126
9304
  const {
9127
- isEqualDomString: isEqualDomString$LWS
9305
+ isEqualDomString: isEqualDomString$LWS,
9306
+ isInherentlyUnsecure: isInherentlyUnsecure$LWS
9128
9307
  } = getValidator$LWS(document$LWS, globalObject$LWS);
9129
9308
  return function distortionURLCreateObjectURL$LWS({
9130
9309
  key: key$LWS
@@ -9170,10 +9349,14 @@ function initDistortionURLCreateObjectURL$LWS({
9170
9349
  throw new LockerSecurityError$LWS(`Unable to verify ${toSafeTemplateStringValue$LWS(blobObject$LWS)} is secure.`);
9171
9350
  }
9172
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
+ }
9173
9356
  const sanitized$LWS = sanitizer$LWS.sanitize(responseText$LWS);
9174
9357
  if (!isEqualDomString$LWS(trusted.createHTML(responseText$LWS), trusted.createHTML(sanitized$LWS))) {
9175
9358
  URLRevokeObjectURL$LWS(outURL$LWS);
9176
- throw new LockerSecurityError$LWS(`Cannot 'createObjectURL' using an unsecure ${toSafeTemplateStringValue$LWS(blobObject$LWS)}.`);
9359
+ throw new LockerSecurityError$LWS(createInsecureBlobErrorMessage$LWS(blobObject$LWS));
9177
9360
  }
9178
9361
  return outURL$LWS;
9179
9362
  }
@@ -9488,6 +9671,9 @@ function initDistortionWindowOpen$LWS({
9488
9671
  const distortionEntry$LWS = [originalWindowOpen$LWS, function open$LWS(...args$LWS) {
9489
9672
  const normalizedArgs$LWS = normalizeWindowOpenArguments$LWS(args$LWS);
9490
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);
9491
9677
  // W-14218118
9492
9678
  // If the target is '_self', '_parent', or '_top', only makes one request
9493
9679
  if (normalizedArgs$LWS.length > 1) {
@@ -9555,9 +9741,11 @@ function initDistortionWindowSetInterval$LWS({
9555
9741
  }
9556
9742
  }) {
9557
9743
  return function distortionWndowSetInterval$LWS({
9558
- sandboxEvaluator: sandboxEvaluator$LWS
9744
+ sandboxEvaluator: sandboxEvaluator$LWS,
9745
+ virtualEnvironmentEvaluator: virtualEnvironmentEvaluator$LWS
9559
9746
  }) {
9560
9747
  return [originalSetInterval$LWS, function setInterval$LWS(...args$LWS) {
9748
+ throwIfMarkedAsUnsafeInChildWindow$LWS(virtualEnvironmentEvaluator$LWS, 'setInterval');
9561
9749
  if (args$LWS.length) {
9562
9750
  const {
9563
9751
  0: callback$LWS
@@ -9588,9 +9776,11 @@ function initDistortionWindowSetTimeout$LWS({
9588
9776
  }
9589
9777
  }) {
9590
9778
  return function distortionWindowSetTimeout$LWS({
9591
- sandboxEvaluator: sandboxEvaluator$LWS
9779
+ sandboxEvaluator: sandboxEvaluator$LWS,
9780
+ virtualEnvironmentEvaluator: virtualEnvironmentEvaluator$LWS
9592
9781
  }) {
9593
9782
  return [originalSetTimeout$LWS, function setTimeout$LWS(...args$LWS) {
9783
+ throwIfMarkedAsUnsafeInChildWindow$LWS(virtualEnvironmentEvaluator$LWS, 'setTimeout');
9594
9784
  if (args$LWS.length) {
9595
9785
  const {
9596
9786
  0: callback$LWS
@@ -9775,6 +9965,8 @@ Naming convention for DistortionFactory function types:
9775
9965
  distortion[ObjectName]Proto : used for the object prototype itself
9776
9966
  */
9777
9967
  const internalDistortionFactoryInitializers$LWS = [
9968
+ // BroadcastChannel
9969
+ initDistortionBroadcastChannelPostMessage$LWS,
9778
9970
  // CSSStyleRule
9779
9971
  initDistortionCSSStyleRuleStyleGetter$LWS,
9780
9972
  // Document
@@ -9897,9 +10089,9 @@ initDistortionElementAfter$LWS, initDistortionElementAppend$LWS, initDistortionE
9897
10089
  // initDistortionNodeAppendChild,
9898
10090
  initDistortionNodeInsertBefore$LWS]);
9899
10091
  const externalKeyedDistortionFactoryInitializers$LWS = internalKeyedDistortionFactoryInitializers$LWS;
9900
- 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']]));
9901
- const DocumentBlockedProperties$LWS = ['createProcessingInstruction', 'exitFullscreen', 'fullscreen', 'fullscreenElement', 'fullscreenEnabled', 'mozCancelFullScreen', 'mozFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'onfullscreenchange', 'onfullscreenerror', 'onmozfullscreenchange', 'onmozfullscreenerror', 'onrejectionhandled', 'onunhandledrejection', 'releaseCapture', 'releaseEvents', 'webkitFullScreenKeyboardInputAllowed', 'write', 'writeln'];
9902
- 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'];
9903
10095
  const EventBlockedProperties$LWS = ['originalTarget', 'explicitOriginalTarget'];
9904
10096
  const HTMLElementBlockedAttributes$LWS = ['nonce'];
9905
10097
  const HTMLElementBlockedProperties$LWS = ['nonce', 'onrejectionhandled', 'onunhandledrejection'];
@@ -9916,7 +10108,7 @@ const SVGElementBlockedProperties$LWS = ['nonce'];
9916
10108
  const UIEventBlockedProperties$LWS = ['rangeParent'];
9917
10109
  const WindowBlockedProperties$LWS = ['find', 'requestFileSystem', 'webkitRequestFileSystem'];
9918
10110
  const XSLTProcessorBlockedProperties$LWS = ['transformToDocument', 'transformToFragment'];
9919
- /*! version: 0.22.1 */
10111
+ /*! version: 0.22.4 */
9920
10112
 
9921
10113
  /*!
9922
10114
  * Copyright (C) 2019 salesforce.com, inc.
@@ -9956,17 +10148,145 @@ function getSandboxRegistry$LWS(document$LWS) {
9956
10148
  const LightningWebSecurity$LWS = {
9957
10149
  __proto__: null
9958
10150
  };
9959
- 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
+ }
9960
10251
  ObjectFreeze$LWS$1(LightningWebSecurity$LWS);
9961
10252
  // If ENABLE_DISTORTION_TOGGLE_SWITCHES = false, this will just be undefined
9962
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
+ }
9963
10283
  const distortionFactoriesCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
9964
10284
  const opaqueWindowPostMessageDistortionFactoryCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
9965
10285
  // WebKit based browsers have a bug that prematurely removes distortion entries
9966
10286
  // from the distortions weak map.
9967
10287
  const SUPPORTS_DISTORTIONS_WEAK_MAP$LWS = !IS_WEBKIT_BROWSER$LWS;
9968
10288
  function createDistortionEntries$LWS(record$LWS, factories$LWS) {
9969
- toSafeMap$LWS$1(new MapCtor$LWS$1());
10289
+ const distortionEntryToToggleSwitch$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1());
9970
10290
  const entries$LWS = [];
9971
10291
  for (let i$LWS = 0, {
9972
10292
  length: length$LWS
@@ -9980,7 +10300,21 @@ function createDistortionEntries$LWS(record$LWS, factories$LWS) {
9980
10300
  } = entry$LWS;
9981
10301
  if (typeof originalValue$LWS === 'function') {
9982
10302
  const proxyMaskedFunctionDistortion$LWS = proxyMaskFunctionDistortion$LWS(record$LWS, factory$LWS, distortedValue$LWS, originalValue$LWS);
9983
- 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];
9984
10318
  } else {
9985
10319
  // istanbul ignore else: current tests have no way of expressing a state that would cause this condition to evaluate false
9986
10320
  if (typeof originalValue$LWS === 'object' && originalValue$LWS !== null) {
@@ -9989,8 +10323,20 @@ function createDistortionEntries$LWS(record$LWS, factories$LWS) {
9989
10323
  entries$LWS[entries$LWS.length] = entry$LWS;
9990
10324
  }
9991
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
+ }
9992
10334
  }
9993
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
+ }
9994
10340
  return entries$LWS;
9995
10341
  }
9996
10342
  function createDistortionMap$LWS(entries$LWS) {
@@ -10026,6 +10372,7 @@ function getDistortionFactories$LWS(record$LWS) {
10026
10372
  addBlockedAttributeDistortionFactoryInitializers$LWS(HTMLIFrameElement$LWS, 'HTMLIFrameElement', HTMLIFrameElementBlockedAttributes$LWS, initializers$LWS);
10027
10373
  addBlockedAttributeDistortionFactoryInitializers$LWS(HTMLScriptElement$LWS, 'HTMLScriptElement', HTMLScriptElementBlockedAttributes$LWS, initializers$LWS);
10028
10374
  addBlockedAttributeDistortionFactoryInitializers$LWS(SVGElement$LWS, 'SVGElement', SVGElementBlockedAttributes$LWS, initializers$LWS);
10375
+ addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, DataTransfer.prototype, DataTransferBlockedProperties$LWS, initializers$LWS);
10029
10376
  addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, Document$LWS.prototype, DocumentBlockedProperties$LWS, initializers$LWS);
10030
10377
  addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, Element$LWS.prototype, ElementBlockedProperties$LWS, initializers$LWS);
10031
10378
  addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, Event$LWS.prototype, EventBlockedProperties$LWS, initializers$LWS);
@@ -10047,7 +10394,19 @@ function getDistortionFactories$LWS(record$LWS) {
10047
10394
  for (let i$LWS = 0, {
10048
10395
  length: length$LWS
10049
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
+ }
10050
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
+ }
10051
10410
  }
10052
10411
  // Finalize attribute distortions last because the attribute registry is
10053
10412
  // populated by the other distortion factories.
@@ -14931,9 +15290,9 @@ function createEvalHelpersFactoryArgs$LWS(record$LWS) {
14931
15290
  prototype: HTMLScriptElementProto$LWS
14932
15291
  }
14933
15292
  },
14934
- root: root$LWS
15293
+ root: _root$LWS
14935
15294
  } = record$LWS;
14936
- const isRootRecord$LWS = record$LWS === root$LWS;
15295
+ const isRootRecord$LWS = record$LWS === _root$LWS;
14937
15296
  const forOfStateCache$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1());
14938
15297
  const resourcePromiseCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
14939
15298
  const resourceStatusCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
@@ -15129,7 +15488,7 @@ function toSourceText$LWS(value$LWS, sourceType$LWS) {
15129
15488
  // tools from mistaking the regexp or the replacement string for an
15130
15489
  // actual source mapping URL.
15131
15490
  /\/\/# sandbox(?=MappingURL=.*?\s*$)/, '//# source']);
15132
- sourceText$LWS = `\n//# LWS Version = "0.22.1"\n${sourceText$LWS}`;
15491
+ sourceText$LWS = `\n//# LWS Version = "0.22.4"\n${sourceText$LWS}`;
15133
15492
  return sourceType$LWS === 1 /* SourceType.Module */ && indexOfPragma$LWS(sourceText$LWS, 'use strict') === -1 ?
15134
15493
  // Append "'use strict'" to the extracted function body so it is
15135
15494
  // evaluated in strict mode.
@@ -15216,7 +15575,7 @@ function createVirtualEnvironment$LWS(record$LWS) {
15216
15575
  globalObject: globalObject$LWS,
15217
15576
  instrumentation: instrumentation$LWS,
15218
15577
  key: key$LWS,
15219
- root: root$LWS,
15578
+ root: _root$LWS,
15220
15579
  root: {
15221
15580
  distortions: distortions$LWS
15222
15581
  },
@@ -15277,7 +15636,7 @@ function createVirtualEnvironment$LWS(record$LWS) {
15277
15636
  globalObject: originalTarget$LWS,
15278
15637
  key: key$LWS,
15279
15638
  type: type$LWS
15280
- }, root$LWS);
15639
+ }, _root$LWS);
15281
15640
  return originalTarget$LWS;
15282
15641
  }
15283
15642
  // eslint-disable-next-line no-empty
@@ -15308,7 +15667,7 @@ function createVirtualEnvironment$LWS(record$LWS) {
15308
15667
  globalObject: originalTargetWindow$LWS,
15309
15668
  key: key$LWS,
15310
15669
  type: type$LWS
15311
- }, root$LWS);
15670
+ }, _root$LWS);
15312
15671
  }
15313
15672
  return originalTarget$LWS;
15314
15673
  },
@@ -15319,7 +15678,9 @@ function createVirtualEnvironment$LWS(record$LWS) {
15319
15678
  ObjectAssign$LWS$1({}, DEFAULT_ENDOWMENTS_DESCRIPTOR_MAP$LWS, ObjectGetOwnPropertyDescriptors$LWS(endowments$LWS)) : DEFAULT_ENDOWMENTS_DESCRIPTOR_MAP$LWS,
15320
15679
  instrumentation: instrumentation$LWS,
15321
15680
  remapTypedArrays: remapTypedArrays$LWS,
15322
- 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,
15323
15684
  liveTargetCallback: isTargetLive$LWS,
15324
15685
  signSourceCallback: sourceText$LWS => trusted.createScript(sourceText$LWS)
15325
15686
  });
@@ -15398,7 +15759,7 @@ function createOpaqueSecondaryWindowSandboxRecord$LWS({
15398
15759
  key: key$LWS,
15399
15760
  // istanbul ignore next: destructured default assignments are not correctly instrumented
15400
15761
  type: type$LWS = /* istannul ignore next: nothing works to ignore these */getDefaultType$LWS(key$LWS)
15401
- }, root$LWS) {
15762
+ }, _root$LWS) {
15402
15763
  const sandboxRegistry$LWS = getOpaqueSandboxRegistry$LWS(globalObject$LWS);
15403
15764
  let record$LWS = sandboxRegistry$LWS[key$LWS];
15404
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
@@ -15411,7 +15772,7 @@ function createOpaqueSecondaryWindowSandboxRecord$LWS({
15411
15772
  LOCKER_VERBOSE_INSTRUMENTATION_FLAG: LOCKER_VERBOSE_INSTRUMENTATION_FLAG$LWS,
15412
15773
  distortions: distortions$LWS,
15413
15774
  instrumentation: instrumentation$LWS
15414
- } = root$LWS;
15775
+ } = _root$LWS;
15415
15776
  record$LWS = {
15416
15777
  BASIC_INSTRUMENTATION_DATA: BASIC_INSTRUMENTATION_DATA$LWS,
15417
15778
  LOCKER_INSTRUMENTATION_FLAG: LOCKER_INSTRUMENTATION_FLAG$LWS,
@@ -15425,7 +15786,7 @@ function createOpaqueSecondaryWindowSandboxRecord$LWS({
15425
15786
  helpers: EMPTY_EVAL_HELPERS$LWS,
15426
15787
  instrumentation: instrumentation$LWS,
15427
15788
  key: key$LWS,
15428
- root: root$LWS,
15789
+ root: _root$LWS,
15429
15790
  sandboxEvaluator: noop$LWS$1,
15430
15791
  type: type$LWS,
15431
15792
  virtualEnvironmentEvaluator: noop$LWS$1
@@ -15458,7 +15819,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15458
15819
  key: key$LWS,
15459
15820
  // istanbul ignore next: destructured default assignments are not correctly instrumented
15460
15821
  type: type$LWS = /* istanbul ignore next: currently unreachable via tests */getDefaultType$LWS(key$LWS)
15461
- }, root$LWS) {
15822
+ }, _root$LWS) {
15462
15823
  const sandboxRegistry$LWS = getSandboxRegistry$LWS(document$LWS);
15463
15824
  let record$LWS = sandboxRegistry$LWS[key$LWS];
15464
15825
  if (record$LWS) {
@@ -15470,7 +15831,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15470
15831
  LOCKER_VERBOSE_INSTRUMENTATION_FLAG: LOCKER_VERBOSE_INSTRUMENTATION_FLAG$LWS,
15471
15832
  distortions: distortions$LWS,
15472
15833
  instrumentation: instrumentation$LWS
15473
- } = root$LWS;
15834
+ } = _root$LWS;
15474
15835
  const {
15475
15836
  location: location$LWS,
15476
15837
  top: top$LWS
@@ -15498,7 +15859,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15498
15859
  helpers: EMPTY_EVAL_HELPERS$LWS,
15499
15860
  instrumentation: instrumentation$LWS,
15500
15861
  key: key$LWS,
15501
- root: root$LWS,
15862
+ root: _root$LWS,
15502
15863
  sandboxEvaluator: noop$LWS$1,
15503
15864
  type: type$LWS,
15504
15865
  virtualEnvironmentEvaluator: noop$LWS$1
@@ -15551,7 +15912,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15551
15912
  globalObject: globalObject$LWS,
15552
15913
  key: key$LWS,
15553
15914
  type: type$LWS
15554
- }, root$LWS);
15915
+ }, _root$LWS);
15555
15916
  }
15556
15917
  } catch (_unused40$LWS) {
15557
15918
  // istanbul ignore next: this is a safety precaution that is unreachable via tests
@@ -15559,7 +15920,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15559
15920
  globalObject: globalObject$LWS,
15560
15921
  key: key$LWS,
15561
15922
  type: type$LWS
15562
- }, root$LWS);
15923
+ }, _root$LWS);
15563
15924
  }
15564
15925
  };
15565
15926
  const frameElement$LWS = ReflectApply$LWS$1(WindowFrameElementGetter$LWS, globalObject$LWS, []);
@@ -15598,7 +15959,7 @@ function createSecondaryWindowSandboxRecord$LWS({
15598
15959
  globalObject: globalObject$LWS,
15599
15960
  key: key$LWS,
15600
15961
  type: type$LWS
15601
- }, root$LWS);
15962
+ }, _root$LWS);
15602
15963
  }
15603
15964
  });
15604
15965
  },
@@ -15809,9 +16170,27 @@ function wrapPlatformResourceLoader$LWS(dep$LWS, key$LWS) {
15809
16170
  return secureDep$LWS;
15810
16171
  }
15811
16172
  secureDep$LWS = {
15812
- loadScript: (thisArg$LWS, url$LWS) => createRootWindowSandboxRecord$LWS({
15813
- key: key$LWS
15814
- }).helpers.loadScript(thisArg$LWS, url$LWS),
16173
+ loadScript: (thisArg$LWS, url$LWS, config$LWS) => {
16174
+ const sandbox$LWS = createRootWindowSandboxRecord$LWS({
16175
+ key: key$LWS
16176
+ });
16177
+ if (isGaterEnabledFeature$LWS('enableTrustedMode') && config$LWS != null && config$LWS.trustedMode) {
16178
+ const trustedGlobals$LWS = config$LWS.trustedGlobals;
16179
+ if ((trustedGlobals$LWS == null ? void 0 : trustedGlobals$LWS.length) > 0) {
16180
+ return dep$LWS.loadScript(thisArg$LWS, url$LWS).then(() => {
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
+ }]);
16187
+ installGlobals$LWS(globals$LWS);
16188
+ });
16189
+ }
16190
+ return dep$LWS.loadScript(thisArg$LWS, url$LWS);
16191
+ }
16192
+ return sandbox$LWS.helpers.loadScript(thisArg$LWS, url$LWS);
16193
+ },
15815
16194
  loadStyle: (thisArg$LWS, url$LWS) => createRootWindowSandboxRecord$LWS({
15816
16195
  key: key$LWS
15817
16196
  }).helpers.loadStyle(thisArg$LWS, url$LWS)
@@ -15819,7 +16198,7 @@ function wrapPlatformResourceLoader$LWS(dep$LWS, key$LWS) {
15819
16198
  depRegistry$LWS.set(dep$LWS, secureDep$LWS);
15820
16199
  return secureDep$LWS;
15821
16200
  }
15822
- /*! version: 0.22.1 */
16201
+ /*! version: 0.22.4 */
15823
16202
 
15824
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 };
15825
16204
  //# sourceMappingURL=lockerSandbox.js.map