happy-dom 2.55.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of happy-dom might be problematic. Click here for more details.
- package/README.md +26 -6
- package/lib/async-task-manager/AsyncTaskManager.js +34 -78
- package/lib/async-task-manager/AsyncTaskManager.js.map +1 -1
- package/lib/attribute/Attr.js +19 -28
- package/lib/attribute/Attr.js.map +1 -1
- package/lib/config/ElementTag.js +15 -15
- package/lib/config/ElementTag.js.map +1 -1
- package/lib/cookie/CookieUtility.js +21 -26
- package/lib/cookie/CookieUtility.js.map +1 -1
- package/lib/css/CSS.js +12 -18
- package/lib/css/CSS.js.map +1 -1
- package/lib/css/CSSParser.js +29 -33
- package/lib/css/CSSParser.js.map +1 -1
- package/lib/css/CSSRule.js +24 -29
- package/lib/css/CSSRule.js.map +1 -1
- package/lib/css/CSSStyleDeclaration.js +4516 -6005
- package/lib/css/CSSStyleDeclaration.js.map +1 -1
- package/lib/css/CSSStyleSheet.js +17 -59
- package/lib/css/CSSStyleSheet.js.map +1 -1
- package/lib/css/CSSUnitValue.js +4 -5
- package/lib/css/CSSUnitValue.js.map +1 -1
- package/lib/css/MediaList.js +23 -28
- package/lib/css/MediaList.js.map +1 -1
- package/lib/css/rules/CSSFontFaceRule.js +6 -24
- package/lib/css/rules/CSSFontFaceRule.js.map +1 -1
- package/lib/css/rules/CSSKeyframeRule.js +14 -36
- package/lib/css/rules/CSSKeyframeRule.js.map +1 -1
- package/lib/css/rules/CSSKeyframesRule.js +31 -54
- package/lib/css/rules/CSSKeyframesRule.js.map +1 -1
- package/lib/css/rules/CSSMediaRule.js +29 -56
- package/lib/css/rules/CSSMediaRule.js.map +1 -1
- package/lib/css/rules/CSSStyleRule.js +16 -38
- package/lib/css/rules/CSSStyleRule.js.map +1 -1
- package/lib/custom-element/CustomElementRegistry.js +21 -24
- package/lib/custom-element/CustomElementRegistry.js.map +1 -1
- package/lib/dom-implementation/DOMImplementation.js +12 -13
- package/lib/dom-implementation/DOMImplementation.js.map +1 -1
- package/lib/dom-parser/DOMParser.js +29 -35
- package/lib/dom-parser/DOMParser.js.map +1 -1
- package/lib/dom-token-list/DOMTokenList.js +64 -79
- package/lib/dom-token-list/DOMTokenList.js.map +1 -1
- package/lib/event/DataTransfer.js +4 -5
- package/lib/event/DataTransfer.js.map +1 -1
- package/lib/event/DataTransferItem.js +7 -8
- package/lib/event/DataTransferItem.js.map +1 -1
- package/lib/event/DataTransferItemList.js +10 -11
- package/lib/event/DataTransferItemList.js.map +1 -1
- package/lib/event/Event.js +11 -15
- package/lib/event/Event.js.map +1 -1
- package/lib/event/EventTarget.js +14 -16
- package/lib/event/EventTarget.js.map +1 -1
- package/lib/event/IUIEventInit.d.ts +2 -2
- package/lib/event/UIEvent.d.ts +2 -2
- package/lib/event/UIEvent.js +25 -46
- package/lib/event/UIEvent.js.map +1 -1
- package/lib/event/events/AnimationEvent.js +11 -29
- package/lib/event/events/AnimationEvent.js.map +1 -1
- package/lib/event/events/CustomEvent.js +9 -31
- package/lib/event/events/CustomEvent.js.map +1 -1
- package/lib/event/events/ErrorEvent.js +15 -34
- package/lib/event/events/ErrorEvent.js.map +1 -1
- package/lib/event/events/FocusEvent.js +7 -26
- package/lib/event/events/FocusEvent.js.map +1 -1
- package/lib/event/events/InputEvent.js +13 -32
- package/lib/event/events/InputEvent.js.map +1 -1
- package/lib/event/events/KeyboardEvent.js +27 -46
- package/lib/event/events/KeyboardEvent.js.map +1 -1
- package/lib/event/events/MouseEvent.js +33 -52
- package/lib/event/events/MouseEvent.js.map +1 -1
- package/lib/event/events/PointerEvent.js +25 -44
- package/lib/event/events/PointerEvent.js.map +1 -1
- package/lib/event/events/ProgressEvent.js +11 -30
- package/lib/event/events/ProgressEvent.js.map +1 -1
- package/lib/event/events/StorageEvent.js +13 -32
- package/lib/event/events/StorageEvent.js.map +1 -1
- package/lib/event/events/WheelEvent.js +16 -35
- package/lib/event/events/WheelEvent.js.map +1 -1
- package/lib/exception/DOMException.js +5 -24
- package/lib/exception/DOMException.js.map +1 -1
- package/lib/fetch/FetchHandler.js +18 -22
- package/lib/fetch/FetchHandler.js.map +1 -1
- package/lib/fetch/Headers.js +3 -23
- package/lib/fetch/Headers.js.map +1 -1
- package/lib/fetch/Request.js +61 -81
- package/lib/fetch/Request.js.map +1 -1
- package/lib/fetch/ResourceFetchHandler.js +18 -67
- package/lib/fetch/ResourceFetchHandler.js.map +1 -1
- package/lib/fetch/Response.js +61 -81
- package/lib/fetch/Response.js.map +1 -1
- package/lib/file/Blob.js +29 -78
- package/lib/file/Blob.js.map +1 -1
- package/lib/file/File.js +9 -27
- package/lib/file/File.js.map +1 -1
- package/lib/file/FileReader.js +57 -78
- package/lib/file/FileReader.js.map +1 -1
- package/lib/history/History.js +32 -37
- package/lib/history/History.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +69 -69
- package/lib/index.js.map +1 -1
- package/lib/location/Location.js +11 -28
- package/lib/location/Location.js.map +1 -1
- package/lib/location/RelativeURL.js +5 -8
- package/lib/location/RelativeURL.js.map +1 -1
- package/lib/location/URL.js +46 -59
- package/lib/location/URL.js.map +1 -1
- package/lib/match-media/MediaQueryList.js +28 -54
- package/lib/match-media/MediaQueryList.js.map +1 -1
- package/lib/mutation-observer/MutationListener.js +3 -4
- package/lib/mutation-observer/MutationListener.js.map +1 -1
- package/lib/mutation-observer/MutationObserver.js +12 -13
- package/lib/mutation-observer/MutationObserver.js.map +1 -1
- package/lib/mutation-observer/MutationRecord.js +3 -4
- package/lib/mutation-observer/MutationRecord.js.map +1 -1
- package/lib/navigator/MimeType.js +5 -6
- package/lib/navigator/MimeType.js.map +1 -1
- package/lib/navigator/MimeTypeArray.js +10 -11
- package/lib/navigator/MimeTypeArray.js.map +1 -1
- package/lib/navigator/Navigator.js +7 -8
- package/lib/navigator/Navigator.js.map +1 -1
- package/lib/navigator/Plugin.js +10 -11
- package/lib/navigator/Plugin.js.map +1 -1
- package/lib/navigator/PluginArray.js +12 -13
- package/lib/navigator/PluginArray.js.map +1 -1
- package/lib/nodes/character-data/CharacterData.js +119 -184
- package/lib/nodes/character-data/CharacterData.js.map +1 -1
- package/lib/nodes/character-data/CharacterDataUtility.js +12 -15
- package/lib/nodes/character-data/CharacterDataUtility.js.map +1 -1
- package/lib/nodes/child-node/ChildNodeUtility.js +24 -45
- package/lib/nodes/child-node/ChildNodeUtility.js.map +1 -1
- package/lib/nodes/child-node/NonDocumentChildNodeUtility.js +9 -12
- package/lib/nodes/child-node/NonDocumentChildNodeUtility.js.map +1 -1
- package/lib/nodes/comment/Comment.js +20 -43
- package/lib/nodes/comment/Comment.js.map +1 -1
- package/lib/nodes/document/Document.d.ts +3 -3
- package/lib/nodes/document/Document.js +334 -461
- package/lib/nodes/document/Document.js.map +1 -1
- package/lib/nodes/document/DocumentReadyStateManager.js +16 -19
- package/lib/nodes/document/DocumentReadyStateManager.js.map +1 -1
- package/lib/nodes/document/IDocument.d.ts +2 -2
- package/lib/nodes/document-fragment/DocumentFragment.js +93 -153
- package/lib/nodes/document-fragment/DocumentFragment.js.map +1 -1
- package/lib/nodes/document-type/DocumentType.js +22 -45
- package/lib/nodes/document-type/DocumentType.js.map +1 -1
- package/lib/nodes/element/DOMRect.js +3 -4
- package/lib/nodes/element/DOMRect.js.map +1 -1
- package/lib/nodes/element/Element.js +367 -496
- package/lib/nodes/element/Element.js.map +1 -1
- package/lib/nodes/element/HTMLCollection.js +4 -24
- package/lib/nodes/element/HTMLCollection.js.map +1 -1
- package/lib/nodes/element/HTMLCollectionFactory.js +6 -9
- package/lib/nodes/element/HTMLCollectionFactory.js.map +1 -1
- package/lib/nodes/element/Range.js +89 -114
- package/lib/nodes/element/Range.js.map +1 -1
- package/lib/nodes/html-base-element/HTMLBaseElement.js +41 -70
- package/lib/nodes/html-base-element/HTMLBaseElement.js.map +1 -1
- package/lib/nodes/html-document/HTMLDocument.js +3 -23
- package/lib/nodes/html-document/HTMLDocument.js.map +1 -1
- package/lib/nodes/html-element/DatasetUtility.js +9 -12
- package/lib/nodes/html-element/DatasetUtility.js.map +1 -1
- package/lib/nodes/html-element/HTMLElement.js +232 -290
- package/lib/nodes/html-element/HTMLElement.js.map +1 -1
- package/lib/nodes/html-form-element/HTMLFormElement.js +170 -235
- package/lib/nodes/html-form-element/HTMLFormElement.js.map +1 -1
- package/lib/nodes/html-image-element/HTMLImageElement.js +178 -237
- package/lib/nodes/html-image-element/HTMLImageElement.js.map +1 -1
- package/lib/nodes/html-image-element/Image.js +7 -27
- package/lib/nodes/html-image-element/Image.js.map +1 -1
- package/lib/nodes/html-input-element/HTMLInputElement.js +705 -872
- package/lib/nodes/html-input-element/HTMLInputElement.js.map +1 -1
- package/lib/nodes/html-input-element/HTMLInputElementValueSanitizer.js +9 -12
- package/lib/nodes/html-input-element/HTMLInputElementValueSanitizer.js.map +1 -1
- package/lib/nodes/html-input-element/HTMLInputElementValueStepping.js +5 -8
- package/lib/nodes/html-input-element/HTMLInputElementValueStepping.js.map +1 -1
- package/lib/nodes/html-input-element/ValidityState.js +47 -69
- package/lib/nodes/html-input-element/ValidityState.js.map +1 -1
- package/lib/nodes/html-label-element/HTMLLabelElement.js +53 -87
- package/lib/nodes/html-label-element/HTMLLabelElement.js.map +1 -1
- package/lib/nodes/html-link-element/HTMLLinkElement.js +197 -252
- package/lib/nodes/html-link-element/HTMLLinkElement.js.map +1 -1
- package/lib/nodes/html-meta-element/HTMLMetaElement.js +66 -102
- package/lib/nodes/html-meta-element/HTMLMetaElement.js.map +1 -1
- package/lib/nodes/html-script-element/HTMLScriptElement.js +145 -193
- package/lib/nodes/html-script-element/HTMLScriptElement.js.map +1 -1
- package/lib/nodes/html-script-element/ScriptUtility.js +58 -112
- package/lib/nodes/html-script-element/ScriptUtility.js.map +1 -1
- package/lib/nodes/html-slot-element/HTMLSlotElement.js +33 -65
- package/lib/nodes/html-slot-element/HTMLSlotElement.js.map +1 -1
- package/lib/nodes/html-style-element/HTMLStyleElement.js +75 -109
- package/lib/nodes/html-style-element/HTMLStyleElement.js.map +1 -1
- package/lib/nodes/html-template-element/HTMLTemplateElement.js +60 -99
- package/lib/nodes/html-template-element/HTMLTemplateElement.js.map +1 -1
- package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js +349 -444
- package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js.map +1 -1
- package/lib/nodes/html-unknown-element/HTMLUnknownElement.js +17 -37
- package/lib/nodes/html-unknown-element/HTMLUnknownElement.js.map +1 -1
- package/lib/nodes/node/Node.js +193 -260
- package/lib/nodes/node/Node.js.map +1 -1
- package/lib/nodes/node/NodeList.js +4 -24
- package/lib/nodes/node/NodeList.js.map +1 -1
- package/lib/nodes/node/NodeListFactory.js +6 -9
- package/lib/nodes/node/NodeListFactory.js.map +1 -1
- package/lib/nodes/parent-node/ParentNodeUtility.js +43 -78
- package/lib/nodes/parent-node/ParentNodeUtility.js.map +1 -1
- package/lib/nodes/shadow-root/ShadowRoot.js +53 -83
- package/lib/nodes/shadow-root/ShadowRoot.js.map +1 -1
- package/lib/nodes/svg-document/SVGDocument.js +3 -23
- package/lib/nodes/svg-document/SVGDocument.js.map +1 -1
- package/lib/nodes/svg-element/DOMMatrix.js +3 -4
- package/lib/nodes/svg-element/DOMMatrix.js.map +1 -1
- package/lib/nodes/svg-element/SVGAngle.js +10 -11
- package/lib/nodes/svg-element/SVGAngle.js.map +1 -1
- package/lib/nodes/svg-element/SVGAnimatedRect.js +4 -5
- package/lib/nodes/svg-element/SVGAnimatedRect.js.map +1 -1
- package/lib/nodes/svg-element/SVGElement.js +58 -93
- package/lib/nodes/svg-element/SVGElement.js.map +1 -1
- package/lib/nodes/svg-element/SVGGraphicsElement.js +14 -32
- package/lib/nodes/svg-element/SVGGraphicsElement.js.map +1 -1
- package/lib/nodes/svg-element/SVGLength.js +16 -17
- package/lib/nodes/svg-element/SVGLength.js.map +1 -1
- package/lib/nodes/svg-element/SVGNumber.js +3 -4
- package/lib/nodes/svg-element/SVGNumber.js.map +1 -1
- package/lib/nodes/svg-element/SVGPoint.js +3 -4
- package/lib/nodes/svg-element/SVGPoint.js.map +1 -1
- package/lib/nodes/svg-element/SVGRect.js +3 -4
- package/lib/nodes/svg-element/SVGRect.js.map +1 -1
- package/lib/nodes/svg-element/SVGSVGElement.js +187 -248
- package/lib/nodes/svg-element/SVGSVGElement.js.map +1 -1
- package/lib/nodes/svg-element/SVGTransform.js +16 -17
- package/lib/nodes/svg-element/SVGTransform.js.map +1 -1
- package/lib/nodes/text/Text.js +20 -43
- package/lib/nodes/text/Text.js.map +1 -1
- package/lib/nodes/xml-document/XMLDocument.js +3 -23
- package/lib/nodes/xml-document/XMLDocument.js.map +1 -1
- package/lib/query-selector/QuerySelector.js +36 -44
- package/lib/query-selector/QuerySelector.js.map +1 -1
- package/lib/query-selector/SelectorItem.js +62 -66
- package/lib/query-selector/SelectorItem.js.map +1 -1
- package/lib/resize-observer/ResizeObserver.js +8 -11
- package/lib/resize-observer/ResizeObserver.js.map +1 -1
- package/lib/screen/Screen.js +3 -4
- package/lib/screen/Screen.js.map +1 -1
- package/lib/selection/Selection.js +29 -30
- package/lib/selection/Selection.js.map +1 -1
- package/lib/storage/Storage.js +22 -27
- package/lib/storage/Storage.js.map +1 -1
- package/lib/tree-walker/NodeFilterMask.js +1 -1
- package/lib/tree-walker/NodeFilterMask.js.map +1 -1
- package/lib/tree-walker/TreeWalker.js +30 -33
- package/lib/tree-walker/TreeWalker.js.map +1 -1
- package/lib/window/GlobalWindow.d.ts +84 -0
- package/lib/window/GlobalWindow.js +90 -0
- package/lib/window/GlobalWindow.js.map +1 -0
- package/lib/window/IWindow.d.ts +29 -18
- package/lib/window/VMGlobalPropertyScript.d.ts +2 -0
- package/lib/window/VMGlobalPropertyScript.js +65 -0
- package/lib/window/VMGlobalPropertyScript.js.map +1 -0
- package/lib/window/Window.d.ts +70 -105
- package/lib/window/Window.js +269 -491
- package/lib/window/Window.js.map +1 -1
- package/lib/xml-parser/XMLParser.js +65 -71
- package/lib/xml-parser/XMLParser.js.map +1 -1
- package/lib/xml-serializer/XMLSerializer.js +30 -37
- package/lib/xml-serializer/XMLSerializer.js.map +1 -1
- package/package.json +6 -7
- package/src/dom-parser/DOMParser.ts +4 -5
- package/src/event/IUIEventInit.ts +2 -2
- package/src/event/UIEvent.ts +2 -2
- package/src/fetch/FetchHandler.ts +3 -3
- package/src/fetch/ResourceFetchHandler.ts +3 -3
- package/src/index.ts +3 -3
- package/src/nodes/document/Document.ts +4 -4
- package/src/nodes/document/IDocument.ts +2 -2
- package/src/nodes/html-link-element/HTMLLinkElement.ts +8 -2
- package/src/nodes/html-script-element/ScriptUtility.ts +4 -4
- package/src/window/GlobalWindow.ts +82 -0
- package/src/window/IWindow.ts +24 -12
- package/src/window/VMGlobalPropertyScript.ts +62 -0
- package/src/window/Window.ts +104 -173
- package/tsconfig.json +1 -1
- package/lib/window/AsyncWindow.d.ts +0 -10
- package/lib/window/AsyncWindow.js +0 -38
- package/lib/window/AsyncWindow.js.map +0 -1
- package/src/window/AsyncWindow.ts +0 -17
package/lib/window/Window.js
CHANGED
@@ -1,19 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
3
|
-
var extendStatics = function (d, b) {
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
-
return extendStatics(d, b);
|
8
|
-
};
|
9
|
-
return function (d, b) {
|
10
|
-
if (typeof b !== "function" && b !== null)
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
-
extendStatics(d, b);
|
13
|
-
function __() { this.constructor = d; }
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
-
};
|
16
|
-
})();
|
17
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
18
3
|
if (k2 === undefined) k2 = k;
|
19
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
@@ -37,492 +22,296 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
37
22
|
__setModuleDefault(result, mod);
|
38
23
|
return result;
|
39
24
|
};
|
40
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
41
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
42
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
43
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
44
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
45
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
46
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
47
|
-
});
|
48
|
-
};
|
49
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
50
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
51
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
52
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
53
|
-
function step(op) {
|
54
|
-
if (f) throw new TypeError("Generator is already executing.");
|
55
|
-
while (_) try {
|
56
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
57
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
58
|
-
switch (op[0]) {
|
59
|
-
case 0: case 1: t = op; break;
|
60
|
-
case 4: _.label++; return { value: op[1], done: false };
|
61
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
62
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
63
|
-
default:
|
64
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
65
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
66
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
67
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
68
|
-
if (t[2]) _.ops.pop();
|
69
|
-
_.trys.pop(); continue;
|
70
|
-
}
|
71
|
-
op = body.call(thisArg, _);
|
72
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
73
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
74
|
-
}
|
75
|
-
};
|
76
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
77
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
78
27
|
};
|
79
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
29
|
+
const CustomElementRegistry_1 = __importDefault(require("../custom-element/CustomElementRegistry"));
|
30
|
+
const Document_1 = __importDefault(require("../nodes/document/Document"));
|
31
|
+
const HTMLDocument_1 = __importDefault(require("../nodes/html-document/HTMLDocument"));
|
32
|
+
const XMLDocument_1 = __importDefault(require("../nodes/xml-document/XMLDocument"));
|
33
|
+
const SVGDocument_1 = __importDefault(require("../nodes/svg-document/SVGDocument"));
|
34
|
+
const Node_1 = __importDefault(require("../nodes/node/Node"));
|
35
|
+
const NodeFilter_1 = __importDefault(require("../tree-walker/NodeFilter"));
|
36
|
+
const Text_1 = __importDefault(require("../nodes/text/Text"));
|
37
|
+
const Comment_1 = __importDefault(require("../nodes/comment/Comment"));
|
38
|
+
const ShadowRoot_1 = __importDefault(require("../nodes/shadow-root/ShadowRoot"));
|
39
|
+
const Element_1 = __importDefault(require("../nodes/element/Element"));
|
40
|
+
const HTMLTemplateElement_1 = __importDefault(require("../nodes/html-template-element/HTMLTemplateElement"));
|
41
|
+
const HTMLFormElement_1 = __importDefault(require("../nodes/html-form-element/HTMLFormElement"));
|
42
|
+
const HTMLElement_1 = __importDefault(require("../nodes/html-element/HTMLElement"));
|
43
|
+
const HTMLUnknownElement_1 = __importDefault(require("../nodes/html-unknown-element/HTMLUnknownElement"));
|
44
|
+
const HTMLInputElement_1 = __importDefault(require("../nodes/html-input-element/HTMLInputElement"));
|
45
|
+
const HTMLTextAreaElement_1 = __importDefault(require("../nodes/html-text-area-element/HTMLTextAreaElement"));
|
46
|
+
const HTMLLinkElement_1 = __importDefault(require("../nodes/html-link-element/HTMLLinkElement"));
|
47
|
+
const HTMLStyleElement_1 = __importDefault(require("../nodes/html-style-element/HTMLStyleElement"));
|
48
|
+
const HTMLSlotElement_1 = __importDefault(require("../nodes/html-slot-element/HTMLSlotElement"));
|
49
|
+
const HTMLLabelElement_1 = __importDefault(require("../nodes/html-label-element/HTMLLabelElement"));
|
50
|
+
const HTMLMetaElement_1 = __importDefault(require("../nodes/html-meta-element/HTMLMetaElement"));
|
51
|
+
const HTMLBaseElement_1 = __importDefault(require("../nodes/html-base-element/HTMLBaseElement"));
|
52
|
+
const SVGSVGElement_1 = __importDefault(require("../nodes/svg-element/SVGSVGElement"));
|
53
|
+
const SVGElement_1 = __importDefault(require("../nodes/svg-element/SVGElement"));
|
54
|
+
const HTMLScriptElement_1 = __importDefault(require("../nodes/html-script-element/HTMLScriptElement"));
|
55
|
+
const HTMLImageElement_1 = __importDefault(require("../nodes/html-image-element/HTMLImageElement"));
|
56
|
+
const Image_1 = __importDefault(require("../nodes/html-image-element/Image"));
|
57
|
+
const DocumentFragment_1 = __importDefault(require("../nodes/document-fragment/DocumentFragment"));
|
58
|
+
const CharacterData_1 = __importDefault(require("../nodes/character-data/CharacterData"));
|
59
|
+
const TreeWalker_1 = __importDefault(require("../tree-walker/TreeWalker"));
|
60
|
+
const Event_1 = __importDefault(require("../event/Event"));
|
61
|
+
const CustomEvent_1 = __importDefault(require("../event/events/CustomEvent"));
|
62
|
+
const AnimationEvent_1 = __importDefault(require("../event/events/AnimationEvent"));
|
63
|
+
const KeyboardEvent_1 = __importDefault(require("../event/events/KeyboardEvent"));
|
64
|
+
const ProgressEvent_1 = __importDefault(require("../event/events/ProgressEvent"));
|
65
|
+
const EventTarget_1 = __importDefault(require("../event/EventTarget"));
|
66
|
+
const URL_1 = __importDefault(require("../location/URL"));
|
67
|
+
const Location_1 = __importDefault(require("../location/Location"));
|
68
|
+
const NonImplementedEventTypes_1 = __importDefault(require("../event/NonImplementedEventTypes"));
|
69
|
+
const MutationObserver_1 = __importDefault(require("../mutation-observer/MutationObserver"));
|
70
|
+
const NonImplemenetedElementClasses_1 = __importDefault(require("../config/NonImplemenetedElementClasses"));
|
71
|
+
const DOMParser_1 = __importDefault(require("../dom-parser/DOMParser"));
|
72
|
+
const XMLSerializer_1 = __importDefault(require("../xml-serializer/XMLSerializer"));
|
73
|
+
const ResizeObserver_1 = __importDefault(require("../resize-observer/ResizeObserver"));
|
74
|
+
const Blob_1 = __importDefault(require("../file/Blob"));
|
75
|
+
const File_1 = __importDefault(require("../file/File"));
|
76
|
+
const DOMException_1 = __importDefault(require("../exception/DOMException"));
|
77
|
+
const FileReader_1 = __importDefault(require("../file/FileReader"));
|
78
|
+
const History_1 = __importDefault(require("../history/History"));
|
79
|
+
const CSSStyleSheet_1 = __importDefault(require("../css/CSSStyleSheet"));
|
80
|
+
const CSSStyleDeclaration_1 = __importDefault(require("../css/CSSStyleDeclaration"));
|
81
|
+
const CSS_1 = __importDefault(require("../css/CSS"));
|
82
|
+
const CSSUnitValue_1 = __importDefault(require("../css/CSSUnitValue"));
|
83
|
+
const MouseEvent_1 = __importDefault(require("../event/events/MouseEvent"));
|
84
|
+
const PointerEvent_1 = __importDefault(require("../event/events/PointerEvent"));
|
85
|
+
const FocusEvent_1 = __importDefault(require("../event/events/FocusEvent"));
|
86
|
+
const WheelEvent_1 = __importDefault(require("../event/events/WheelEvent"));
|
87
|
+
const DataTransfer_1 = __importDefault(require("../event/DataTransfer"));
|
88
|
+
const DataTransferItem_1 = __importDefault(require("../event/DataTransferItem"));
|
89
|
+
const DataTransferItemList_1 = __importDefault(require("../event/DataTransferItemList"));
|
90
|
+
const InputEvent_1 = __importDefault(require("../event/events/InputEvent"));
|
91
|
+
const UIEvent_1 = __importDefault(require("../event/UIEvent"));
|
92
|
+
const ErrorEvent_1 = __importDefault(require("../event/events/ErrorEvent"));
|
93
|
+
const StorageEvent_1 = __importDefault(require("../event/events/StorageEvent"));
|
94
|
+
const Screen_1 = __importDefault(require("../screen/Screen"));
|
95
|
+
const AsyncTaskManager_1 = __importDefault(require("../async-task-manager/AsyncTaskManager"));
|
96
|
+
const Headers_1 = __importDefault(require("../fetch/Headers"));
|
97
|
+
const Request_1 = __importDefault(require("../fetch/Request"));
|
98
|
+
const Response_1 = __importDefault(require("../fetch/Response"));
|
99
|
+
const Storage_1 = __importDefault(require("../storage/Storage"));
|
100
|
+
const HTMLCollection_1 = __importDefault(require("../nodes/element/HTMLCollection"));
|
101
|
+
const NodeList_1 = __importDefault(require("../nodes/node/NodeList"));
|
102
|
+
const MediaQueryList_1 = __importDefault(require("../match-media/MediaQueryList"));
|
103
|
+
const Selection_1 = __importDefault(require("../selection/Selection"));
|
104
|
+
const Navigator_1 = __importDefault(require("../navigator/Navigator"));
|
105
|
+
const MimeType_1 = __importDefault(require("../navigator/MimeType"));
|
106
|
+
const MimeTypeArray_1 = __importDefault(require("../navigator/MimeTypeArray"));
|
107
|
+
const Plugin_1 = __importDefault(require("../navigator/Plugin"));
|
108
|
+
const PluginArray_1 = __importDefault(require("../navigator/PluginArray"));
|
109
|
+
const url_1 = require("url");
|
110
|
+
const FetchHandler_1 = __importDefault(require("../fetch/FetchHandler"));
|
111
|
+
const VMGlobalPropertyScript_1 = __importDefault(require("./VMGlobalPropertyScript"));
|
112
|
+
const PerfHooks = __importStar(require("perf_hooks"));
|
113
|
+
const vm_1 = __importDefault(require("vm"));
|
114
|
+
const buffer_1 = require("buffer");
|
160
115
|
/**
|
161
|
-
*
|
116
|
+
* Browser window.
|
117
|
+
*
|
118
|
+
* Reference:
|
119
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Window.
|
162
120
|
*/
|
163
|
-
|
164
|
-
__extends(Window, _super);
|
121
|
+
class Window extends EventTarget_1.default {
|
165
122
|
/**
|
166
123
|
* Constructor.
|
167
124
|
*/
|
168
|
-
|
169
|
-
|
125
|
+
constructor() {
|
126
|
+
super();
|
170
127
|
// Public Properties
|
171
|
-
|
172
|
-
whenAsyncComplete:
|
173
|
-
return
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
}
|
178
|
-
});
|
179
|
-
}); },
|
180
|
-
cancelAsync: function () {
|
181
|
-
_this.happyDOM.asyncTaskManager.cancelAll();
|
128
|
+
this.happyDOM = {
|
129
|
+
whenAsyncComplete: async () => {
|
130
|
+
return await this.happyDOM.asyncTaskManager.whenComplete();
|
131
|
+
},
|
132
|
+
cancelAsync: () => {
|
133
|
+
this.happyDOM.asyncTaskManager.cancelAll();
|
182
134
|
},
|
183
135
|
asyncTaskManager: new AsyncTaskManager_1.default()
|
184
136
|
};
|
185
137
|
// Global classes
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
138
|
+
this.Node = Node_1.default;
|
139
|
+
this.HTMLElement = HTMLElement_1.default;
|
140
|
+
this.HTMLUnknownElement = HTMLUnknownElement_1.default;
|
141
|
+
this.HTMLTemplateElement = HTMLTemplateElement_1.default;
|
142
|
+
this.HTMLFormElement = HTMLFormElement_1.default;
|
143
|
+
this.HTMLInputElement = HTMLInputElement_1.default;
|
144
|
+
this.HTMLTextAreaElement = HTMLTextAreaElement_1.default;
|
145
|
+
this.HTMLImageElement = HTMLImageElement_1.default;
|
146
|
+
this.Image = Image_1.default;
|
147
|
+
this.HTMLScriptElement = HTMLScriptElement_1.default;
|
148
|
+
this.HTMLLinkElement = HTMLLinkElement_1.default;
|
149
|
+
this.HTMLStyleElement = HTMLStyleElement_1.default;
|
150
|
+
this.HTMLLabelElement = HTMLLabelElement_1.default;
|
151
|
+
this.HTMLSlotElement = HTMLSlotElement_1.default;
|
152
|
+
this.HTMLMetaElement = HTMLMetaElement_1.default;
|
153
|
+
this.HTMLBaseElement = HTMLBaseElement_1.default;
|
154
|
+
this.SVGSVGElement = SVGSVGElement_1.default;
|
155
|
+
this.SVGElement = SVGElement_1.default;
|
156
|
+
this.Text = Text_1.default;
|
157
|
+
this.Comment = Comment_1.default;
|
158
|
+
this.ShadowRoot = ShadowRoot_1.default;
|
159
|
+
this.Element = Element_1.default;
|
160
|
+
this.DocumentFragment = DocumentFragment_1.default;
|
161
|
+
this.CharacterData = CharacterData_1.default;
|
162
|
+
this.NodeFilter = NodeFilter_1.default;
|
163
|
+
this.TreeWalker = TreeWalker_1.default;
|
164
|
+
this.DOMParser = DOMParser_1.default;
|
165
|
+
this.MutationObserver = MutationObserver_1.default;
|
166
|
+
this.Document = Document_1.default;
|
167
|
+
this.HTMLDocument = HTMLDocument_1.default;
|
168
|
+
this.XMLDocument = XMLDocument_1.default;
|
169
|
+
this.SVGDocument = SVGDocument_1.default;
|
170
|
+
this.Event = Event_1.default;
|
171
|
+
this.UIEvent = UIEvent_1.default;
|
172
|
+
this.CustomEvent = CustomEvent_1.default;
|
173
|
+
this.AnimationEvent = AnimationEvent_1.default;
|
174
|
+
this.KeyboardEvent = KeyboardEvent_1.default;
|
175
|
+
this.MouseEvent = MouseEvent_1.default;
|
176
|
+
this.PointerEvent = PointerEvent_1.default;
|
177
|
+
this.FocusEvent = FocusEvent_1.default;
|
178
|
+
this.WheelEvent = WheelEvent_1.default;
|
179
|
+
this.InputEvent = InputEvent_1.default;
|
180
|
+
this.ErrorEvent = ErrorEvent_1.default;
|
181
|
+
this.StorageEvent = StorageEvent_1.default;
|
182
|
+
this.ProgressEvent = ProgressEvent_1.default;
|
183
|
+
this.EventTarget = EventTarget_1.default;
|
184
|
+
this.DataTransfer = DataTransfer_1.default;
|
185
|
+
this.DataTransferItem = DataTransferItem_1.default;
|
186
|
+
this.DataTransferItemList = DataTransferItemList_1.default;
|
187
|
+
this.URL = URL_1.default;
|
188
|
+
this.Location = Location_1.default;
|
189
|
+
this.CustomElementRegistry = CustomElementRegistry_1.default;
|
190
|
+
this.Window = this.constructor;
|
191
|
+
this.XMLSerializer = XMLSerializer_1.default;
|
192
|
+
this.ResizeObserver = ResizeObserver_1.default;
|
193
|
+
this.CSSStyleSheet = CSSStyleSheet_1.default;
|
194
|
+
this.Blob = Blob_1.default;
|
195
|
+
this.File = File_1.default;
|
196
|
+
this.FileReader = FileReader_1.default;
|
197
|
+
this.DOMException = DOMException_1.default;
|
198
|
+
this.History = History_1.default;
|
199
|
+
this.Screen = Screen_1.default;
|
200
|
+
this.Storage = Storage_1.default;
|
201
|
+
this.URLSearchParams = url_1.URLSearchParams;
|
202
|
+
this.HTMLCollection = HTMLCollection_1.default;
|
203
|
+
this.NodeList = NodeList_1.default;
|
204
|
+
this.MediaQueryList = MediaQueryList_1.default;
|
205
|
+
this.CSSUnitValue = CSSUnitValue_1.default;
|
206
|
+
this.Selection = Selection_1.default;
|
207
|
+
this.Navigator = Navigator_1.default;
|
208
|
+
this.MimeType = MimeType_1.default;
|
209
|
+
this.MimeTypeArray = MimeTypeArray_1.default;
|
210
|
+
this.Plugin = Plugin_1.default;
|
211
|
+
this.PluginArray = PluginArray_1.default;
|
212
|
+
this.Headers = Headers_1.default;
|
213
|
+
this.Request = Request_1.default;
|
214
|
+
this.Response = Response_1.default;
|
260
215
|
// Events
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
_this.Date = global ? global.Date : null;
|
286
|
-
_this.Error = global ? global.Error : null;
|
287
|
-
_this.EvalError = global ? global.EvalError : null;
|
288
|
-
_this.Float32Array = global ? global.Float32Array : null;
|
289
|
-
_this.Float64Array = global ? global.Float64Array : null;
|
290
|
-
_this.GLOBAL = null;
|
291
|
-
_this.Infinity = global ? global.Infinity : null;
|
292
|
-
_this.Int16Array = global ? global.Int16Array : null;
|
293
|
-
_this.Int32Array = global ? global.Int32Array : null;
|
294
|
-
_this.Int8Array = global ? global.Int8Array : null;
|
295
|
-
_this.Intl = global ? global.Intl : null;
|
296
|
-
_this.JSON = global ? global.JSON : null;
|
297
|
-
_this.Map = global ? global.Map : null;
|
298
|
-
_this.Math = global ? global.Math : null;
|
299
|
-
_this.NaN = global ? global.NaN : null;
|
300
|
-
_this.Number = global ? global.Number : null;
|
301
|
-
_this.Promise = global ? global.Promise : null;
|
302
|
-
_this.RangeError = global ? global.RangeError : null;
|
303
|
-
_this.ReferenceError = global ? global.ReferenceError : null;
|
304
|
-
_this.RegExp = global ? global.RegExp : null;
|
305
|
-
_this.Reflect = global ? global.Reflect : null;
|
306
|
-
_this.Set = global ? global.Set : null;
|
307
|
-
_this.Symbol = global ? global.Symbol : null;
|
308
|
-
_this.SyntaxError = global ? global.SyntaxError : null;
|
309
|
-
_this.String = global ? global.String : null;
|
310
|
-
_this.TypeError = global ? global.TypeError : null;
|
311
|
-
_this.URIError = global ? global.URIError : null;
|
312
|
-
_this.Uint16Array = global ? global.Uint16Array : null;
|
313
|
-
_this.Uint32Array = global ? global.Uint32Array : null;
|
314
|
-
_this.Uint8Array = global ? global.Uint8Array : null;
|
315
|
-
_this.Uint8ClampedArray = global ? global.Uint8ClampedArray : null;
|
316
|
-
_this.WeakMap = global ? global.WeakMap : null;
|
317
|
-
_this.WeakSet = global ? global.WeakSet : null;
|
318
|
-
_this.clearImmediate = null;
|
319
|
-
_this.decodeURI = global ? global.decodeURI : null;
|
320
|
-
_this.decodeURIComponent = global ? global.decodeURIComponent : null;
|
321
|
-
_this.encodeURI = global ? global.encodeURI : null;
|
322
|
-
_this.encodeURIComponent = global ? global.encodeURIComponent : null;
|
323
|
-
_this.escape = global ? global.escape : null;
|
324
|
-
_this.global = null;
|
325
|
-
_this.isFinite = global ? global.isFinite : null;
|
326
|
-
_this.isNaN = global ? global.isNaN : null;
|
327
|
-
_this.parseFloat = global ? global.parseFloat : null;
|
328
|
-
_this.parseInt = global ? global.parseInt : null;
|
329
|
-
_this.process = null;
|
330
|
-
_this.root = null;
|
331
|
-
_this.setImmediate = null;
|
332
|
-
_this.queueMicrotask = global ? global.queueMicrotask : null;
|
333
|
-
_this.undefined = global ? global.undefined : null;
|
334
|
-
_this.unescape = global ? global.unescape : null;
|
335
|
-
_this.gc = null;
|
336
|
-
_this.v8debug = null;
|
337
|
-
_this.AbortController = global ? global.AbortController : null;
|
338
|
-
_this.AbortSignal = global ? global.AbortSignal : null;
|
339
|
-
// Private properties
|
340
|
-
_this._objectClass = null;
|
341
|
-
_this._arrayClass = null;
|
342
|
-
_this._functionClass = null;
|
343
|
-
_this.document = new HTMLDocument_1.default();
|
344
|
-
_this.document.defaultView = _this;
|
345
|
-
_this.document._readyStateManager.whenComplete().then(function () {
|
346
|
-
_this.dispatchEvent(new Event_1.default('load'));
|
216
|
+
this.onload = null;
|
217
|
+
this.onerror = null;
|
218
|
+
this.customElements = new CustomElementRegistry_1.default();
|
219
|
+
this.location = new Location_1.default();
|
220
|
+
this.history = new History_1.default();
|
221
|
+
this.navigator = new Navigator_1.default();
|
222
|
+
this.console = console;
|
223
|
+
this.self = this;
|
224
|
+
this.top = this;
|
225
|
+
this.parent = this;
|
226
|
+
this.window = this;
|
227
|
+
this.globalThis = this;
|
228
|
+
this.screen = new Screen_1.default();
|
229
|
+
this.innerWidth = 1024;
|
230
|
+
this.innerHeight = 768;
|
231
|
+
this.devicePixelRatio = 1;
|
232
|
+
this.sessionStorage = new Storage_1.default();
|
233
|
+
this.localStorage = new Storage_1.default();
|
234
|
+
this.performance = PerfHooks.performance;
|
235
|
+
this.Buffer = buffer_1.Buffer;
|
236
|
+
this.document = new HTMLDocument_1.default();
|
237
|
+
this.document.defaultView = this;
|
238
|
+
this.document._readyStateManager.whenComplete().then(() => {
|
239
|
+
this.dispatchEvent(new Event_1.default('load'));
|
347
240
|
});
|
348
|
-
DOMParser_1.default._ownerDocument =
|
349
|
-
FileReader_1.default._ownerDocument =
|
350
|
-
Image_1.default.ownerDocument =
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
241
|
+
DOMParser_1.default._ownerDocument = this.document;
|
242
|
+
FileReader_1.default._ownerDocument = this.document;
|
243
|
+
Image_1.default.ownerDocument = this.document;
|
244
|
+
Request_1.default._ownerDocument = this.document;
|
245
|
+
Response_1.default._ownerDocument = this.document;
|
246
|
+
for (const eventType of NonImplementedEventTypes_1.default) {
|
247
|
+
if (!this[eventType]) {
|
248
|
+
this[eventType] = Event_1.default;
|
355
249
|
}
|
356
250
|
}
|
357
|
-
for (
|
358
|
-
|
359
|
-
|
360
|
-
_this[className] = HTMLElement_1.default;
|
251
|
+
for (const className of NonImplemenetedElementClasses_1.default) {
|
252
|
+
if (!this[className]) {
|
253
|
+
this[className] = HTMLElement_1.default;
|
361
254
|
}
|
362
255
|
}
|
363
256
|
// Binds all methods to "this", so that it will use the correct context when called globally.
|
364
|
-
for (
|
365
|
-
|
366
|
-
|
367
|
-
_this[key] = _this[key].bind(_this);
|
257
|
+
for (const key of Object.getOwnPropertyNames(this.constructor.prototype)) {
|
258
|
+
if (key !== 'constructor' && key !== 'CSS' && typeof this[key] === 'function') {
|
259
|
+
this[key] = this[key].bind(this);
|
368
260
|
}
|
369
261
|
}
|
370
|
-
|
262
|
+
// Only contextify if there isn't any sub-class handling globals (like GlobalWindow)
|
263
|
+
if (this.Array === undefined && !vm_1.default.isContext(this)) {
|
264
|
+
vm_1.default.createContext(this);
|
265
|
+
// Sets global properties from the VM to the Window object.
|
266
|
+
// Otherwise "this.Array" will be undefined for example.
|
267
|
+
vm_1.default.runInContext(VMGlobalPropertyScript_1.default, this);
|
268
|
+
}
|
269
|
+
}
|
270
|
+
/**
|
271
|
+
* The CSS interface holds useful CSS-related methods.
|
272
|
+
*
|
273
|
+
* @returns CSS interface.
|
274
|
+
*/
|
275
|
+
get CSS() {
|
276
|
+
return new CSS_1.default();
|
371
277
|
}
|
372
|
-
Object.defineProperty(Window.prototype, "Object", {
|
373
|
-
/**
|
374
|
-
* Returns Object class.
|
375
|
-
*
|
376
|
-
* @returns Object class.
|
377
|
-
*/
|
378
|
-
get: function () {
|
379
|
-
if (this._objectClass) {
|
380
|
-
return this._objectClass;
|
381
|
-
}
|
382
|
-
// When inside a VM global.Object is not the same as ({}).constructor
|
383
|
-
// We will therefore run the code inside the VM to get the real constructor
|
384
|
-
this._objectClass = this.eval('({}).constructor');
|
385
|
-
return this._objectClass;
|
386
|
-
},
|
387
|
-
enumerable: false,
|
388
|
-
configurable: true
|
389
|
-
});
|
390
|
-
Object.defineProperty(Window.prototype, "Array", {
|
391
|
-
/**
|
392
|
-
* Returns Array class.
|
393
|
-
*
|
394
|
-
* @returns Array class.
|
395
|
-
*/
|
396
|
-
get: function () {
|
397
|
-
if (this._arrayClass) {
|
398
|
-
return this._arrayClass;
|
399
|
-
}
|
400
|
-
// When inside a VM global.Object is not the same as [].constructor
|
401
|
-
// We will therefore run the code inside the VM to get the real constructor
|
402
|
-
this._arrayClass = this.eval('[].constructor');
|
403
|
-
return this._arrayClass;
|
404
|
-
},
|
405
|
-
enumerable: false,
|
406
|
-
configurable: true
|
407
|
-
});
|
408
|
-
Object.defineProperty(Window.prototype, "Function", {
|
409
|
-
/**
|
410
|
-
* Returns Function class.
|
411
|
-
*
|
412
|
-
* @returns Function class.
|
413
|
-
*/
|
414
|
-
get: function () {
|
415
|
-
if (this._functionClass) {
|
416
|
-
return this._functionClass;
|
417
|
-
}
|
418
|
-
// When inside a VM global.Function is not the same as (() => {}).constructor
|
419
|
-
// We will therefore run the code inside the VM to get the real constructor
|
420
|
-
this._functionClass = this.eval('(() => {}).constructor');
|
421
|
-
return this._functionClass;
|
422
|
-
},
|
423
|
-
enumerable: false,
|
424
|
-
configurable: true
|
425
|
-
});
|
426
|
-
Object.defineProperty(Window.prototype, "CSS", {
|
427
|
-
/**
|
428
|
-
* The CSS interface holds useful CSS-related methods.
|
429
|
-
*
|
430
|
-
* @returns CSS interface.
|
431
|
-
*/
|
432
|
-
get: function () {
|
433
|
-
return new CSS_1.default();
|
434
|
-
},
|
435
|
-
enumerable: false,
|
436
|
-
configurable: true
|
437
|
-
});
|
438
|
-
Object.defineProperty(Window.prototype, "Headers", {
|
439
|
-
/**
|
440
|
-
* Returns Headers class.
|
441
|
-
*
|
442
|
-
* @returns Headers.
|
443
|
-
*/
|
444
|
-
get: function () {
|
445
|
-
return require('../fetch/Headers').default;
|
446
|
-
},
|
447
|
-
enumerable: false,
|
448
|
-
configurable: true
|
449
|
-
});
|
450
|
-
Object.defineProperty(Window.prototype, "Request", {
|
451
|
-
/**
|
452
|
-
* Returns Request class.
|
453
|
-
*
|
454
|
-
* @returns Request.
|
455
|
-
*/
|
456
|
-
get: function () {
|
457
|
-
var Request = require('../fetch/Request').default;
|
458
|
-
Request._ownerDocument = Request._ownerDocument || this.document;
|
459
|
-
return Request;
|
460
|
-
},
|
461
|
-
enumerable: false,
|
462
|
-
configurable: true
|
463
|
-
});
|
464
|
-
Object.defineProperty(Window.prototype, "Response", {
|
465
|
-
/**
|
466
|
-
* Returns Response class.
|
467
|
-
*
|
468
|
-
* @returns Response.
|
469
|
-
*/
|
470
|
-
get: function () {
|
471
|
-
var Response = require('../fetch/Response').default;
|
472
|
-
Response._ownerDocument = Response._ownerDocument || this.document;
|
473
|
-
return Response;
|
474
|
-
},
|
475
|
-
enumerable: false,
|
476
|
-
configurable: true
|
477
|
-
});
|
478
278
|
/**
|
479
279
|
* Evaluates code.
|
480
280
|
*
|
281
|
+
* @override
|
481
282
|
* @param code Code.
|
482
283
|
* @returns Result.
|
483
284
|
*/
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
try {
|
488
|
-
vmExists = !!require.resolve('vm');
|
489
|
-
}
|
490
|
-
catch (error) {
|
491
|
-
// Ignore error;
|
285
|
+
eval(code) {
|
286
|
+
if (vm_1.default.isContext(this)) {
|
287
|
+
return vm_1.default.runInContext(code, this);
|
492
288
|
}
|
493
|
-
|
494
|
-
|
495
|
-
}
|
496
|
-
if (vm && vm.isContext(this)) {
|
497
|
-
return vm.runInContext(code, this);
|
498
|
-
}
|
499
|
-
return global.eval(code);
|
500
|
-
};
|
289
|
+
return eval(code);
|
290
|
+
}
|
501
291
|
/**
|
502
292
|
* Returns an object containing the values of all CSS properties of an element.
|
503
293
|
*
|
504
294
|
* @param element Element.
|
505
295
|
* @returns CSS style declaration.
|
506
296
|
*/
|
507
|
-
|
297
|
+
getComputedStyle(element) {
|
508
298
|
return new CSSStyleDeclaration_1.default(element._attributes, element);
|
509
|
-
}
|
299
|
+
}
|
510
300
|
/**
|
511
301
|
* Scrolls to a particular set of coordinates.
|
512
302
|
*
|
513
303
|
* @param x X position or options object.
|
514
304
|
* @param y Y position.
|
515
305
|
*/
|
516
|
-
|
517
|
-
var _this = this;
|
306
|
+
scroll(x, y) {
|
518
307
|
if (typeof x === 'object') {
|
519
308
|
if (x.behavior === 'smooth') {
|
520
|
-
this.setTimeout(
|
309
|
+
this.setTimeout(() => {
|
521
310
|
if (x.top !== undefined) {
|
522
|
-
|
311
|
+
this.document.documentElement.scrollTop = x.top;
|
523
312
|
}
|
524
313
|
if (x.left !== undefined) {
|
525
|
-
|
314
|
+
this.document.documentElement.scrollLeft = x.left;
|
526
315
|
}
|
527
316
|
});
|
528
317
|
}
|
@@ -539,27 +328,27 @@ var Window = /** @class */ (function (_super) {
|
|
539
328
|
this.document.documentElement.scrollLeft = x;
|
540
329
|
this.document.documentElement.scrollTop = y;
|
541
330
|
}
|
542
|
-
}
|
331
|
+
}
|
543
332
|
/**
|
544
333
|
* Scrolls to a particular set of coordinates.
|
545
334
|
*
|
546
335
|
* @param x X position or options object.
|
547
336
|
* @param y Y position.
|
548
337
|
*/
|
549
|
-
|
338
|
+
scrollTo(x, y) {
|
550
339
|
this.scroll(x, y);
|
551
|
-
}
|
340
|
+
}
|
552
341
|
/**
|
553
342
|
* Returns a new MediaQueryList object that can then be used to determine if the document matches the media query string.
|
554
343
|
*
|
555
344
|
* @param mediaQueryString A string specifying the media query to parse into a MediaQueryList.
|
556
345
|
* @returns A new MediaQueryList.
|
557
346
|
*/
|
558
|
-
|
559
|
-
|
347
|
+
matchMedia(mediaQueryString) {
|
348
|
+
const mediaQueryList = new MediaQueryList_1.default();
|
560
349
|
mediaQueryList._media = mediaQueryString;
|
561
350
|
return mediaQueryList;
|
562
|
-
}
|
351
|
+
}
|
563
352
|
/**
|
564
353
|
* Sets a timer which executes a function once the timer expires.
|
565
354
|
*
|
@@ -568,26 +357,24 @@ var Window = /** @class */ (function (_super) {
|
|
568
357
|
* @param [delay=0] Delay in ms.
|
569
358
|
* @returns Timeout ID.
|
570
359
|
*/
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
var id = global.setTimeout(function () {
|
575
|
-
_this.happyDOM.asyncTaskManager.endTimer(id);
|
360
|
+
setTimeout(callback, delay = 0) {
|
361
|
+
const id = setTimeout(() => {
|
362
|
+
this.happyDOM.asyncTaskManager.endTimer(id);
|
576
363
|
callback();
|
577
364
|
}, delay);
|
578
365
|
this.happyDOM.asyncTaskManager.startTimer(id);
|
579
366
|
return id;
|
580
|
-
}
|
367
|
+
}
|
581
368
|
/**
|
582
369
|
* Cancels a timeout previously established by calling setTimeout().
|
583
370
|
*
|
584
371
|
* @override
|
585
372
|
* @param id ID of the timeout.
|
586
373
|
*/
|
587
|
-
|
588
|
-
|
374
|
+
clearTimeout(id) {
|
375
|
+
clearTimeout(id);
|
589
376
|
this.happyDOM.asyncTaskManager.endTimer(id);
|
590
|
-
}
|
377
|
+
}
|
591
378
|
/**
|
592
379
|
* Calls a function with a fixed time delay between each call.
|
593
380
|
*
|
@@ -596,22 +383,21 @@ var Window = /** @class */ (function (_super) {
|
|
596
383
|
* @param [delay=0] Delay in ms.
|
597
384
|
* @returns Interval ID.
|
598
385
|
*/
|
599
|
-
|
600
|
-
|
601
|
-
var id = global.setInterval(callback, delay);
|
386
|
+
setInterval(callback, delay = 0) {
|
387
|
+
const id = setInterval(callback, delay);
|
602
388
|
this.happyDOM.asyncTaskManager.startTimer(id);
|
603
389
|
return id;
|
604
|
-
}
|
390
|
+
}
|
605
391
|
/**
|
606
392
|
* Cancels a timed repeating action which was previously established by a call to setInterval().
|
607
393
|
*
|
608
394
|
* @override
|
609
395
|
* @param id ID of the interval.
|
610
396
|
*/
|
611
|
-
|
612
|
-
|
397
|
+
clearInterval(id) {
|
398
|
+
clearInterval(id);
|
613
399
|
this.happyDOM.asyncTaskManager.endTimer(id);
|
614
|
-
}
|
400
|
+
}
|
615
401
|
/**
|
616
402
|
* Mock animation frames with timeouts.
|
617
403
|
*
|
@@ -619,20 +405,20 @@ var Window = /** @class */ (function (_super) {
|
|
619
405
|
* @param callback Callback.
|
620
406
|
* @returns Timeout ID.
|
621
407
|
*/
|
622
|
-
|
623
|
-
return this.setTimeout(
|
408
|
+
requestAnimationFrame(callback) {
|
409
|
+
return this.setTimeout(() => {
|
624
410
|
callback(2);
|
625
411
|
});
|
626
|
-
}
|
412
|
+
}
|
627
413
|
/**
|
628
414
|
* Mock animation frames with timeouts.
|
629
415
|
*
|
630
416
|
* @override
|
631
417
|
* @param id Timeout ID.
|
632
418
|
*/
|
633
|
-
|
419
|
+
cancelAnimationFrame(id) {
|
634
420
|
this.clearTimeout(id);
|
635
|
-
}
|
421
|
+
}
|
636
422
|
/**
|
637
423
|
* This method provides an easy, logical way to fetch resources asynchronously across the network.
|
638
424
|
*
|
@@ -641,17 +427,9 @@ var Window = /** @class */ (function (_super) {
|
|
641
427
|
* @param [init] Init.
|
642
428
|
* @returns Promise.
|
643
429
|
*/
|
644
|
-
|
645
|
-
return
|
646
|
-
|
647
|
-
|
648
|
-
case 0: return [4 /*yield*/, FetchHandler_1.default.fetch(this.document, url, init)];
|
649
|
-
case 1: return [2 /*return*/, _a.sent()];
|
650
|
-
}
|
651
|
-
});
|
652
|
-
});
|
653
|
-
};
|
654
|
-
return Window;
|
655
|
-
}(EventTarget_1.default));
|
430
|
+
async fetch(url, init) {
|
431
|
+
return await FetchHandler_1.default.fetch(this.document, url, init);
|
432
|
+
}
|
433
|
+
}
|
656
434
|
exports.default = Window;
|
657
435
|
//# sourceMappingURL=Window.js.map
|