///
///
///
///
import CustomElementRegistry from '../custom-element/CustomElementRegistry';
import Document from '../nodes/document/Document';
import HTMLDocument from '../nodes/html-document/HTMLDocument';
import XMLDocument from '../nodes/xml-document/XMLDocument';
import SVGDocument from '../nodes/svg-document/SVGDocument';
import Node from '../nodes/node/Node';
import Text from '../nodes/text/Text';
import Comment from '../nodes/comment/Comment';
import ShadowRoot from '../nodes/shadow-root/ShadowRoot';
import Element from '../nodes/element/Element';
import HTMLTemplateElement from '../nodes/html-template-element/HTMLTemplateElement';
import HTMLFormElement from '../nodes/html-form-element/HTMLFormElement';
import HTMLElement from '../nodes/html-element/HTMLElement';
import HTMLUnknownElement from '../nodes/html-unknown-element/HTMLUnknownElement';
import HTMLInputElement from '../nodes/html-input-element/HTMLInputElement';
import HTMLSelectElement from '../nodes/html-select-element/HTMLSelectElement';
import HTMLTextAreaElement from '../nodes/html-text-area-element/HTMLTextAreaElement';
import HTMLLinkElement from '../nodes/html-link-element/HTMLLinkElement';
import HTMLStyleElement from '../nodes/html-style-element/HTMLStyleElement';
import HTMLSlotElement from '../nodes/html-slot-element/HTMLSlotElement';
import HTMLLabelElement from '../nodes/html-label-element/HTMLLabelElement';
import HTMLMetaElement from '../nodes/html-meta-element/HTMLMetaElement';
import HTMLMediaElement from '../nodes/html-media-element/HTMLMediaElement';
import HTMLAudioElement from '../nodes/html-audio-element/HTMLAudioElement';
import HTMLVideoElement from '../nodes/html-video-element/HTMLVideoElement';
import HTMLBaseElement from '../nodes/html-base-element/HTMLBaseElement';
import HTMLIFrameElement from '../nodes/html-iframe-element/HTMLIFrameElement';
import HTMLDialogElement from '../nodes/html-dialog-element/HTMLDialogElement';
import SVGSVGElement from '../nodes/svg-element/SVGSVGElement';
import SVGElement from '../nodes/svg-element/SVGElement';
import SVGGraphicsElement from '../nodes/svg-element/SVGGraphicsElement';
import HTMLScriptElement from '../nodes/html-script-element/HTMLScriptElement';
import HTMLImageElement from '../nodes/html-image-element/HTMLImageElement';
import DocumentFragment from '../nodes/document-fragment/DocumentFragment';
import CharacterData from '../nodes/character-data/CharacterData';
import TreeWalker from '../tree-walker/TreeWalker';
import Event from '../event/Event';
import CustomEvent from '../event/events/CustomEvent';
import AnimationEvent from '../event/events/AnimationEvent';
import KeyboardEvent from '../event/events/KeyboardEvent';
import MessageEvent from '../event/events/MessageEvent';
import ProgressEvent from '../event/events/ProgressEvent';
import MediaQueryListEvent from '../event/events/MediaQueryListEvent';
import EventTarget from '../event/EventTarget';
import MessagePort from '../event/MessagePort';
import { URL, URLSearchParams } from 'url';
import Location from '../location/Location';
import MutationObserver from '../mutation-observer/MutationObserver';
import XMLSerializer from '../xml-serializer/XMLSerializer';
import ResizeObserver from '../resize-observer/ResizeObserver';
import Blob from '../file/Blob';
import File from '../file/File';
import DOMException from '../exception/DOMException';
import History from '../history/History';
import CSSStyleSheet from '../css/CSSStyleSheet';
import CSSStyleDeclaration from '../css/declaration/CSSStyleDeclaration';
import CSS from '../css/CSS';
import CSSUnitValue from '../css/CSSUnitValue';
import CSSRule from '../css/CSSRule';
import CSSContainerRule from '../css/rules/CSSContainerRule';
import CSSFontFaceRule from '../css/rules/CSSFontFaceRule';
import CSSKeyframeRule from '../css/rules/CSSKeyframeRule';
import CSSKeyframesRule from '../css/rules/CSSKeyframesRule';
import CSSMediaRule from '../css/rules/CSSMediaRule';
import CSSStyleRule from '../css/rules/CSSStyleRule';
import MouseEvent from '../event/events/MouseEvent';
import PointerEvent from '../event/events/PointerEvent';
import FocusEvent from '../event/events/FocusEvent';
import WheelEvent from '../event/events/WheelEvent';
import DataTransfer from '../event/DataTransfer';
import DataTransferItem from '../event/DataTransferItem';
import DataTransferItemList from '../event/DataTransferItemList';
import InputEvent from '../event/events/InputEvent';
import UIEvent from '../event/UIEvent';
import ErrorEvent from '../event/events/ErrorEvent';
import StorageEvent from '../event/events/StorageEvent';
import Screen from '../screen/Screen';
import AsyncTaskManager from '../async-task-manager/AsyncTaskManager';
import IResponse from '../fetch/IResponse';
import IResponseInit from '../fetch/IResponseInit';
import IRequest from '../fetch/IRequest';
import IRequestInit from '../fetch/IRequestInit';
import IHeaders from '../fetch/IHeaders';
import IHeadersInit from '../fetch/IHeadersInit';
import Storage from '../storage/Storage';
import IWindow from './IWindow';
import HTMLCollection from '../nodes/element/HTMLCollection';
import NodeList from '../nodes/node/NodeList';
import MediaQueryList from '../match-media/MediaQueryList';
import Selection from '../selection/Selection';
import Navigator from '../navigator/Navigator';
import MimeType from '../navigator/MimeType';
import MimeTypeArray from '../navigator/MimeTypeArray';
import Plugin from '../navigator/Plugin';
import PluginArray from '../navigator/PluginArray';
import DOMRect from '../nodes/element/DOMRect';
import * as PerfHooks from 'perf_hooks';
import XMLHttpRequestUpload from '../xml-http-request/XMLHttpRequestUpload';
import XMLHttpRequestEventTarget from '../xml-http-request/XMLHttpRequestEventTarget';
import Attr from '../nodes/attr/Attr';
import NamedNodeMap from '../named-node-map/NamedNodeMap';
import IElement from '../nodes/element/IElement';
import ProcessingInstruction from '../nodes/processing-instruction/ProcessingInstruction';
import RequestInfo from '../fetch/RequestInfo';
import FileList from '../nodes/html-input-element/FileList';
import IHappyDOMOptions from './IHappyDOMOptions';
/**
* Browser window.
*
* Reference:
* https://developer.mozilla.org/en-US/docs/Web/API/Window.
*/
export default class Window extends EventTarget implements IWindow {
readonly happyDOM: {
whenAsyncComplete: () => Promise;
cancelAsync: () => void;
asyncTaskManager: AsyncTaskManager;
setInnerWidth: (width: number) => void;
setInnerHeight: (height: number) => void;
setURL: (url: string) => void;
settings: {
disableJavaScriptEvaluation: boolean;
disableJavaScriptFileLoading: boolean;
disableCSSFileLoading: boolean;
disableIframePageLoading: boolean;
enableFileSystemHttpRequests: boolean;
};
};
readonly Node: typeof Node;
readonly HTMLElement: typeof HTMLElement;
readonly HTMLUnknownElement: typeof HTMLUnknownElement;
readonly HTMLTemplateElement: typeof HTMLTemplateElement;
readonly HTMLFormElement: typeof HTMLFormElement;
readonly HTMLInputElement: typeof HTMLInputElement;
readonly HTMLSelectElement: typeof HTMLSelectElement;
readonly HTMLTextAreaElement: typeof HTMLTextAreaElement;
readonly HTMLImageElement: typeof HTMLImageElement;
readonly HTMLScriptElement: typeof HTMLScriptElement;
readonly HTMLLinkElement: typeof HTMLLinkElement;
readonly HTMLStyleElement: typeof HTMLStyleElement;
readonly HTMLLabelElement: typeof HTMLLabelElement;
readonly HTMLSlotElement: typeof HTMLSlotElement;
readonly HTMLMetaElement: typeof HTMLMetaElement;
readonly HTMLMediaElement: typeof HTMLMediaElement;
readonly HTMLAudioElement: typeof HTMLAudioElement;
readonly HTMLVideoElement: typeof HTMLVideoElement;
readonly HTMLBaseElement: typeof HTMLBaseElement;
readonly HTMLIFrameElement: typeof HTMLIFrameElement;
readonly HTMLDialogElement: typeof HTMLDialogElement;
readonly Attr: typeof Attr;
readonly NamedNodeMap: typeof NamedNodeMap;
readonly SVGSVGElement: typeof SVGSVGElement;
readonly SVGElement: typeof SVGElement;
readonly SVGGraphicsElement: typeof SVGGraphicsElement;
readonly Text: typeof Text;
readonly Comment: typeof Comment;
readonly ShadowRoot: typeof ShadowRoot;
readonly ProcessingInstruction: typeof ProcessingInstruction;
readonly Element: typeof Element;
readonly DocumentFragment: typeof DocumentFragment;
readonly CharacterData: typeof CharacterData;
readonly NodeFilter: {
FILTER_ACCEPT: number;
FILTER_REJECT: number;
FILTER_SKIP: number;
SHOW_ALL: number;
SHOW_ELEMENT: number;
SHOW_ATTRIBUTE: number;
SHOW_TEXT: number;
SHOW_CDATA_SECTION: number;
SHOW_ENTITY_REFERENCE: number;
SHOW_ENTITY: number;
SHOW_PROCESSING_INSTRUCTION: number;
SHOW_COMMENT: number;
SHOW_DOCUMENT: number;
SHOW_DOCUMENT_TYPE: number;
SHOW_DOCUMENT_FRAGMENT: number;
SHOW_NOTATION: number;
};
readonly TreeWalker: typeof TreeWalker;
readonly MutationObserver: typeof MutationObserver;
readonly Document: typeof Document;
readonly HTMLDocument: typeof HTMLDocument;
readonly XMLDocument: typeof XMLDocument;
readonly SVGDocument: typeof SVGDocument;
readonly Event: typeof Event;
readonly UIEvent: typeof UIEvent;
readonly CustomEvent: typeof CustomEvent;
readonly AnimationEvent: typeof AnimationEvent;
readonly KeyboardEvent: typeof KeyboardEvent;
readonly MessageEvent: typeof MessageEvent;
readonly MouseEvent: typeof MouseEvent;
readonly PointerEvent: typeof PointerEvent;
readonly FocusEvent: typeof FocusEvent;
readonly WheelEvent: typeof WheelEvent;
readonly InputEvent: typeof InputEvent;
readonly ErrorEvent: typeof ErrorEvent;
readonly StorageEvent: typeof StorageEvent;
readonly ProgressEvent: typeof ProgressEvent;
readonly MediaQueryListEvent: typeof MediaQueryListEvent;
readonly EventTarget: typeof EventTarget;
readonly MessagePort: typeof MessagePort;
readonly DataTransfer: typeof DataTransfer;
readonly DataTransferItem: typeof DataTransferItem;
readonly DataTransferItemList: typeof DataTransferItemList;
readonly URL: typeof URL;
readonly Location: typeof Location;
readonly CustomElementRegistry: typeof CustomElementRegistry;
readonly Window: typeof Window;
readonly XMLSerializer: typeof XMLSerializer;
readonly ResizeObserver: typeof ResizeObserver;
readonly CSSStyleSheet: typeof CSSStyleSheet;
readonly Blob: typeof Blob;
readonly File: typeof File;
readonly DOMException: typeof DOMException;
readonly History: typeof History;
readonly Screen: typeof Screen;
readonly Storage: typeof Storage;
readonly URLSearchParams: typeof URLSearchParams;
readonly HTMLCollection: typeof HTMLCollection;
readonly NodeList: typeof NodeList;
readonly CSSUnitValue: typeof CSSUnitValue;
readonly CSSRule: typeof CSSRule;
readonly CSSContainerRule: typeof CSSContainerRule;
readonly CSSFontFaceRule: typeof CSSFontFaceRule;
readonly CSSKeyframeRule: typeof CSSKeyframeRule;
readonly CSSKeyframesRule: typeof CSSKeyframesRule;
readonly CSSMediaRule: typeof CSSMediaRule;
readonly CSSStyleRule: typeof CSSStyleRule;
readonly Selection: typeof Selection;
readonly Navigator: typeof Navigator;
readonly MimeType: typeof MimeType;
readonly MimeTypeArray: typeof MimeTypeArray;
readonly Plugin: typeof Plugin;
readonly PluginArray: typeof PluginArray;
readonly FileList: typeof FileList;
readonly Headers: {
new (init?: IHeadersInit): IHeaders;
};
readonly DOMRect: typeof DOMRect;
readonly Request: {
new (input: string | {
href: string;
} | IRequest, init?: IRequestInit): IRequest;
};
readonly Response: {
new (body?: NodeJS.ReadableStream | null, init?: IResponseInit): IResponse;
};
readonly XMLHttpRequestUpload: typeof XMLHttpRequestUpload;
readonly XMLHttpRequestEventTarget: typeof XMLHttpRequestEventTarget;
readonly XMLHttpRequest: any;
readonly DOMParser: any;
readonly Range: any;
readonly FileReader: any;
readonly Image: any;
readonly Audio: any;
onload: (event: Event) => void;
onerror: (event: ErrorEvent) => void;
readonly document: Document;
readonly customElements: CustomElementRegistry;
readonly location: Location;
readonly history: History;
readonly navigator: Navigator;
readonly console: Console;
readonly self: this;
readonly top: this;
readonly parent: this;
readonly window: this;
readonly globalThis: this;
readonly screen: Screen;
readonly devicePixelRatio = 1;
readonly sessionStorage: Storage;
readonly localStorage: Storage;
readonly performance: PerfHooks.Performance;
readonly innerWidth: number;
readonly innerHeight: number;
ArrayBuffer: any;
Boolean: any;
Buffer: typeof globalThis.Buffer;
DataView: any;
Date: any;
Error: any;
EvalError: any;
Float32Array: any;
Float64Array: any;
GLOBAL: any;
Infinity: any;
Int16Array: any;
Int32Array: any;
Int8Array: any;
Intl: any;
JSON: any;
Map: any;
Math: any;
NaN: any;
Number: any;
Promise: any;
RangeError: any;
ReferenceError: any;
RegExp: any;
Reflect: any;
Set: any;
Symbol: any;
SyntaxError: any;
String: any;
TypeError: any;
URIError: any;
Uint16Array: any;
Uint32Array: any;
Uint8Array: any;
Uint8ClampedArray: any;
WeakMap: any;
WeakSet: any;
clearImmediate: any;
decodeURI: any;
decodeURIComponent: any;
encodeURI: any;
encodeURIComponent: any;
escape: any;
global: any;
isFinite: any;
isNaN: any;
parseFloat: any;
parseInt: any;
process: any;
root: any;
setImmediate: any;
queueMicrotask: any;
undefined: any;
unescape: any;
gc: any;
v8debug: any;
AbortController: any;
AbortSignal: any;
Array: any;
Object: any;
Function: any;
private _setTimeout;
private _clearTimeout;
private _setInterval;
private _clearInterval;
/**
* Constructor.
*
* @param [options] Options.
* @param [options.innerWidth] Inner width. Defaults to "1024".
* @param [options.innerHeight] Inner height. Defaults to "768".
* @param [options.url] URL.
* @param [options.settings] Settings.
*/
constructor(options?: IHappyDOMOptions);
/**
* The number of pixels that the document is currently scrolled horizontally
*
* @returns number
*/
get scrollX(): number;
/**
* The read-only Window property pageXOffset is an alias for scrollX.
*
* @returns number
*/
get pageXOffset(): number;
/**
* The number of pixels that the document is currently scrolled vertically
*
* @returns number
*/
get scrollY(): number;
/**
* The read-only Window property pageYOffset is an alias for scrollY.
*
* @returns number
*/
get pageYOffset(): number;
/**
* The CSS interface holds useful CSS-related methods.
*
* @returns CSS interface.
*/
get CSS(): CSS;
/**
* Evaluates code.
*
* @override
* @param code Code.
* @returns Result.
*/
eval(code: string): unknown;
/**
* Returns an object containing the values of all CSS properties of an element.
*
* @param element Element.
* @returns CSS style declaration.
*/
getComputedStyle(element: IElement): CSSStyleDeclaration;
/**
* Returns selection.
*
* @returns Selection.
*/
getSelection(): Selection;
/**
* Scrolls to a particular set of coordinates.
*
* @param x X position or options object.
* @param y Y position.
*/
scroll(x: {
top?: number;
left?: number;
behavior?: string;
} | number, y?: number): void;
/**
* Scrolls to a particular set of coordinates.
*
* @param x X position or options object.
* @param y Y position.
*/
scrollTo(x: {
top?: number;
left?: number;
behavior?: string;
} | number, y?: number): void;
/**
* Returns a new MediaQueryList object that can then be used to determine if the document matches the media query string.
*
* @param mediaQueryString A string specifying the media query to parse into a MediaQueryList.
* @returns A new MediaQueryList.
*/
matchMedia(mediaQueryString: string): MediaQueryList;
/**
* Sets a timer which executes a function once the timer expires.
*
* @override
* @param callback Function to be executed.
* @param [delay=0] Delay in ms.
* @param args Arguments passed to the callback function.
* @returns Timeout ID.
*/
setTimeout(callback: Function, delay?: number, ...args: unknown[]): NodeJS.Timeout;
/**
* Cancels a timeout previously established by calling setTimeout().
*
* @override
* @param id ID of the timeout.
*/
clearTimeout(id: NodeJS.Timeout): void;
/**
* Calls a function with a fixed time delay between each call.
*
* @override
* @param callback Function to be executed.
* @param [delay=0] Delay in ms.
* @param args Arguments passed to the callback function.
* @returns Interval ID.
*/
setInterval(callback: Function, delay?: number, ...args: unknown[]): NodeJS.Timeout;
/**
* Cancels a timed repeating action which was previously established by a call to setInterval().
*
* @override
* @param id ID of the interval.
*/
clearInterval(id: NodeJS.Timeout): void;
/**
* Mock animation frames with timeouts.
*
* @override
* @param callback Callback.
* @returns Timeout ID.
*/
requestAnimationFrame(callback: (timestamp: number) => void): NodeJS.Timeout;
/**
* Mock animation frames with timeouts.
*
* @override
* @param id Timeout ID.
*/
cancelAnimationFrame(id: NodeJS.Timeout): void;
/**
* This method provides an easy, logical way to fetch resources asynchronously across the network.
*
* @override
* @param url URL.
* @param [init] Init.
* @returns Promise.
*/
fetch(url: RequestInfo, init?: IRequestInit): Promise;
/**
* Creates a Base64-encoded ASCII string from a binary string (i.e., a string in which each character in the string is treated as a byte of binary data).
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/btoa
* @param data Binay data.
* @returns Base64-encoded string.
*/
btoa(data: unknown): string;
/**
* Decodes a string of data which has been encoded using Base64 encoding.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/atob
* @see https://infra.spec.whatwg.org/#forgiving-base64-encode.
* @see Https://html.spec.whatwg.org/multipage/webappapis.html#btoa.
* @param data Binay string.
* @returns An ASCII string containing decoded data from encodedData.
*/
atob(data: unknown): string;
/**
* Safely enables cross-origin communication between Window objects; e.g., between a page and a pop-up that it spawned, or between a page and an iframe embedded within it.
*
* @param message Message.
* @param [targetOrigin=*] Target origin.
* @param _transfer Transfer. Not implemented.
*/
postMessage(message: unknown, targetOrigin?: string, _transfer?: unknown[]): void;
/**
* Setup of VM context.
*/
protected _setupVMContext(): void;
}