happy-dom
Version:
Happy DOM is a JavaScript implementation of a web browser without its graphical user interface. It includes many web standards from WHATWG DOM and HTML.
134 lines (119 loc) • 2.83 kB
text/typescript
import VirtualConsolePrinter from '../console/VirtualConsolePrinter.js';
import IOptionalBrowserPageViewport from '../browser/types/IOptionalBrowserPageViewport.js';
import IBrowserFrame from '../browser/types/IBrowserFrame.js';
import IBrowserSettings from '../browser/types/IBrowserSettings.js';
/**
* API for detached windows to be able to access features of the browser.
*/
export default class DetachedWindowAPI {
/**
* Constructor.
*
* @param browserFrame Browser frame.
*/
constructor(browserFrame: IBrowserFrame) {
this.
}
/**
* Returns settings.
*
* @returns Settings.
*/
public get settings(): IBrowserSettings {
return this.
}
/**
* Returns virtual console printer.
*
* @returns Virtual console printer.
*/
public get virtualConsolePrinter(): VirtualConsolePrinter {
return this.
}
/**
* Waits for all async tasks to complete.
*
* @returns Promise.
*/
public waitUntilComplete(): Promise<void> {
return this.
}
/**
* Waits for all async tasks to complete.
*
* @deprecated Use waitUntilComplete() instead.
* @returns Promise.
*/
public whenAsyncComplete(): Promise<void> {
return this.waitUntilComplete();
}
/**
* Aborts all async tasks.
*/
public abort(): Promise<void> {
return this.
}
/**
* Aborts all async tasks.
*
* @deprecated Use abort() instead.
*/
public cancelAsync(): Promise<void> {
return this.abort();
}
/**
* Aborts all async tasks and closes the window.
*/
public close(): Promise<void> {
return this.
}
/**
* Sets the URL without navigating the browser.
*
* @param url URL.
*/
public setURL(url: string): void {
this.
}
/**
* Sets the viewport.
*
* @param viewport Viewport.
*/
public setViewport(viewport: IOptionalBrowserPageViewport): void {
this.
}
/**
* Sets the window size.
*
* @deprecated Use setViewport() instead.
* @param options Options.
* @param options.width Width.
* @param options.height Height.
*/
public setWindowSize(options: { width?: number; height?: number }): void {
this.setViewport({
width: options?.width,
height: options?.height
});
}
/**
* Sets the window width.
*
* @deprecated Use setViewport() instead.
* @param width Width.
*/
public setInnerWidth(width: number): void {
this.setViewport({ width });
}
/**
* Sets the window height.
*
* @deprecated Use setViewport() instead.
* @param height Height.
*/
public setInnerHeight(height: number): void {
this.setViewport({ height });
}
}