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/src/window/Window.ts
CHANGED
@@ -71,25 +71,34 @@ import IRequest from '../fetch/IRequest';
|
|
71
71
|
import IRequestInit from '../fetch/IRequestInit';
|
72
72
|
import IHeaders from '../fetch/IHeaders';
|
73
73
|
import IHeadersInit from '../fetch/IHeadersInit';
|
74
|
+
import Headers from '../fetch/Headers';
|
75
|
+
import Request from '../fetch/Request';
|
76
|
+
import Response from '../fetch/Response';
|
74
77
|
import Storage from '../storage/Storage';
|
75
78
|
import IWindow from './IWindow';
|
76
79
|
import HTMLCollection from '../nodes/element/HTMLCollection';
|
77
80
|
import NodeList from '../nodes/node/NodeList';
|
78
81
|
import MediaQueryList from '../match-media/MediaQueryList';
|
79
82
|
import Selection from '../selection/Selection';
|
80
|
-
import * as PerfHooks from 'perf_hooks';
|
81
83
|
import Navigator from '../navigator/Navigator';
|
82
84
|
import MimeType from '../navigator/MimeType';
|
83
85
|
import MimeTypeArray from '../navigator/MimeTypeArray';
|
84
86
|
import Plugin from '../navigator/Plugin';
|
85
87
|
import PluginArray from '../navigator/PluginArray';
|
86
|
-
import FetchHandler from '../fetch/FetchHandler';
|
87
88
|
import { URLSearchParams } from 'url';
|
89
|
+
import FetchHandler from '../fetch/FetchHandler';
|
90
|
+
import VMGlobalPropertyScript from './VMGlobalPropertyScript';
|
91
|
+
import * as PerfHooks from 'perf_hooks';
|
92
|
+
import VM from 'vm';
|
93
|
+
import { Buffer } from 'buffer';
|
88
94
|
|
89
95
|
/**
|
90
|
-
*
|
96
|
+
* Browser window.
|
97
|
+
*
|
98
|
+
* Reference:
|
99
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Window.
|
91
100
|
*/
|
92
|
-
export default class Window extends EventTarget implements IWindow
|
101
|
+
export default class Window extends EventTarget implements IWindow {
|
93
102
|
// Public Properties
|
94
103
|
public readonly happyDOM = {
|
95
104
|
whenAsyncComplete: async (): Promise<void> => {
|
@@ -154,7 +163,7 @@ export default class Window extends EventTarget implements IWindow, NodeJS.Globa
|
|
154
163
|
public readonly URL = URL;
|
155
164
|
public readonly Location = Location;
|
156
165
|
public readonly CustomElementRegistry = CustomElementRegistry;
|
157
|
-
public readonly Window = Window;
|
166
|
+
public readonly Window = <typeof Window>this.constructor;
|
158
167
|
public readonly XMLSerializer = XMLSerializer;
|
159
168
|
public readonly ResizeObserver = ResizeObserver;
|
160
169
|
public readonly CSSStyleSheet = CSSStyleSheet;
|
@@ -176,6 +185,13 @@ export default class Window extends EventTarget implements IWindow, NodeJS.Globa
|
|
176
185
|
public readonly MimeTypeArray = MimeTypeArray;
|
177
186
|
public readonly Plugin = Plugin;
|
178
187
|
public readonly PluginArray = PluginArray;
|
188
|
+
public readonly Headers: { new (init?: IHeadersInit): IHeaders } = Headers;
|
189
|
+
public readonly Request: {
|
190
|
+
new (input: string | { href: string } | IRequest, init?: IRequestInit): IRequest;
|
191
|
+
} = Request;
|
192
|
+
public readonly Response: {
|
193
|
+
new (body?: NodeJS.ReadableStream | null, init?: IResponseInit): IResponse;
|
194
|
+
} = Response;
|
179
195
|
|
180
196
|
// Events
|
181
197
|
public onload: (event: Event) => void = null;
|
@@ -187,7 +203,7 @@ export default class Window extends EventTarget implements IWindow, NodeJS.Globa
|
|
187
203
|
public readonly location = new Location();
|
188
204
|
public readonly history = new History();
|
189
205
|
public readonly navigator = new Navigator();
|
190
|
-
public readonly console =
|
206
|
+
public readonly console = console;
|
191
207
|
public readonly self = this;
|
192
208
|
public readonly top = this;
|
193
209
|
public readonly parent = this;
|
@@ -202,69 +218,67 @@ export default class Window extends EventTarget implements IWindow, NodeJS.Globa
|
|
202
218
|
public readonly performance = PerfHooks.performance;
|
203
219
|
|
204
220
|
// Node.js Globals
|
205
|
-
public ArrayBuffer
|
206
|
-
public Boolean
|
207
|
-
public Buffer =
|
208
|
-
public DataView
|
209
|
-
public Date
|
210
|
-
public Error
|
211
|
-
public EvalError
|
212
|
-
public Float32Array
|
213
|
-
public Float64Array
|
214
|
-
public GLOBAL
|
215
|
-
public Infinity
|
216
|
-
public Int16Array
|
217
|
-
public Int32Array
|
218
|
-
public Int8Array
|
219
|
-
public Intl
|
220
|
-
public JSON
|
221
|
-
public Map
|
222
|
-
public Math
|
223
|
-
public NaN
|
224
|
-
public Number
|
225
|
-
public Promise
|
226
|
-
public RangeError
|
227
|
-
public ReferenceError
|
228
|
-
public RegExp
|
229
|
-
public Reflect
|
230
|
-
public Set
|
231
|
-
public Symbol
|
232
|
-
public SyntaxError
|
233
|
-
public String
|
234
|
-
public TypeError
|
235
|
-
public URIError
|
236
|
-
public Uint16Array
|
237
|
-
public Uint32Array
|
238
|
-
public Uint8Array
|
239
|
-
public Uint8ClampedArray
|
240
|
-
public WeakMap
|
241
|
-
public WeakSet
|
242
|
-
public clearImmediate
|
243
|
-
public decodeURI
|
244
|
-
public decodeURIComponent
|
245
|
-
public encodeURI
|
246
|
-
public encodeURIComponent
|
247
|
-
public escape
|
248
|
-
public global
|
249
|
-
public isFinite
|
250
|
-
public isNaN
|
251
|
-
public parseFloat
|
252
|
-
public parseInt
|
253
|
-
public process
|
254
|
-
public root
|
255
|
-
public setImmediate
|
256
|
-
public queueMicrotask
|
257
|
-
public undefined
|
258
|
-
public unescape
|
259
|
-
public gc
|
260
|
-
public v8debug
|
261
|
-
public AbortController
|
262
|
-
public AbortSignal
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
private _arrayClass: typeof globalThis.Array = null;
|
267
|
-
private _functionClass: typeof globalThis.Function = null;
|
221
|
+
public ArrayBuffer;
|
222
|
+
public Boolean;
|
223
|
+
public Buffer = Buffer;
|
224
|
+
public DataView;
|
225
|
+
public Date;
|
226
|
+
public Error;
|
227
|
+
public EvalError;
|
228
|
+
public Float32Array;
|
229
|
+
public Float64Array;
|
230
|
+
public GLOBAL;
|
231
|
+
public Infinity;
|
232
|
+
public Int16Array;
|
233
|
+
public Int32Array;
|
234
|
+
public Int8Array;
|
235
|
+
public Intl;
|
236
|
+
public JSON;
|
237
|
+
public Map;
|
238
|
+
public Math;
|
239
|
+
public NaN;
|
240
|
+
public Number;
|
241
|
+
public Promise;
|
242
|
+
public RangeError;
|
243
|
+
public ReferenceError;
|
244
|
+
public RegExp;
|
245
|
+
public Reflect;
|
246
|
+
public Set;
|
247
|
+
public Symbol;
|
248
|
+
public SyntaxError;
|
249
|
+
public String;
|
250
|
+
public TypeError;
|
251
|
+
public URIError;
|
252
|
+
public Uint16Array;
|
253
|
+
public Uint32Array;
|
254
|
+
public Uint8Array;
|
255
|
+
public Uint8ClampedArray;
|
256
|
+
public WeakMap;
|
257
|
+
public WeakSet;
|
258
|
+
public clearImmediate;
|
259
|
+
public decodeURI;
|
260
|
+
public decodeURIComponent;
|
261
|
+
public encodeURI;
|
262
|
+
public encodeURIComponent;
|
263
|
+
public escape;
|
264
|
+
public global;
|
265
|
+
public isFinite;
|
266
|
+
public isNaN;
|
267
|
+
public parseFloat;
|
268
|
+
public parseInt;
|
269
|
+
public process;
|
270
|
+
public root;
|
271
|
+
public setImmediate;
|
272
|
+
public queueMicrotask;
|
273
|
+
public undefined;
|
274
|
+
public unescape;
|
275
|
+
public gc;
|
276
|
+
public v8debug;
|
277
|
+
public AbortController;
|
278
|
+
public AbortSignal;
|
279
|
+
public Array;
|
280
|
+
public Object;
|
281
|
+
public Function;
|
268
282
|
|
269
283
|
/**
|
270
284
|
* Constructor.
|
@@ -278,9 +292,11 @@ export default class Window extends EventTarget implements IWindow, NodeJS.Globa
|
|
278
292
|
this.dispatchEvent(new Event('load'));
|
279
293
|
});
|
280
294
|
|
281
|
-
DOMParser._ownerDocument =
|
282
|
-
FileReader._ownerDocument =
|
283
|
-
Image.ownerDocument =
|
295
|
+
DOMParser._ownerDocument = this.document;
|
296
|
+
FileReader._ownerDocument = this.document;
|
297
|
+
Image.ownerDocument = this.document;
|
298
|
+
Request._ownerDocument = this.document;
|
299
|
+
Response._ownerDocument = this.document;
|
284
300
|
|
285
301
|
for (const eventType of NonImplementedEventTypes) {
|
286
302
|
if (!this[eventType]) {
|
@@ -295,56 +311,20 @@ export default class Window extends EventTarget implements IWindow, NodeJS.Globa
|
|
295
311
|
}
|
296
312
|
|
297
313
|
// Binds all methods to "this", so that it will use the correct context when called globally.
|
298
|
-
for (const key of Object.
|
299
|
-
if (typeof this[key] === 'function') {
|
314
|
+
for (const key of Object.getOwnPropertyNames(this.constructor.prototype)) {
|
315
|
+
if (key !== 'constructor' && key !== 'CSS' && typeof this[key] === 'function') {
|
300
316
|
this[key] = this[key].bind(this);
|
301
317
|
}
|
302
318
|
}
|
303
|
-
}
|
304
319
|
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
* @returns Object class.
|
309
|
-
*/
|
310
|
-
public get Object(): typeof globalThis.Object {
|
311
|
-
if (this._objectClass) {
|
312
|
-
return this._objectClass;
|
313
|
-
}
|
314
|
-
// When inside a VM global.Object is not the same as ({}).constructor
|
315
|
-
// We will therefore run the code inside the VM to get the real constructor
|
316
|
-
this._objectClass = <typeof globalThis.Object>this.eval('({}).constructor');
|
317
|
-
return this._objectClass;
|
318
|
-
}
|
320
|
+
// Only contextify if there isn't any sub-class handling globals (like GlobalWindow)
|
321
|
+
if (this.Array === undefined && !VM.isContext(this)) {
|
322
|
+
VM.createContext(this);
|
319
323
|
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
* @returns Array class.
|
324
|
-
*/
|
325
|
-
public get Array(): typeof globalThis.Array {
|
326
|
-
if (this._arrayClass) {
|
327
|
-
return this._arrayClass;
|
324
|
+
// Sets global properties from the VM to the Window object.
|
325
|
+
// Otherwise "this.Array" will be undefined for example.
|
326
|
+
VM.runInContext(VMGlobalPropertyScript, this);
|
328
327
|
}
|
329
|
-
// When inside a VM global.Object is not the same as [].constructor
|
330
|
-
// We will therefore run the code inside the VM to get the real constructor
|
331
|
-
this._arrayClass = <typeof globalThis.Array>this.eval('[].constructor');
|
332
|
-
return this._arrayClass;
|
333
|
-
}
|
334
|
-
|
335
|
-
/**
|
336
|
-
* Returns Function class.
|
337
|
-
*
|
338
|
-
* @returns Function class.
|
339
|
-
*/
|
340
|
-
public get Function(): typeof globalThis.Function {
|
341
|
-
if (this._functionClass) {
|
342
|
-
return this._functionClass;
|
343
|
-
}
|
344
|
-
// When inside a VM global.Function is not the same as (() => {}).constructor
|
345
|
-
// We will therefore run the code inside the VM to get the real constructor
|
346
|
-
this._functionClass = <typeof globalThis.Function>this.eval('(() => {}).constructor');
|
347
|
-
return this._functionClass;
|
348
328
|
}
|
349
329
|
|
350
330
|
/**
|
@@ -356,68 +336,19 @@ export default class Window extends EventTarget implements IWindow, NodeJS.Globa
|
|
356
336
|
return new CSS();
|
357
337
|
}
|
358
338
|
|
359
|
-
/**
|
360
|
-
* Returns Headers class.
|
361
|
-
*
|
362
|
-
* @returns Headers.
|
363
|
-
*/
|
364
|
-
public get Headers(): {
|
365
|
-
new (init?: IHeadersInit): IHeaders;
|
366
|
-
} {
|
367
|
-
return require('../fetch/Headers').default;
|
368
|
-
}
|
369
|
-
|
370
|
-
/**
|
371
|
-
* Returns Request class.
|
372
|
-
*
|
373
|
-
* @returns Request.
|
374
|
-
*/
|
375
|
-
public get Request(): {
|
376
|
-
new (input: string | { href: string } | IRequest, init?: IRequestInit): IRequest;
|
377
|
-
} {
|
378
|
-
const Request = require('../fetch/Request').default;
|
379
|
-
Request._ownerDocument = Request._ownerDocument || this.document;
|
380
|
-
return Request;
|
381
|
-
}
|
382
|
-
|
383
|
-
/**
|
384
|
-
* Returns Response class.
|
385
|
-
*
|
386
|
-
* @returns Response.
|
387
|
-
*/
|
388
|
-
public get Response(): {
|
389
|
-
new (body?: NodeJS.ReadableStream | null, init?: IResponseInit): IResponse;
|
390
|
-
} {
|
391
|
-
const Response = require('../fetch/Response').default;
|
392
|
-
Response._ownerDocument = Response._ownerDocument || this.document;
|
393
|
-
return Response;
|
394
|
-
}
|
395
|
-
|
396
339
|
/**
|
397
340
|
* Evaluates code.
|
398
341
|
*
|
342
|
+
* @override
|
399
343
|
* @param code Code.
|
400
344
|
* @returns Result.
|
401
345
|
*/
|
402
346
|
public eval(code: string): unknown {
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
try {
|
407
|
-
vmExists = !!require.resolve('vm');
|
408
|
-
} catch (error) {
|
409
|
-
// Ignore error;
|
410
|
-
}
|
411
|
-
|
412
|
-
if (vmExists) {
|
413
|
-
vm = require('vm');
|
414
|
-
}
|
415
|
-
|
416
|
-
if (vm && vm.isContext(this)) {
|
417
|
-
return vm.runInContext(code, this);
|
347
|
+
if (VM.isContext(this)) {
|
348
|
+
return VM.runInContext(code, this);
|
418
349
|
}
|
419
350
|
|
420
|
-
return
|
351
|
+
return eval(code);
|
421
352
|
}
|
422
353
|
|
423
354
|
/**
|
@@ -495,7 +426,7 @@ export default class Window extends EventTarget implements IWindow, NodeJS.Globa
|
|
495
426
|
* @returns Timeout ID.
|
496
427
|
*/
|
497
428
|
public setTimeout(callback: () => void, delay = 0): NodeJS.Timeout {
|
498
|
-
const id =
|
429
|
+
const id = setTimeout(() => {
|
499
430
|
this.happyDOM.asyncTaskManager.endTimer(id);
|
500
431
|
callback();
|
501
432
|
}, delay);
|
@@ -510,7 +441,7 @@ export default class Window extends EventTarget implements IWindow, NodeJS.Globa
|
|
510
441
|
* @param id ID of the timeout.
|
511
442
|
*/
|
512
443
|
public clearTimeout(id: NodeJS.Timeout): void {
|
513
|
-
|
444
|
+
clearTimeout(id);
|
514
445
|
this.happyDOM.asyncTaskManager.endTimer(id);
|
515
446
|
}
|
516
447
|
|
@@ -523,7 +454,7 @@ export default class Window extends EventTarget implements IWindow, NodeJS.Globa
|
|
523
454
|
* @returns Interval ID.
|
524
455
|
*/
|
525
456
|
public setInterval(callback: () => void, delay = 0): NodeJS.Timeout {
|
526
|
-
const id =
|
457
|
+
const id = setInterval(callback, delay);
|
527
458
|
this.happyDOM.asyncTaskManager.startTimer(id);
|
528
459
|
return id;
|
529
460
|
}
|
@@ -535,7 +466,7 @@ export default class Window extends EventTarget implements IWindow, NodeJS.Globa
|
|
535
466
|
* @param id ID of the interval.
|
536
467
|
*/
|
537
468
|
public clearInterval(id: NodeJS.Timeout): void {
|
538
|
-
|
469
|
+
clearInterval(id);
|
539
470
|
this.happyDOM.asyncTaskManager.endTimer(id);
|
540
471
|
}
|
541
472
|
|
package/tsconfig.json
CHANGED
@@ -1,10 +0,0 @@
|
|
1
|
-
import Window from './Window';
|
2
|
-
/**
|
3
|
-
* The async Window makes it possible to wait for asyncrounous tasks to complete by calling the method whenAsyncComplete(). It also adds support for the method fetch().
|
4
|
-
*/
|
5
|
-
export default class AsyncWindow extends Window {
|
6
|
-
/**
|
7
|
-
* Constructor.
|
8
|
-
*/
|
9
|
-
constructor();
|
10
|
-
}
|
@@ -1,38 +0,0 @@
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
19
|
-
};
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
21
|
-
var Window_1 = __importDefault(require("./Window"));
|
22
|
-
/**
|
23
|
-
* The async Window makes it possible to wait for asyncrounous tasks to complete by calling the method whenAsyncComplete(). It also adds support for the method fetch().
|
24
|
-
*/
|
25
|
-
var AsyncWindow = /** @class */ (function (_super) {
|
26
|
-
__extends(AsyncWindow, _super);
|
27
|
-
/**
|
28
|
-
* Constructor.
|
29
|
-
*/
|
30
|
-
function AsyncWindow() {
|
31
|
-
var _this = _super.call(this) || this;
|
32
|
-
_this.console.warn('⚠ AsyncWindow has been deprecated in Happy DOM. All the functionality of AsyncWindow has been added to Window, so there is no need to use AsyncWindow. AsyncWindow will be removed in the future.');
|
33
|
-
return _this;
|
34
|
-
}
|
35
|
-
return AsyncWindow;
|
36
|
-
}(Window_1.default));
|
37
|
-
exports.default = AsyncWindow;
|
38
|
-
//# sourceMappingURL=AsyncWindow.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"AsyncWindow.js","sourceRoot":"","sources":["../../src/window/AsyncWindow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,oDAA8B;AAE9B;;GAEG;AACH;IAAyC,+BAAM;IAC9C;;OAEG;IACH;QAAA,YACC,iBAAO,SAKP;QAHA,KAAI,CAAC,OAAO,CAAC,IAAI,CAChB,mMAAmM,CACnM,CAAC;;IACH,CAAC;IACF,kBAAC;AAAD,CAAC,AAXD,CAAyC,gBAAM,GAW9C"}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import Window from './Window';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* The async Window makes it possible to wait for asyncrounous tasks to complete by calling the method whenAsyncComplete(). It also adds support for the method fetch().
|
5
|
-
*/
|
6
|
-
export default class AsyncWindow extends Window {
|
7
|
-
/**
|
8
|
-
* Constructor.
|
9
|
-
*/
|
10
|
-
constructor() {
|
11
|
-
super();
|
12
|
-
|
13
|
-
this.console.warn(
|
14
|
-
'⚠ AsyncWindow has been deprecated in Happy DOM. All the functionality of AsyncWindow has been added to Window, so there is no need to use AsyncWindow. AsyncWindow will be removed in the future.'
|
15
|
-
);
|
16
|
-
}
|
17
|
-
}
|