-
-
Notifications
You must be signed in to change notification settings - Fork 219
/
Copy pathBrowserWindow.ts
1771 lines (1647 loc) · 69.4 KB
/
BrowserWindow.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
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
260
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { Buffer } from 'buffer';
import { webcrypto } from 'crypto';
import { TextEncoder, TextDecoder } from 'util';
import Stream from 'stream';
import { ReadableStream } from 'stream/web';
import { URLSearchParams } from 'url';
import VM from 'vm';
import * as PropertySymbol from '../PropertySymbol.js';
import Base64 from '../base64/Base64.js';
import BrowserErrorCaptureEnum from '../browser/enums/BrowserErrorCaptureEnum.js';
import IBrowserFrame from '../browser/types/IBrowserFrame.js';
import Clipboard from '../clipboard/Clipboard.js';
import ClipboardItem from '../clipboard/ClipboardItem.js';
import CSS from '../css/CSS.js';
import CSSRule from '../css/CSSRule.js';
import CSSStyleSheet from '../css/CSSStyleSheet.js';
import CSSUnitValue from '../css/CSSUnitValue.js';
import CSSStyleDeclaration from '../css/declaration/CSSStyleDeclaration.js';
import CSSContainerRule from '../css/rules/CSSContainerRule.js';
import CSSFontFaceRule from '../css/rules/CSSFontFaceRule.js';
import CSSKeyframeRule from '../css/rules/CSSKeyframeRule.js';
import CSSKeyframesRule from '../css/rules/CSSKeyframesRule.js';
import CSSMediaRule from '../css/rules/CSSMediaRule.js';
import CSSStyleRule from '../css/rules/CSSStyleRule.js';
import CSSSupportsRule from '../css/rules/CSSSupportsRule.js';
import CustomElementRegistry from '../custom-element/CustomElementRegistry.js';
import DOMParser from '../dom-parser/DOMParser.js';
import DataTransfer from '../event/DataTransfer.js';
import DataTransferItem from '../event/DataTransferItem.js';
import DataTransferItemList from '../event/DataTransferItemList.js';
import Event from '../event/Event.js';
import EventTarget from '../event/EventTarget.js';
import MessagePort from '../event/MessagePort.js';
import Touch from '../event/Touch.js';
import UIEvent from '../event/UIEvent.js';
import AnimationEvent from '../event/events/AnimationEvent.js';
import ClipboardEvent from '../event/events/ClipboardEvent.js';
import CustomEvent from '../event/events/CustomEvent.js';
import ErrorEvent from '../event/events/ErrorEvent.js';
import FocusEvent from '../event/events/FocusEvent.js';
import HashChangeEvent from '../event/events/HashChangeEvent.js';
import InputEvent from '../event/events/InputEvent.js';
import KeyboardEvent from '../event/events/KeyboardEvent.js';
import MediaQueryListEvent from '../event/events/MediaQueryListEvent.js';
import MessageEvent from '../event/events/MessageEvent.js';
import MouseEvent from '../event/events/MouseEvent.js';
import PointerEvent from '../event/events/PointerEvent.js';
import ProgressEvent from '../event/events/ProgressEvent.js';
import StorageEvent from '../event/events/StorageEvent.js';
import SubmitEvent from '../event/events/SubmitEvent.js';
import TouchEvent from '../event/events/TouchEvent.js';
import WheelEvent from '../event/events/WheelEvent.js';
import DOMException from '../exception/DOMException.js';
import DOMExceptionNameEnum from '../exception/DOMExceptionNameEnum.js';
import AbortController from '../fetch/AbortController.js';
import AbortSignal from '../fetch/AbortSignal.js';
import Fetch from '../fetch/Fetch.js';
import Headers from '../fetch/Headers.js';
import Request from '../fetch/Request.js';
import Response from '../fetch/Response.js';
import IRequestInfo from '../fetch/types/IRequestInfo.js';
import IRequestInit from '../fetch/types/IRequestInit.js';
import Blob from '../file/Blob.js';
import File from '../file/File.js';
import FileReader from '../file/FileReader.js';
import FormData from '../form-data/FormData.js';
import History from '../history/History.js';
import IntersectionObserver from '../intersection-observer/IntersectionObserver.js';
import IntersectionObserverEntry from '../intersection-observer/IntersectionObserverEntry.js';
import Location from '../location/Location.js';
import MediaQueryList from '../match-media/MediaQueryList.js';
import MutationObserver from '../mutation-observer/MutationObserver.js';
import MutationRecord from '../mutation-observer/MutationRecord.js';
import MimeType from '../navigator/MimeType.js';
import MimeTypeArray from '../navigator/MimeTypeArray.js';
import Navigator from '../navigator/Navigator.js';
import Plugin from '../navigator/Plugin.js';
import PluginArray from '../navigator/PluginArray.js';
import Attr from '../nodes/attr/Attr.js';
import CharacterData from '../nodes/character-data/CharacterData.js';
import Comment from '../nodes/comment/Comment.js';
import DocumentFragment from '../nodes/document-fragment/DocumentFragment.js';
import DocumentType from '../nodes/document-type/DocumentType.js';
import Document from '../nodes/document/Document.js';
import DocumentReadyStateEnum from '../nodes/document/DocumentReadyStateEnum.js';
import DocumentReadyStateManager from '../nodes/document/DocumentReadyStateManager.js';
import DOMRect from '../dom/DOMRect.js';
import DOMRectReadOnly from '../dom/DOMRectReadOnly.js';
import Element from '../nodes/element/Element.js';
import HTMLCollection from '../nodes/element/HTMLCollection.js';
import NamedNodeMap from '../nodes/element/NamedNodeMap.js';
import HTMLAnchorElement from '../nodes/html-anchor-element/HTMLAnchorElement.js';
import HTMLAreaElement from '../nodes/html-area-element/HTMLAreaElement.js';
import Audio from '../nodes/html-audio-element/Audio.js';
import HTMLAudioElement from '../nodes/html-audio-element/HTMLAudioElement.js';
import HTMLBaseElement from '../nodes/html-base-element/HTMLBaseElement.js';
import HTMLBodyElement from '../nodes/html-body-element/HTMLBodyElement.js';
import HTMLBRElement from '../nodes/html-br-element/HTMLBRElement.js';
import HTMLButtonElement from '../nodes/html-button-element/HTMLButtonElement.js';
import HTMLCanvasElement from '../nodes/html-canvas-element/HTMLCanvasElement.js';
import HTMLDListElement from '../nodes/html-d-list-element/HTMLDListElement.js';
import HTMLDataElement from '../nodes/html-data-element/HTMLDataElement.js';
import HTMLDataListElement from '../nodes/html-data-list-element/HTMLDataListElement.js';
import HTMLDetailsElement from '../nodes/html-details-element/HTMLDetailsElement.js';
import HTMLDialogElement from '../nodes/html-dialog-element/HTMLDialogElement.js';
import HTMLDivElement from '../nodes/html-div-element/HTMLDivElement.js';
import HTMLDocument from '../nodes/html-document/HTMLDocument.js';
import HTMLElement from '../nodes/html-element/HTMLElement.js';
import HTMLEmbedElement from '../nodes/html-embed-element/HTMLEmbedElement.js';
import HTMLFieldSetElement from '../nodes/html-field-set-element/HTMLFieldSetElement.js';
import HTMLFormControlsCollection from '../nodes/html-form-element/HTMLFormControlsCollection.js';
import HTMLFormElement from '../nodes/html-form-element/HTMLFormElement.js';
import RadioNodeList from '../nodes/html-form-element/RadioNodeList.js';
import HTMLHeadElement from '../nodes/html-head-element/HTMLHeadElement.js';
import HTMLHeadingElement from '../nodes/html-heading-element/HTMLHeadingElement.js';
import HTMLHRElement from '../nodes/html-hr-element/HTMLHRElement.js';
import HTMLHtmlElement from '../nodes/html-html-element/HTMLHtmlElement.js';
import HTMLIFrameElement from '../nodes/html-iframe-element/HTMLIFrameElement.js';
import HTMLImageElement from '../nodes/html-image-element/HTMLImageElement.js';
import Image from '../nodes/html-image-element/Image.js';
import FileList from '../nodes/html-input-element/FileList.js';
import HTMLInputElement from '../nodes/html-input-element/HTMLInputElement.js';
import HTMLLabelElement from '../nodes/html-label-element/HTMLLabelElement.js';
import HTMLLegendElement from '../nodes/html-legend-element/HTMLLegendElement.js';
import HTMLLIElement from '../nodes/html-li-element/HTMLLIElement.js';
import HTMLLinkElement from '../nodes/html-link-element/HTMLLinkElement.js';
import HTMLMapElement from '../nodes/html-map-element/HTMLMapElement.js';
import HTMLMediaElement from '../nodes/html-media-element/HTMLMediaElement.js';
import MediaStream from '../nodes/html-media-element/MediaStream.js';
import MediaStreamTrack from '../nodes/html-media-element/MediaStreamTrack.js';
import RemotePlayback from '../nodes/html-media-element/RemotePlayback.js';
import TextTrack from '../nodes/html-media-element/TextTrack.js';
import TextTrackCue from '../nodes/html-media-element/TextTrackCue.js';
import TextTrackCueList from '../nodes/html-media-element/TextTrackCueList.js';
import TextTrackList from '../nodes/html-media-element/TextTrackList.js';
import TimeRanges from '../nodes/html-media-element/TimeRanges.js';
import VTTCue from '../nodes/html-media-element/VTTCue.js';
import HTMLMenuElement from '../nodes/html-menu-element/HTMLMenuElement.js';
import HTMLMetaElement from '../nodes/html-meta-element/HTMLMetaElement.js';
import HTMLMeterElement from '../nodes/html-meter-element/HTMLMeterElement.js';
import HTMLModElement from '../nodes/html-mod-element/HTMLModElement.js';
import HTMLOListElement from '../nodes/html-o-list-element/HTMLOListElement.js';
import HTMLObjectElement from '../nodes/html-object-element/HTMLObjectElement.js';
import HTMLOptGroupElement from '../nodes/html-opt-group-element/HTMLOptGroupElement.js';
import HTMLOptionElement from '../nodes/html-option-element/HTMLOptionElement.js';
import HTMLOutputElement from '../nodes/html-output-element/HTMLOutputElement.js';
import HTMLParagraphElement from '../nodes/html-paragraph-element/HTMLParagraphElement.js';
import HTMLParamElement from '../nodes/html-param-element/HTMLParamElement.js';
import HTMLPictureElement from '../nodes/html-picture-element/HTMLPictureElement.js';
import HTMLPreElement from '../nodes/html-pre-element/HTMLPreElement.js';
import HTMLProgressElement from '../nodes/html-progress-element/HTMLProgressElement.js';
import HTMLQuoteElement from '../nodes/html-quote-element/HTMLQuoteElement.js';
import HTMLScriptElement from '../nodes/html-script-element/HTMLScriptElement.js';
import HTMLSelectElement from '../nodes/html-select-element/HTMLSelectElement.js';
import HTMLSlotElement from '../nodes/html-slot-element/HTMLSlotElement.js';
import HTMLSourceElement from '../nodes/html-source-element/HTMLSourceElement.js';
import HTMLSpanElement from '../nodes/html-span-element/HTMLSpanElement.js';
import HTMLStyleElement from '../nodes/html-style-element/HTMLStyleElement.js';
import HTMLTableCaptionElement from '../nodes/html-table-caption-element/HTMLTableCaptionElement.js';
import HTMLTableCellElement from '../nodes/html-table-cell-element/HTMLTableCellElement.js';
import HTMLTableColElement from '../nodes/html-table-col-element/HTMLTableColElement.js';
import HTMLTableElement from '../nodes/html-table-element/HTMLTableElement.js';
import HTMLTableRowElement from '../nodes/html-table-row-element/HTMLTableRowElement.js';
import HTMLTableSectionElement from '../nodes/html-table-section-element/HTMLTableSectionElement.js';
import HTMLTemplateElement from '../nodes/html-template-element/HTMLTemplateElement.js';
import HTMLTextAreaElement from '../nodes/html-text-area-element/HTMLTextAreaElement.js';
import HTMLTimeElement from '../nodes/html-time-element/HTMLTimeElement.js';
import HTMLTitleElement from '../nodes/html-title-element/HTMLTitleElement.js';
import HTMLTrackElement from '../nodes/html-track-element/HTMLTrackElement.js';
import HTMLUListElement from '../nodes/html-u-list-element/HTMLUListElement.js';
import HTMLUnknownElement from '../nodes/html-unknown-element/HTMLUnknownElement.js';
import HTMLVideoElement from '../nodes/html-video-element/HTMLVideoElement.js';
import Node from '../nodes/node/Node.js';
import NodeList from '../nodes/node/NodeList.js';
import ProcessingInstruction from '../nodes/processing-instruction/ProcessingInstruction.js';
import ShadowRoot from '../nodes/shadow-root/ShadowRoot.js';
import SVGElement from '../nodes/svg-element/SVGElement.js';
import Text from '../nodes/text/Text.js';
import XMLDocument from '../nodes/xml-document/XMLDocument.js';
import PermissionStatus from '../permissions/PermissionStatus.js';
import Permissions from '../permissions/Permissions.js';
import Range from '../range/Range.js';
import ResizeObserver from '../resize-observer/ResizeObserver.js';
import Screen from '../screen/Screen.js';
import Selection from '../selection/Selection.js';
import Storage from '../storage/Storage.js';
import NodeFilter from '../tree-walker/NodeFilter.js';
import NodeIterator from '../tree-walker/NodeIterator.js';
import TreeWalker from '../tree-walker/TreeWalker.js';
import URL from '../url/URL.js';
import ValidityState from '../validity-state/ValidityState.js';
import XMLHttpRequest from '../xml-http-request/XMLHttpRequest.js';
import XMLHttpRequestEventTarget from '../xml-http-request/XMLHttpRequestEventTarget.js';
import XMLHttpRequestUpload from '../xml-http-request/XMLHttpRequestUpload.js';
import XMLSerializer from '../xml-serializer/XMLSerializer.js';
import CrossOriginBrowserWindow from './CrossOriginBrowserWindow.js';
import INodeJSGlobal from './INodeJSGlobal.js';
import VMGlobalPropertyScript from './VMGlobalPropertyScript.js';
import WindowErrorUtility from './WindowErrorUtility.js';
import WindowPageOpenUtility from './WindowPageOpenUtility.js';
import {
PerformanceObserver,
PerformanceEntry,
PerformanceObserverEntryList as IPerformanceObserverEntryList
} from 'node:perf_hooks';
import EventPhaseEnum from '../event/EventPhaseEnum.js';
import HTMLOptionsCollection from '../nodes/html-select-element/HTMLOptionsCollection.js';
import WindowContextClassExtender from './WindowContextClassExtender.js';
import WindowBrowserContext from './WindowBrowserContext.js';
import CanvasCaptureMediaStreamTrack from '../nodes/html-canvas-element/CanvasCaptureMediaStreamTrack.js';
import SVGSVGElement from '../nodes/svg-svg-element/SVGSVGElement.js';
import SVGGraphicsElement from '../nodes/svg-graphics-element/SVGGraphicsElement.js';
import SVGAnimateElement from '../nodes/svg-animate-element/SVGAnimateElement.js';
import SVGAnimateMotionElement from '../nodes/svg-animate-motion-element/SVGAnimateMotionElement.js';
import SVGAnimateTransformElement from '../nodes/svg-animate-transform-element/SVGAnimateTransformElement.js';
import SVGCircleElement from '../nodes/svg-circle-element/SVGCircleElement.js';
import SVGClipPathElement from '../nodes/svg-clip-path-element/SVGClipPathElement.js';
import SVGDefsElement from '../nodes/svg-defs-element/SVGDefsElement.js';
import SVGDescElement from '../nodes/svg-desc-element/SVGDescElement.js';
import SVGEllipseElement from '../nodes/svg-ellipse-element/SVGEllipseElement.js';
import SVGFEBlendElement from '../nodes/svg-fe-blend-element/SVGFEBlendElement.js';
import SVGFEColorMatrixElement from '../nodes/svg-fe-color-matrix-element/SVGFEColorMatrixElement.js';
import SVGFEComponentTransferElement from '../nodes/svg-fe-component-transfer-element/SVGFEComponentTransferElement.js';
import SVGFECompositeElement from '../nodes/svg-fe-composite-element/SVGFECompositeElement.js';
import SVGFEConvolveMatrixElement from '../nodes/svg-fe-convolve-matrix-element/SVGFEConvolveMatrixElement.js';
import SVGFEDiffuseLightingElement from '../nodes/svg-fe-diffuse-lighting-element/SVGFEDiffuseLightingElement.js';
import SVGFEDisplacementMapElement from '../nodes/svg-fe-displacement-map-element/SVGFEDisplacementMapElement.js';
import SVGFEDistantLightElement from '../nodes/svg-fe-distant-light-element/SVGFEDistantLightElement.js';
import SVGFEDropShadowElement from '../nodes/svg-fe-drop-shadow-element/SVGFEDropShadowElement.js';
import SVGFEFloodElement from '../nodes/svg-fe-flood-element/SVGFEFloodElement.js';
import SVGFEFuncAElement from '../nodes/svg-fe-func-a-element/SVGFEFuncAElement.js';
import SVGFEFuncBElement from '../nodes/svg-fe-func-b-element/SVGFEFuncBElement.js';
import SVGFEFuncGElement from '../nodes/svg-fe-func-g-element/SVGFEFuncGElement.js';
import SVGFEFuncRElement from '../nodes/svg-fe-func-r-element/SVGFEFuncRElement.js';
import SVGFEGaussianBlurElement from '../nodes/svg-fe-gaussian-blur-element/SVGFEGaussianBlurElement.js';
import SVGFEImageElement from '../nodes/svg-fe-image-element/SVGFEImageElement.js';
import SVGFEMergeElement from '../nodes/svg-fe-merge-element/SVGFEMergeElement.js';
import SVGFEMergeNodeElement from '../nodes/svg-fe-merge-node-element/SVGFEMergeNodeElement.js';
import SVGFEMorphologyElement from '../nodes/svg-fe-morphology-element/SVGFEMorphologyElement.js';
import SVGFEOffsetElement from '../nodes/svg-fe-offset-element/SVGFEOffsetElement.js';
import SVGFEPointLightElement from '../nodes/svg-fe-point-light-element/SVGFEPointLightElement.js';
import SVGFESpecularLightingElement from '../nodes/svg-fe-specular-lighting-element/SVGFESpecularLightingElement.js';
import SVGFESpotLightElement from '../nodes/svg-fe-spot-light-element/SVGFESpotLightElement.js';
import SVGFETileElement from '../nodes/svg-fe-tile-element/SVGFETileElement.js';
import SVGFETurbulenceElement from '../nodes/svg-fe-turbulence-element/SVGFETurbulenceElement.js';
import SVGFilterElement from '../nodes/svg-filter-element/SVGFilterElement.js';
import SVGForeignObjectElement from '../nodes/svg-foreign-object-element/SVGForeignObjectElement.js';
import SVGGElement from '../nodes/svg-g-element/SVGGElement.js';
import SVGImageElement from '../nodes/svg-image-element/SVGImageElement.js';
import SVGLineElement from '../nodes/svg-line-element/SVGLineElement.js';
import SVGLinearGradientElement from '../nodes/svg-linear-gradient-element/SVGLinearGradientElement.js';
import SVGMarkerElement from '../nodes/svg-marker-element/SVGMarkerElement.js';
import SVGMaskElement from '../nodes/svg-mask-element/SVGMaskElement.js';
import SVGMetadataElement from '../nodes/svg-metadata-element/SVGMetadataElement.js';
import SVGMPathElement from '../nodes/svg-m-path-element/SVGMPathElement.js';
import SVGPathElement from '../nodes/svg-path-element/SVGPathElement.js';
import SVGPatternElement from '../nodes/svg-pattern-element/SVGPatternElement.js';
import SVGPolygonElement from '../nodes/svg-polygon-element/SVGPolygonElement.js';
import SVGPolylineElement from '../nodes/svg-polyline-element/SVGPolylineElement.js';
import SVGRadialGradientElement from '../nodes/svg-radial-gradient-element/SVGRadialGradientElement.js';
import SVGRectElement from '../nodes/svg-rect-element/SVGRectElement.js';
import SVGScriptElement from '../nodes/svg-script-element/SVGScriptElement.js';
import SVGSetElement from '../nodes/svg-set-element/SVGSetElement.js';
import SVGStopElement from '../nodes/svg-stop-element/SVGStopElement.js';
import SVGStyleElement from '../nodes/svg-style-element/SVGStyleElement.js';
import SVGSwitchElement from '../nodes/svg-switch-element/SVGSwitchElement.js';
import SVGSymbolElement from '../nodes/svg-symbol-element/SVGSymbolElement.js';
import SVGTextElement from '../nodes/svg-text-element/SVGTextElement.js';
import SVGTextPathElement from '../nodes/svg-text-path-element/SVGTextPathElement.js';
import SVGTitleElement from '../nodes/svg-title-element/SVGTitleElement.js';
import SVGTSpanElement from '../nodes/svg-t-span-element/SVGTSpanElement.js';
import SVGUseElement from '../nodes/svg-use-element/SVGUseElement.js';
import SVGViewElement from '../nodes/svg-view-element/SVGViewElement.js';
import SVGAnimationElement from '../nodes/svg-animation-element/SVGAnimationElement.js';
import SVGComponentTransferFunctionElement from '../nodes/svg-component-transfer-function-element/SVGComponentTransferFunctionElement.js';
import SVGGeometryElement from '../nodes/svg-geometry-element/SVGGeometryElement.js';
import SVGGradientElement from '../nodes/svg-gradient-element/SVGGradientElement.js';
import SVGTextPositioningElement from '../nodes/svg-text-positioning-element/SVGTextPositioningElement.js';
import DOMMatrixReadOnly from '../dom/dom-matrix/DOMMatrixReadOnly.js';
import DOMMatrix from '../dom/dom-matrix/DOMMatrix.js';
import SVGAngle from '../svg/SVGAngle.js';
import SVGAnimatedAngle from '../svg/SVGAnimatedAngle.js';
import SVGAnimatedBoolean from '../svg/SVGAnimatedBoolean.js';
import SVGAnimatedEnumeration from '../svg/SVGAnimatedEnumeration.js';
import SVGAnimatedInteger from '../svg/SVGAnimatedInteger.js';
import SVGAnimatedLength from '../svg/SVGAnimatedLength.js';
import SVGLength from '../svg/SVGLength.js';
import SVGAnimatedNumber from '../svg/SVGAnimatedNumber.js';
import SVGAnimatedNumberList from '../svg/SVGAnimatedNumberList.js';
import SVGAnimatedPreserveAspectRatio from '../svg/SVGAnimatedPreserveAspectRatio.js';
import SVGAnimatedRect from '../svg/SVGAnimatedRect.js';
import SVGAnimatedString from '../svg/SVGAnimatedString.js';
import SVGAnimatedTransformList from '../svg/SVGAnimatedTransformList.js';
import SVGLengthList from '../svg/SVGLengthList.js';
import SVGMatrix from '../svg/SVGMatrix.js';
import SVGNumber from '../svg/SVGNumber.js';
import SVGNumberList from '../svg/SVGNumberList.js';
import SVGPoint from '../svg/SVGPoint.js';
import SVGPointList from '../svg/SVGPointList.js';
import SVGPreserveAspectRatio from '../svg/SVGPreserveAspectRatio.js';
import SVGRect from '../svg/SVGRect.js';
import SVGStringList from '../svg/SVGStringList.js';
import SVGTransform from '../svg/SVGTransform.js';
import SVGTransformList from '../svg/SVGTransformList.js';
import SVGUnitTypes from '../svg/SVGUnitTypes.js';
import DOMPoint from '../dom/DOMPoint.js';
import SVGAnimatedLengthList from '../svg/SVGAnimatedLengthList.js';
import CustomElementReactionStack from '../custom-element/CustomElementReactionStack.js';
import IScrollToOptions from './IScrollToOptions.js';
const TIMER = {
setTimeout: globalThis.setTimeout.bind(globalThis),
clearTimeout: globalThis.clearTimeout.bind(globalThis),
setInterval: globalThis.setInterval.bind(globalThis),
clearInterval: globalThis.clearInterval.bind(globalThis),
queueMicrotask: globalThis.queueMicrotask.bind(globalThis),
setImmediate: globalThis.setImmediate.bind(globalThis),
clearImmediate: globalThis.clearImmediate.bind(globalThis)
};
const IS_NODE_JS_TIMEOUT_ENVIRONMENT = setTimeout.toString().includes('new Timeout');
/**
* Class for PerformanceObserverEntryList as it is only available as an interface from Node.js.
*/
class PerformanceObserverEntryList {
/**
* Constructor.
*/
constructor() {
throw new TypeError('Illegal constructor');
}
}
/**
* Zero Timeout.
*/
class Timeout {
public callback: () => void;
/**
* Constructor.
* @param callback Callback.
*/
constructor(callback: () => void) {
this.callback = callback;
}
}
/**
* Browser window.
*
* Reference:
* https://developer.mozilla.org/en-US/docs/Web/API/Window.
*/
export default class BrowserWindow extends EventTarget implements INodeJSGlobal {
// Nodes
public readonly Node = Node;
public readonly Attr = Attr;
public readonly ShadowRoot = ShadowRoot;
public readonly ProcessingInstruction = ProcessingInstruction;
public readonly Element = Element;
public readonly CharacterData = CharacterData;
public readonly DocumentType = DocumentType;
// Nodes that can be created using "new" keyword (populated by WindowContextClassExtender)
public declare readonly Document: typeof Document;
public declare readonly HTMLDocument: typeof HTMLDocument;
public declare readonly XMLDocument: typeof XMLDocument;
public declare readonly DocumentFragment: typeof DocumentFragment;
public declare readonly Text: typeof Text;
public declare readonly Comment: typeof Comment;
public declare readonly Image: typeof Image;
public declare readonly Audio: typeof Audio;
// HTML Element classes
public readonly HTMLAnchorElement = HTMLAnchorElement;
public readonly HTMLButtonElement = HTMLButtonElement;
public readonly HTMLOptGroupElement = HTMLOptGroupElement;
public readonly HTMLOptionElement = HTMLOptionElement;
public readonly HTMLElement = HTMLElement;
public readonly HTMLUnknownElement = HTMLUnknownElement;
public readonly HTMLTemplateElement = HTMLTemplateElement;
public readonly HTMLInputElement = HTMLInputElement;
public readonly HTMLSelectElement = HTMLSelectElement;
public readonly HTMLTextAreaElement = HTMLTextAreaElement;
public readonly HTMLImageElement = HTMLImageElement;
public readonly HTMLStyleElement = HTMLStyleElement;
public readonly HTMLLabelElement = HTMLLabelElement;
public readonly HTMLSlotElement = HTMLSlotElement;
public readonly HTMLMetaElement = HTMLMetaElement;
public readonly HTMLMediaElement = HTMLMediaElement;
public readonly HTMLAudioElement = HTMLAudioElement;
public readonly HTMLVideoElement = HTMLVideoElement;
public readonly HTMLBaseElement = HTMLBaseElement;
public readonly HTMLDialogElement = HTMLDialogElement;
public readonly HTMLScriptElement = HTMLScriptElement;
public readonly HTMLLinkElement = HTMLLinkElement;
public readonly HTMLIFrameElement = HTMLIFrameElement;
public readonly HTMLFormElement = HTMLFormElement;
public readonly HTMLUListElement = HTMLUListElement;
public readonly HTMLTrackElement = HTMLTrackElement;
public readonly HTMLTableRowElement = HTMLTableRowElement;
public readonly HTMLTitleElement = HTMLTitleElement;
public readonly HTMLTimeElement = HTMLTimeElement;
public readonly HTMLTableSectionElement = HTMLTableSectionElement;
public readonly HTMLTableCellElement = HTMLTableCellElement;
public readonly HTMLTableElement = HTMLTableElement;
public readonly HTMLSpanElement = HTMLSpanElement;
public readonly HTMLSourceElement = HTMLSourceElement;
public readonly HTMLQuoteElement = HTMLQuoteElement;
public readonly HTMLProgressElement = HTMLProgressElement;
public readonly HTMLPreElement = HTMLPreElement;
public readonly HTMLPictureElement = HTMLPictureElement;
public readonly HTMLParamElement = HTMLParamElement;
public readonly HTMLParagraphElement = HTMLParagraphElement;
public readonly HTMLOutputElement = HTMLOutputElement;
public readonly HTMLOListElement = HTMLOListElement;
public readonly HTMLObjectElement = HTMLObjectElement;
public readonly HTMLMeterElement = HTMLMeterElement;
public readonly HTMLMenuElement = HTMLMenuElement;
public readonly HTMLMapElement = HTMLMapElement;
public readonly HTMLLIElement = HTMLLIElement;
public readonly HTMLLegendElement = HTMLLegendElement;
public readonly HTMLModElement = HTMLModElement;
public readonly HTMLHtmlElement = HTMLHtmlElement;
public readonly HTMLHRElement = HTMLHRElement;
public readonly HTMLHeadElement = HTMLHeadElement;
public readonly HTMLHeadingElement = HTMLHeadingElement;
public readonly HTMLFieldSetElement = HTMLFieldSetElement;
public readonly HTMLEmbedElement = HTMLEmbedElement;
public readonly HTMLDListElement = HTMLDListElement;
public readonly HTMLDivElement = HTMLDivElement;
public readonly HTMLDetailsElement = HTMLDetailsElement;
public readonly HTMLDataListElement = HTMLDataListElement;
public readonly HTMLDataElement = HTMLDataElement;
public readonly HTMLTableColElement = HTMLTableColElement;
public readonly HTMLTableCaptionElement = HTMLTableCaptionElement;
public readonly HTMLCanvasElement = HTMLCanvasElement;
public readonly HTMLBRElement = HTMLBRElement;
public readonly HTMLBodyElement = HTMLBodyElement;
public readonly HTMLAreaElement = HTMLAreaElement;
// SVG Element classes
public readonly SVGSVGElement = SVGSVGElement;
public readonly SVGAnimateElement = SVGAnimateElement;
public readonly SVGAnimateMotionElement = SVGAnimateMotionElement;
public readonly SVGAnimateTransformElement = SVGAnimateTransformElement;
public readonly SVGCircleElement = SVGCircleElement;
public readonly SVGClipPathElement = SVGClipPathElement;
public readonly SVGDefsElement = SVGDefsElement;
public readonly SVGDescElement = SVGDescElement;
public readonly SVGEllipseElement = SVGEllipseElement;
public readonly SVGFEBlendElement = SVGFEBlendElement;
public readonly SVGFEColorMatrixElement = SVGFEColorMatrixElement;
public readonly SVGFEComponentTransferElement = SVGFEComponentTransferElement;
public readonly SVGFECompositeElement = SVGFECompositeElement;
public readonly SVGFEConvolveMatrixElement = SVGFEConvolveMatrixElement;
public readonly SVGFEDiffuseLightingElement = SVGFEDiffuseLightingElement;
public readonly SVGFEDisplacementMapElement = SVGFEDisplacementMapElement;
public readonly SVGFEDistantLightElement = SVGFEDistantLightElement;
public readonly SVGFEDropShadowElement = SVGFEDropShadowElement;
public readonly SVGFEFloodElement = SVGFEFloodElement;
public readonly SVGFEFuncAElement = SVGFEFuncAElement;
public readonly SVGFEFuncBElement = SVGFEFuncBElement;
public readonly SVGFEFuncGElement = SVGFEFuncGElement;
public readonly SVGFEFuncRElement = SVGFEFuncRElement;
public readonly SVGFEGaussianBlurElement = SVGFEGaussianBlurElement;
public readonly SVGFEImageElement = SVGFEImageElement;
public readonly SVGFEMergeElement = SVGFEMergeElement;
public readonly SVGFEMergeNodeElement = SVGFEMergeNodeElement;
public readonly SVGFEMorphologyElement = SVGFEMorphologyElement;
public readonly SVGFEOffsetElement = SVGFEOffsetElement;
public readonly SVGFEPointLightElement = SVGFEPointLightElement;
public readonly SVGFESpecularLightingElement = SVGFESpecularLightingElement;
public readonly SVGFESpotLightElement = SVGFESpotLightElement;
public readonly SVGFETileElement = SVGFETileElement;
public readonly SVGFETurbulenceElement = SVGFETurbulenceElement;
public readonly SVGFilterElement = SVGFilterElement;
public readonly SVGForeignObjectElement = SVGForeignObjectElement;
public readonly SVGGElement = SVGGElement;
public readonly SVGImageElement = SVGImageElement;
public readonly SVGLineElement = SVGLineElement;
public readonly SVGLinearGradientElement = SVGLinearGradientElement;
public readonly SVGMarkerElement = SVGMarkerElement;
public readonly SVGMaskElement = SVGMaskElement;
public readonly SVGMetadataElement = SVGMetadataElement;
public readonly SVGMPathElement = SVGMPathElement;
public readonly SVGPathElement = SVGPathElement;
public readonly SVGPatternElement = SVGPatternElement;
public readonly SVGPolygonElement = SVGPolygonElement;
public readonly SVGPolylineElement = SVGPolylineElement;
public readonly SVGRadialGradientElement = SVGRadialGradientElement;
public readonly SVGRectElement = SVGRectElement;
public readonly SVGScriptElement = SVGScriptElement;
public readonly SVGSetElement = SVGSetElement;
public readonly SVGStopElement = SVGStopElement;
public readonly SVGStyleElement = SVGStyleElement;
public readonly SVGSwitchElement = SVGSwitchElement;
public readonly SVGSymbolElement = SVGSymbolElement;
public readonly SVGTextElement = SVGTextElement;
public readonly SVGTextPathElement = SVGTextPathElement;
public readonly SVGTitleElement = SVGTitleElement;
public readonly SVGTSpanElement = SVGTSpanElement;
public readonly SVGUseElement = SVGUseElement;
public readonly SVGViewElement = SVGViewElement;
// Abstract SVG Element classes
public readonly SVGElement = SVGElement;
public readonly SVGAnimationElement = SVGAnimationElement;
public readonly SVGComponentTransferFunctionElement = SVGComponentTransferFunctionElement;
public readonly SVGGeometryElement = SVGGeometryElement;
public readonly SVGGradientElement = SVGGradientElement;
public readonly SVGTextPositioningElement = SVGTextPositioningElement;
public readonly SVGGraphicsElement = SVGGraphicsElement;
// Event classes
public readonly Event = Event;
public readonly UIEvent = UIEvent;
public readonly CustomEvent = CustomEvent;
public readonly AnimationEvent = AnimationEvent;
public readonly KeyboardEvent = KeyboardEvent;
public readonly MessageEvent = MessageEvent;
public readonly MouseEvent = MouseEvent;
public readonly PointerEvent = PointerEvent;
public readonly FocusEvent = FocusEvent;
public readonly WheelEvent = WheelEvent;
public readonly InputEvent = InputEvent;
public readonly ErrorEvent = ErrorEvent;
public readonly StorageEvent = StorageEvent;
public readonly SubmitEvent = SubmitEvent;
public readonly ProgressEvent = ProgressEvent;
public readonly MediaQueryListEvent = MediaQueryListEvent;
public readonly HashChangeEvent = HashChangeEvent;
public readonly ClipboardEvent = ClipboardEvent;
public readonly TouchEvent = TouchEvent;
public readonly Touch = Touch;
// Non-implemented event classes
public readonly AudioProcessingEvent = Event;
public readonly BeforeInputEvent = Event;
public readonly BeforeUnloadEvent = Event;
public readonly BlobEvent = Event;
public readonly CloseEvent = Event;
public readonly CompositionEvent = Event;
public readonly CSSFontFaceLoadEvent = Event;
public readonly DeviceLightEvent = Event;
public readonly DeviceMotionEvent = Event;
public readonly DeviceOrientationEvent = Event;
public readonly DeviceProximityEvent = Event;
public readonly DOMTransactionEvent = Event;
public readonly DragEvent = Event;
public readonly EditingBeforeInputEvent = Event;
public readonly FetchEvent = Event;
public readonly GamepadEvent = Event;
public readonly IDBVersionChangeEvent = Event;
public readonly MediaStreamEvent = Event;
public readonly MutationEvent = Event;
public readonly OfflineAudioCompletionEvent = Event;
public readonly OverconstrainedError = Event;
public readonly PageTransitionEvent = Event;
public readonly PaymentRequestUpdateEvent = Event;
public readonly PopStateEvent = Event;
public readonly RelatedEvent = Event;
public readonly RTCDataChannelEvent = Event;
public readonly RTCIdentityErrorEvent = Event;
public readonly RTCIdentityEvent = Event;
public readonly RTCPeerConnectionIceEvent = Event;
public readonly SensorEvent = Event;
public readonly SVGEvent = Event;
public readonly SVGZoomEvent = Event;
public readonly TimeEvent = Event;
public readonly TrackEvent = Event;
public readonly TransitionEvent = Event;
public readonly UserProximityEvent = Event;
public readonly WebGLContextEvent = Event;
public readonly TextEvent = Event;
// Other classes that has to be bound to the Window context (populated by WindowContextClassExtender)
public declare readonly NodeIterator: typeof NodeIterator;
public declare readonly TreeWalker: typeof TreeWalker;
public declare readonly MutationObserver: typeof MutationObserver;
public declare readonly MessagePort: typeof MessagePort;
public declare readonly DataTransfer: typeof DataTransfer;
public declare readonly DataTransferItem: typeof DataTransferItem;
public declare readonly DataTransferItemList: typeof DataTransferItemList;
public declare readonly XMLSerializer: typeof XMLSerializer;
public declare readonly CSSStyleSheet: typeof CSSStyleSheet;
public declare readonly DOMException: typeof DOMException;
public declare readonly CSSUnitValue: typeof CSSUnitValue;
public declare readonly Selection: typeof Selection;
public declare readonly Headers: typeof Headers;
public declare readonly Request: typeof Request;
public declare readonly Response: typeof Response;
public declare readonly EventTarget: typeof EventTarget;
public declare readonly XMLHttpRequestUpload: typeof XMLHttpRequestUpload;
public declare readonly XMLHttpRequestEventTarget: typeof XMLHttpRequestEventTarget;
public declare readonly AbortController: typeof AbortController;
public declare readonly AbortSignal: typeof AbortSignal;
public declare readonly FormData: typeof FormData;
public declare readonly PermissionStatus: typeof PermissionStatus;
public declare readonly ClipboardItem: typeof ClipboardItem;
public declare readonly XMLHttpRequest: typeof XMLHttpRequest;
public declare readonly DOMParser: typeof DOMParser;
public declare readonly Range: typeof Range;
public declare readonly VTTCue: typeof VTTCue;
public declare readonly FileReader: typeof FileReader;
public declare readonly MediaStream: typeof MediaStream;
public declare readonly MediaStreamTrack: typeof MediaStreamTrack;
public declare readonly CanvasCaptureMediaStreamTrack: typeof CanvasCaptureMediaStreamTrack;
public declare readonly NamedNodeMap: typeof NamedNodeMap;
public declare readonly TextTrack: typeof TextTrack;
public declare readonly TextTrackList: typeof TextTrackList;
public declare readonly TextTrackCue: typeof TextTrackCue;
public declare readonly RemotePlayback: typeof RemotePlayback;
// Other classes that don't have to be bound to the Window context
public readonly Permissions = Permissions;
public readonly History = History;
public readonly Navigator = Navigator;
public readonly Clipboard = Clipboard;
public readonly TimeRanges = TimeRanges;
public readonly TextTrackCueList = TextTrackCueList;
public readonly ValidityState = ValidityState;
public readonly MutationRecord = MutationRecord;
public readonly IntersectionObserver = IntersectionObserver;
public readonly IntersectionObserverEntry = IntersectionObserverEntry;
public readonly CSSStyleDeclaration = CSSStyleDeclaration;
public readonly CSSRule = CSSRule;
public readonly CSSContainerRule = CSSContainerRule;
public readonly CSSFontFaceRule = CSSFontFaceRule;
public readonly CSSKeyframeRule = CSSKeyframeRule;
public readonly CSSKeyframesRule = CSSKeyframesRule;
public readonly CSSMediaRule = CSSMediaRule;
public readonly CSSStyleRule = CSSStyleRule;
public readonly CSSSupportsRule = CSSSupportsRule;
public readonly DOMRect = DOMRect;
public readonly DOMRectReadOnly = DOMRectReadOnly;
public readonly Plugin = Plugin;
public readonly PluginArray = PluginArray;
public readonly Location = Location;
public readonly CustomElementRegistry = CustomElementRegistry;
public readonly ResizeObserver = ResizeObserver;
public readonly URL = URL;
public readonly Blob = Blob;
public readonly File = File;
public readonly Storage = Storage;
public readonly MimeType = MimeType;
public readonly MimeTypeArray = MimeTypeArray;
public readonly NodeFilter = NodeFilter;
public readonly HTMLCollection = HTMLCollection;
public readonly HTMLFormControlCollection = HTMLFormControlsCollection;
public readonly HTMLOptionsCollection = HTMLOptionsCollection;
public readonly NodeList = NodeList;
public readonly RadioNodeList = RadioNodeList;
public readonly FileList = FileList;
public readonly Screen = Screen;
public readonly DOMMatrixReadOnly = DOMMatrixReadOnly;
public readonly DOMMatrix = DOMMatrix;
public readonly SVGAngle = SVGAngle;
public readonly SVGAnimatedAngle = SVGAnimatedAngle;
public readonly SVGAnimatedBoolean = SVGAnimatedBoolean;
public readonly SVGAnimatedEnumeration = SVGAnimatedEnumeration;
public readonly SVGAnimatedInteger = SVGAnimatedInteger;
public readonly SVGAnimatedLength = SVGAnimatedLength;
public readonly SVGAnimatedNumber = SVGAnimatedNumber;
public readonly SVGAnimatedNumberList = SVGAnimatedNumberList;
public readonly SVGAnimatedPreserveAspectRatio = SVGAnimatedPreserveAspectRatio;
public readonly SVGAnimatedRect = SVGAnimatedRect;
public readonly SVGAnimatedString = SVGAnimatedString;
public readonly SVGAnimatedTransformList = SVGAnimatedTransformList;
public readonly SVGLength = SVGLength;
public readonly SVGLengthList = SVGLengthList;
public readonly SVGMatrix = SVGMatrix;
public readonly SVGNumber = SVGNumber;
public readonly SVGNumberList = SVGNumberList;
public readonly SVGPoint = SVGPoint;
public readonly SVGPointList = SVGPointList;
public readonly SVGPreserveAspectRatio = SVGPreserveAspectRatio;
public readonly SVGRect = SVGRect;
public readonly SVGStringList = SVGStringList;
public readonly SVGTransform = SVGTransform;
public readonly SVGTransformList = SVGTransformList;
public readonly SVGAnimatedLengthList = SVGAnimatedLengthList;
public readonly SVGUnitTypes = SVGUnitTypes;
public readonly DOMPoint = DOMPoint;
public readonly Window = <typeof BrowserWindow>this.constructor;
// Node.js Classes
public readonly URLSearchParams = URLSearchParams;
public readonly WritableStream = Stream.Writable;
public readonly ReadableStream = ReadableStream;
public readonly TransformStream = Stream.Transform;
public readonly PerformanceObserver = PerformanceObserver;
public readonly PerformanceEntry = PerformanceEntry;
public readonly PerformanceObserverEntryList: new () => IPerformanceObserverEntryList = <
new () => IPerformanceObserverEntryList
>PerformanceObserverEntryList;
// Events
public onload: ((event: Event) => void) | null = null;
public onerror: ((event: ErrorEvent) => void) | null = null;
// Public properties.
public readonly document: Document;
public readonly customElements: CustomElementRegistry = new CustomElementRegistry(this);
public readonly window: BrowserWindow = this;
public readonly globalThis: BrowserWindow = this;
public readonly performance: typeof performance = performance;
public readonly screenLeft: number = 0;
public readonly screenTop: number = 0;
public readonly screenX: number = 0;
public readonly screenY: number = 0;
public readonly crypto: typeof webcrypto = webcrypto;
public readonly TextEncoder: typeof TextEncoder = TextEncoder;
public readonly TextDecoder: typeof TextDecoder = TextDecoder;
public readonly closed = false;
public console: Console;
public name = '';
// Node.js Globals (populated by VMGlobalPropertyScript)
public declare Array: typeof Array;
public declare ArrayBuffer: typeof ArrayBuffer;
public declare Boolean: typeof Boolean;
public Buffer: typeof Buffer = Buffer;
public declare DataView: typeof DataView;
public declare Date: typeof Date;
public declare Error: typeof Error;
public declare EvalError: typeof EvalError;
public declare Float32Array: typeof Float32Array;
public declare Float64Array: typeof Float64Array;
public declare Function: typeof Function;
public declare Infinity: typeof Infinity;
public declare Int16Array: typeof Int16Array;
public declare Int32Array: typeof Int32Array;
public declare Int8Array: typeof Int8Array;
public declare Intl: typeof Intl;
public declare JSON: typeof JSON;
public declare Map: MapConstructor;
public declare Math: typeof Math;
public declare NaN: typeof NaN;
public declare Number: typeof Number;
public declare Object: typeof Object;
public declare Promise: typeof Promise;
public declare RangeError: typeof RangeError;
public declare ReferenceError: typeof ReferenceError;
public declare RegExp: typeof RegExp;
public declare Set: SetConstructor;
public declare String: typeof String;
public declare Symbol: Function;
public declare SyntaxError: typeof SyntaxError;
public declare TypeError: typeof TypeError;
public declare URIError: typeof URIError;
public declare Uint16Array: typeof Uint16Array;
public declare Uint32Array: typeof Uint32Array;
public declare Uint8Array: typeof Uint8Array;
public declare Uint8ClampedArray: typeof Uint8ClampedArray;
public declare WeakMap: WeakMapConstructor;
public declare WeakSet: WeakSetConstructor;
public declare decodeURI: typeof decodeURI;
public declare decodeURIComponent: typeof decodeURIComponent;
public declare encodeURI: typeof encodeURI;
public declare encodeURIComponent: typeof encodeURIComponent;
public declare eval: typeof eval;
/**
* @deprecated
*/
public declare escape: (str: string) => string;
public declare global: typeof globalThis;
public declare isFinite: typeof isFinite;
public declare isNaN: typeof isNaN;
public declare parseFloat: typeof parseFloat;
public declare parseInt: typeof parseInt;
public declare undefined: typeof undefined;
/**
* @deprecated
*/
public declare unescape: (str: string) => string;
public declare gc: () => void;
public declare v8debug?: unknown;
// Public internal properties
// Used for tracking capture event listeners to improve performance when they are not used.
// See EventTarget class.
public [PropertySymbol.mutationObservers]: MutationObserver[] = [];
public readonly [PropertySymbol.readyStateManager] = new DocumentReadyStateManager(this);
public [PropertySymbol.location]: Location;
public [PropertySymbol.history]: History;
public [PropertySymbol.navigator]: Navigator;
public [PropertySymbol.screen]: Screen;
public [PropertySymbol.sessionStorage]: Storage;
public [PropertySymbol.localStorage]: Storage;
public [PropertySymbol.self]: BrowserWindow = this;
public [PropertySymbol.top]: BrowserWindow = this;
public [PropertySymbol.parent]: BrowserWindow = this;
public [PropertySymbol.window]: BrowserWindow = this;
public [PropertySymbol.internalId]: number = -1;
public [PropertySymbol.customElementReactionStack] = new CustomElementReactionStack(this);
// Private properties
#browserFrame: IBrowserFrame;
#innerWidth: number | null = null;
#innerHeight: number | null = null;
#outerWidth: number | null = null;
#outerHeight: number | null = null;
#devicePixelRatio: number | null = null;
#zeroDelayTimeout: { timeouts: Array<Timeout> | null } = { timeouts: null };
#timerLoopStacks: string[] = [];
/**
* Constructor.
*
* @param browserFrame Browser frame.
* @param [options] Options.
* @param [options.url] URL.
*/
constructor(browserFrame: IBrowserFrame, options?: { url?: string }) {
super();
this.#browserFrame = browserFrame;
this.console = browserFrame.page.console;
this[PropertySymbol.navigator] = new Navigator(this);
this[PropertySymbol.screen] = new Screen();
this[PropertySymbol.sessionStorage] = new Storage();
this[PropertySymbol.localStorage] = new Storage();
this[PropertySymbol.location] = new Location(this.#browserFrame, options?.url ?? 'about:blank');
this[PropertySymbol.history] = new History(this.#browserFrame, this);
WindowBrowserContext.setWindowBrowserFrameRelation(this, this.#browserFrame);
this[PropertySymbol.setupVMContext]();
WindowContextClassExtender.extendClasses(this);
// Document
this.document = new this.HTMLDocument();
this.document[PropertySymbol.defaultView] = this;
// Ready state manager
this[PropertySymbol.readyStateManager].waitUntilComplete().then(() => {
this.document[PropertySymbol.readyState] = DocumentReadyStateEnum.complete;
this.document.dispatchEvent(new Event('readystatechange'));
// Not sure why target is set to document here, but this is how it works in the browser
const loadEvent = new Event('load');
loadEvent[PropertySymbol.currentTarget] = this.document;
loadEvent[PropertySymbol.target] = this.document;
loadEvent[PropertySymbol.eventPhase] = EventPhaseEnum.atTarget;
this.dispatchEvent(loadEvent);
loadEvent[PropertySymbol.target] = null;
loadEvent[PropertySymbol.currentTarget] = null;
loadEvent[PropertySymbol.eventPhase] = EventPhaseEnum.none;
});
this[PropertySymbol.bindMethods]();
}
/**
* Returns self.
*
* @returns Self.
*/
public get self(): BrowserWindow {
return this[PropertySymbol.self];
}
/**
* Returns self.
*
* @param self Self.
*/
public set self(self: BrowserWindow | null) {
this[PropertySymbol.self] = self;
}
/**
* Returns top.
*
* @returns Top.
*/
public get top(): BrowserWindow {
return this[PropertySymbol.top];
}
/**
* Returns parent.
*
* @returns Parent.
*/
public get parent(): BrowserWindow {
return this[PropertySymbol.parent];
}
/**
* Returns parent.
*
* @param parent Parent.
*/
public set parent(parent: BrowserWindow | null) {
this[PropertySymbol.parent] = parent;
}
/**
* Returns location.
*/
public get location(): Location {
return this[PropertySymbol.location];
}
/**
* Returns location.
*
* @param href Href.
*/
public set location(href: string) {
this[PropertySymbol.location].href = href;
}
/**
* Returns history.
*/
public get history(): History {
return this[PropertySymbol.history];
}
/**
* Returns navigator.
*/
public get navigator(): Navigator {
return this[PropertySymbol.navigator];
}
/**
* Returns screen.
*/
public get screen(): Screen {
return this[PropertySymbol.screen];
}
/**
* Returns session storage.
*/
public get sessionStorage(): Storage {
return this[PropertySymbol.sessionStorage];
}
/**
* Returns local storage.
*/
public get localStorage(): Storage {
return this[PropertySymbol.localStorage];
}
/**
* Returns opener.
*
* @returns Opener.
*/
public get opener(): BrowserWindow | CrossOriginBrowserWindow | null {
return this.#browserFrame[PropertySymbol.openerWindow];
}
/**
* The number of pixels that the document is currently scrolled horizontally.
*
* @returns Scroll X.
*/
public get scrollX(): number {
return this.document?.documentElement?.scrollLeft ?? 0;
}
/**
* The read-only Window property pageXOffset is an alias for scrollX.
*
* @returns Scroll X.
*/
public get pageXOffset(): number {
return this.scrollX;
}
/**
* The number of pixels that the document is currently scrolled vertically.
*
* @returns Scroll Y.
*/
public get scrollY(): number {
return this.document?.documentElement?.scrollTop ?? 0;
}
/**
* The read-only Window property pageYOffset is an alias for scrollY.
*
* @returns Scroll Y.
*/
public get pageYOffset(): number {
return this.scrollY;