* @param {!FakeWindowSpec=} opt_spec
(opt_spec)
| 19 | * @param {!FakeWindowSpec=} opt_spec |
| 20 | */ |
| 21 | constructor(opt_spec) { |
| 22 | const spec = opt_spec || {}; |
| 23 | |
| 24 | /** |
| 25 | * This value is reflected on this.document.readyState. |
| 26 | * @type {string} |
| 27 | */ |
| 28 | this.readyState = spec.readyState || 'complete'; |
| 29 | |
| 30 | // Passthrough. |
| 31 | /** @const */ |
| 32 | this.Object = window.Object; |
| 33 | /** @const */ |
| 34 | this.HTMLElement = window.HTMLElement; |
| 35 | /** @const */ |
| 36 | this.HTMLFormElement = window.HTMLFormElement; |
| 37 | /** @const */ |
| 38 | this.Element = window.Element; |
| 39 | /** @const */ |
| 40 | this.Node = window.Node; |
| 41 | /** @const */ |
| 42 | this.EventTarget = window.EventTarget; |
| 43 | /** @const */ |
| 44 | this.DOMTokenList = window.DOMTokenList; |
| 45 | /** @const */ |
| 46 | this.Math = window.Math; |
| 47 | /** @const */ |
| 48 | this.Promise = window.Promise; |
| 49 | /** @const */ |
| 50 | this.IntersectionObserver = window.IntersectionObserver; |
| 51 | /** @const */ |
| 52 | this./*OK*/ pageYOffset = window./*OK*/ pageYOffset; |
| 53 | |
| 54 | /** @const */ |
| 55 | this.IntersectionObserver = window.IntersectionObserver; |
| 56 | |
| 57 | /** @const */ |
| 58 | this.crypto = window.crypto || window.msCrypto; |
| 59 | |
| 60 | // Parent Window points to itself if spec.parent was not passed. |
| 61 | /** @const @type {!Window} */ |
| 62 | this.parent = spec.parent ? new FakeWindow(spec.parent) : this; |
| 63 | |
| 64 | // Top Window points to parent if spec.top was not passed. |
| 65 | /** @const */ |
| 66 | this.top = spec.top ? new FakeWindow(spec.top) : this.parent; |
| 67 | |
| 68 | // Events. |
| 69 | EventListeners.intercept(this); |
| 70 | |
| 71 | // Document. |
| 72 | /** @const {!HTMLDocument} */ |
| 73 | this.document = self.document.implementation.createHTMLDocument(''); |
| 74 | // NOTE: There was a change between chrome 119 and 120 where the above |
| 75 | // self.document.implementation.createHTMLDocument no longer inherits |
| 76 | // the baseURI of self.document. We explicitly set and force it thru |
| 77 | // a `<base>` element. |
| 78 | const base = this.document.createElement('base'); |