版博士V2.0程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

47 строки
2.0 KiB

  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. const EventTarget_1 = __importDefault(require("../../event/EventTarget"));
  7. const DOMException_1 = __importDefault(require("../../exception/DOMException"));
  8. const DOMExceptionNameEnum_1 = __importDefault(require("../../exception/DOMExceptionNameEnum"));
  9. /**
  10. * Browser window with limited access due to CORS restrictions in iframes.
  11. */
  12. class IFrameCrossOriginWindow extends EventTarget_1.default {
  13. /**
  14. * Constructor.
  15. *
  16. * @param parent Parent window.
  17. * @param target Target window.
  18. */
  19. constructor(parent, target) {
  20. super();
  21. this.self = this;
  22. this.window = this;
  23. this.parent = parent;
  24. this.top = parent;
  25. this.location = new Proxy({}, {
  26. get: () => {
  27. throw new DOMException_1.default(`Blocked a frame with origin "${this.parent.location.origin}" from accessing a cross-origin frame.`, DOMExceptionNameEnum_1.default.securityError);
  28. },
  29. set: () => {
  30. throw new DOMException_1.default(`Blocked a frame with origin "${this.parent.location.origin}" from accessing a cross-origin frame.`, DOMExceptionNameEnum_1.default.securityError);
  31. }
  32. });
  33. this._targetWindow = target;
  34. }
  35. /**
  36. * Safely enables cross-origin communication between Window objects; e.g., between a page and a pop-up that it spawned, or between a page and an iframe embedded within it.
  37. *
  38. * @param message Message.
  39. * @param [targetOrigin=*] Target origin.
  40. * @param transfer Transfer. Not implemented.
  41. */
  42. postMessage(message, targetOrigin = '*', transfer) {
  43. this._targetWindow.postMessage(message, targetOrigin, transfer);
  44. }
  45. }
  46. exports.default = IFrameCrossOriginWindow;
  47. //# sourceMappingURL=IFrameCrossOriginWindow.js.map