# browser

Stand-ins for the browser surfaces a test environment cannot supply: windows that message each other across origins, and a `ResizeObserver` the test drives.

## Usage

Unlike [`/dom`](https://www.hyperfrontend.dev/docs/libraries/testing/dom.md), importing this entry changes nothing on the global, and none of it needs jsdom. Each stand-in is typed as the browser interface it replaces, so it goes straight into code that expects a `Window` without a cast.

### Windows that message each other

[`createWindowPair`](https://www.hyperfrontend.dev/docs/libraries/testing/browser/#api-createWindowPair) returns two windows wired the way a page and the frame or popup it opened are. Posting to one delivers to that window's listeners with the other window as the event's source and the other window's origin as its origin:

```typescript
import { expect, it, waitUntil } from '@hyperfrontend/testing'
import { createWindowPair } from '@hyperfrontend/testing/browser'
import { connect } from './connect'

it('connects a host and its frame', async () => {
  const [host, frame] = createWindowPair({ origins: ['https://host.test', 'https://frame.test'] })
  const hostSide = connect({ listenOn: host, peer: frame })
  const frameSide = connect({ listenOn: frame, peer: host })

  await waitUntil(() => hostSide.isOpen() && frameSide.isOpen())

  expect(frame.posted()).toEqual([expect.objectContaining({ type: 'HELLO' })])
})
```

| Behaviour     | What the pair does                                                                                                                                                                           |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Delivery      | On a later timer task, as a browser delivers, which fake timers control. Pass `delivery: 'sync'` to deliver inside the call instead.                                                         |
| Target origin | A post whose target origin is neither `*` nor the receiving window's origin is dropped. `/` stands for the sender's own origin.                                                              |
| Copying       | The message is copied with `structuredClone`. A transfer list is ignored, so a posted buffer stays readable in the recorded call.                                                            |
| Recording     | Every post is recorded, delivered or not: `postMessage` is a mock function, and [`posted`](https://www.hyperfrontend.dev/docs/libraries/testing/browser/#api-FakeWindow) lists the messages. |

[`createFakeWindow`](https://www.hyperfrontend.dev/docs/libraries/testing/browser/#api-createFakeWindow) is a single window with no counterpart: it records what is posted to it, and [`receive`](https://www.hyperfrontend.dev/docs/libraries/testing/browser/#api-FakeWindow) dispatches a message to its listeners as if another origin had sent it.

### ResizeObserver

[`installResizeObserver`](https://www.hyperfrontend.dev/docs/libraries/testing/browser/#api-installResizeObserver) puts a `ResizeObserver` on the global and returns the controller that sends its notifications:

```typescript
const observers = installResizeObserver()
const panel = mountPanel(container)

observers.resize(container, { width: 320, height: 200 })

expect(panel.layout()).toBe('compact')
```

Observers behave like real ones, observing, unobserving and disconnecting, and each entry carries the content rectangle and every box size. A callback runs only when the test calls [`resize`](https://www.hyperfrontend.dev/docs/libraries/testing/browser/#api-ResizeObserverController), never on its own, not even for the initial notification a browser sends when observation starts. [`resizeLate`](https://www.hyperfrontend.dev/docs/libraries/testing/browser/#api-ResizeObserverController) also reaches observers that have stopped watching the element, the way a notification already queued when observation stopped still arrives, for testing code that must ignore one. The stub is installed as a stubbed global, so [`jest.restoreAllMocks`](https://www.hyperfrontend.dev/docs/libraries/testing/#api-JestApi) removes it.

## API Reference

### Functions

#### createFakeWindow

```typescript
function createFakeWindow(options: FakeWindowOptions): FakeWindow
```

Creates a window that records what is posted to it and delivers nothing on its own.

Use it as the target a piece of code posts to, asserting on `posted`, or as the window a
piece of code listens on, feeding it messages with `receive`.

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `options` | `FakeWindowOptions` | The window's origin. (default: `{}`) |

**Returns** `FakeWindow`: The window, typed as a `Window`.

**Example: Feeding a listener a message from another origin**

```ts
const host = createFakeWindow({ origin: 'https://host.test' })
const stop = listenForCommands(host)
host.receive({ type: 'PING' }, { origin: 'https://feature.test' })
expect(host.posted()).toEqual([{ type: 'PONG' }])
```

#### createWindowPair

```typescript
function createWindowPair(options: WindowPairOptions): unknown
```

Creates two windows that can message each other, as a page and the frame or popup it opened.

Posting to one window delivers to that window's own listeners, with the other window as
the event's `source` and the other window's origin as its `origin`, exactly as a browser
reports a message one window sent another. A post whose target origin is neither `*` nor
the receiving window's origin is dropped, as a browser drops it, with `/` standing for the
sender's own origin. The message is copied with `structuredClone`, so the receiver never
shares an object with the sender; a transfer list is ignored, which leaves the posted
buffers readable for assertions. By default delivery waits for a later timer task, which
fake timers control.

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `options` | `WindowPairOptions` | The windows' origins and when a post is delivered. (default: `{}`) |

**Returns** `unknown`: The two windows, each typed as a `Window`.

**Example: Connecting two brokers across a frame boundary**

```ts
const [host, frame] = createWindowPair({ origins: ['https://host.test', 'https://frame.test'] })
const hostBroker = createBroker({ window: host })
const frameBroker = createBroker({ window: frame })
hostBroker.addChannel('frame', frame).connect()
frameBroker.addChannel('host', host).connect()
await waitUntil(() => hostBroker.isConnected())
```

#### installResizeObserver

```typescript
function installResizeObserver(): ResizeObserverController
```

Puts a `ResizeObserver` on the global whose notifications the test sends, and returns the
controller that sends them.

jsdom has no layout engine and so no `ResizeObserver`. Observers created through this one
behave like the real constructor's, observing, unobserving and disconnecting, but a
callback runs only when the test calls `resize`, never on its own: not even the initial
notification a browser sends after `observe`. `resizeLate` delivers to observers that have
stopped watching the element too, the way a notification already queued when observation
stopped still arrives, for code that must ignore one. The stub is installed like a stubbed global,
so `jest.restoreAllMocks` and the runner's `restoreMocks` option remove it.

**Returns** `ResizeObserverController`: The controller.

**Example: Driving a component that follows its container's width**

```ts
const observers = installResizeObserver()
const panel = mountPanel(container)
observers.resize(container, { width: 320, height: 200 })
expect(panel.layout()).toBe('compact')
```

### Interfaces

#### FakeWindow

A stand-in for a browser window as cross-window messaging sees it, accepted wherever a
`Window` is expected.

**Properties**

| Name | Type | Description |
| --- | --- | --- |
| `postMessage` | `MockFn` | Records every message posted to this window, and delivers it when the window is linked. |
| `addEventListener` | `MockFn` | Registers a listener, as a window does. Calls are recorded. |
| `removeEventListener` | `MockFn` | Removes a listener, as a window does. Calls are recorded. |
| `readonly origin` | `string` | The origin this window's own documents run in, compared against a post's target origin. |
| `onabort` | `(this: GlobalEventHandlers, ev: UIEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/abort_event) |
| `onanimationcancel` | `(this: GlobalEventHandlers, ev: AnimationEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/animationcancel_event) |
| `onanimationend` | `(this: GlobalEventHandlers, ev: AnimationEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/animationend_event) |
| `onanimationiteration` | `(this: GlobalEventHandlers, ev: AnimationEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/animationiteration_event) |
| `onanimationstart` | `(this: GlobalEventHandlers, ev: AnimationEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/animationstart_event) |
| `onauxclick` | `(this: GlobalEventHandlers, ev: PointerEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/auxclick_event) |
| `onbeforeinput` | `(this: GlobalEventHandlers, ev: InputEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/beforeinput_event) |
| `onbeforematch` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/beforematch_event) |
| `onbeforetoggle` | `(this: GlobalEventHandlers, ev: ToggleEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/beforetoggle_event) |
| `onblur` | `(this: GlobalEventHandlers, ev: FocusEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/blur_event) |
| `oncancel` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/cancel_event) |
| `oncanplay` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/canplay_event) |
| `oncanplaythrough` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/canplaythrough_event) |
| `onchange` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/change_event) |
| `onclick` | `(this: GlobalEventHandlers, ev: PointerEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/click_event) |
| `onclose` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/close_event) |
| `oncontextlost` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/contextlost_event) |
| `oncontextmenu` | `(this: GlobalEventHandlers, ev: PointerEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/contextmenu_event) |
| `oncontextrestored` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/contextrestored_event) |
| `oncopy` | `(this: GlobalEventHandlers, ev: ClipboardEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/copy_event) |
| `oncuechange` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLTrackElement/cuechange_event) |
| `oncut` | `(this: GlobalEventHandlers, ev: ClipboardEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/cut_event) |
| `ondblclick` | `(this: GlobalEventHandlers, ev: MouseEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/dblclick_event) |
| `ondrag` | `(this: GlobalEventHandlers, ev: DragEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/drag_event) |
| `ondragend` | `(this: GlobalEventHandlers, ev: DragEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/dragend_event) |
| `ondragenter` | `(this: GlobalEventHandlers, ev: DragEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/dragenter_event) |
| `ondragleave` | `(this: GlobalEventHandlers, ev: DragEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/dragleave_event) |
| `ondragover` | `(this: GlobalEventHandlers, ev: DragEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/dragover_event) |
| `ondragstart` | `(this: GlobalEventHandlers, ev: DragEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/dragstart_event) |
| `ondrop` | `(this: GlobalEventHandlers, ev: DragEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/drop_event) |
| `ondurationchange` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/durationchange_event) |
| `onemptied` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/emptied_event) |
| `onended` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/ended_event) |
| `onerror` | `OnErrorEventHandlerNonNull` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/error_event) |
| `onfocus` | `(this: GlobalEventHandlers, ev: FocusEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/focus_event) |
| `onformdata` | `(this: GlobalEventHandlers, ev: FormDataEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/formdata_event) |
| `ongotpointercapture` | `(this: GlobalEventHandlers, ev: PointerEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/gotpointercapture_event) |
| `oninput` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/input_event) |
| `oninvalid` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/invalid_event) |
| `onkeydown` | `(this: GlobalEventHandlers, ev: KeyboardEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/keydown_event) |
| `onkeypress` | `(this: GlobalEventHandlers, ev: KeyboardEvent) => any` |  |
| `onkeyup` | `(this: GlobalEventHandlers, ev: KeyboardEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/keyup_event) |
| `onload` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/load_event) |
| `onloadeddata` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/loadeddata_event) |
| `onloadedmetadata` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/loadedmetadata_event) |
| `onloadstart` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/loadstart_event) |
| `onlostpointercapture` | `(this: GlobalEventHandlers, ev: PointerEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/lostpointercapture_event) |
| `onmousedown` | `(this: GlobalEventHandlers, ev: MouseEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/mousedown_event) |
| `onmouseenter` | `(this: GlobalEventHandlers, ev: MouseEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/mouseenter_event) |
| `onmouseleave` | `(this: GlobalEventHandlers, ev: MouseEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/mouseleave_event) |
| `onmousemove` | `(this: GlobalEventHandlers, ev: MouseEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/mousemove_event) |
| `onmouseout` | `(this: GlobalEventHandlers, ev: MouseEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/mouseout_event) |
| `onmouseover` | `(this: GlobalEventHandlers, ev: MouseEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/mouseover_event) |
| `onmouseup` | `(this: GlobalEventHandlers, ev: MouseEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/mouseup_event) |
| `onpaste` | `(this: GlobalEventHandlers, ev: ClipboardEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/paste_event) |
| `onpause` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/pause_event) |
| `onplay` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/play_event) |
| `onplaying` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/playing_event) |
| `onpointercancel` | `(this: GlobalEventHandlers, ev: PointerEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/pointercancel_event) |
| `onpointerdown` | `(this: GlobalEventHandlers, ev: PointerEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/pointerdown_event) |
| `onpointerenter` | `(this: GlobalEventHandlers, ev: PointerEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/pointerenter_event) |
| `onpointerleave` | `(this: GlobalEventHandlers, ev: PointerEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/pointerleave_event) |
| `onpointermove` | `(this: GlobalEventHandlers, ev: PointerEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/pointermove_event) |
| `onpointerout` | `(this: GlobalEventHandlers, ev: PointerEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/pointerout_event) |
| `onpointerover` | `(this: GlobalEventHandlers, ev: PointerEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/pointerover_event) |
| `onpointerrawupdate` | `(this: GlobalEventHandlers, ev: Event) => any` | Available only in secure contexts. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/pointerrawupdate_event) |
| `onpointerup` | `(this: GlobalEventHandlers, ev: PointerEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/pointerup_event) |
| `onprogress` | `(this: GlobalEventHandlers, ev: ProgressEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/progress_event) |
| `onratechange` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/ratechange_event) |
| `onreset` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/reset_event) |
| `onresize` | `(this: GlobalEventHandlers, ev: UIEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLVideoElement/resize_event) |
| `onscroll` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/scroll_event) |
| `onscrollend` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/scrollend_event) |
| `onsecuritypolicyviolation` | `(this: GlobalEventHandlers, ev: SecurityPolicyViolationEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/securitypolicyviolation_event) |
| `onseeked` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/seeked_event) |
| `onseeking` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/seeking_event) |
| `onselect` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/select_event) |
| `onselectionchange` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/selectionchange_event) |
| `onselectstart` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/selectstart_event) |
| `onslotchange` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLSlotElement/slotchange_event) |
| `onstalled` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/stalled_event) |
| `onsubmit` | `(this: GlobalEventHandlers, ev: SubmitEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/submit_event) |
| `onsuspend` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/suspend_event) |
| `ontimeupdate` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/timeupdate_event) |
| `ontoggle` | `(this: GlobalEventHandlers, ev: ToggleEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/toggle_event) |
| `ontouchcancel?` | `(this: GlobalEventHandlers, ev: TouchEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/touchcancel_event) |
| `ontouchend?` | `(this: GlobalEventHandlers, ev: TouchEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/touchend_event) |
| `ontouchmove?` | `(this: GlobalEventHandlers, ev: TouchEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/touchmove_event) |
| `ontouchstart?` | `(this: GlobalEventHandlers, ev: TouchEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/touchstart_event) |
| `ontransitioncancel` | `(this: GlobalEventHandlers, ev: TransitionEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/transitioncancel_event) |
| `ontransitionend` | `(this: GlobalEventHandlers, ev: TransitionEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/transitionend_event) |
| `ontransitionrun` | `(this: GlobalEventHandlers, ev: TransitionEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/transitionrun_event) |
| `ontransitionstart` | `(this: GlobalEventHandlers, ev: TransitionEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/transitionstart_event) |
| `onvolumechange` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/volumechange_event) |
| `onwaiting` | `(this: GlobalEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/waiting_event) |
| `onwebkitanimationend` | `(this: GlobalEventHandlers, ev: Event) => any` |  |
| `onwebkitanimationiteration` | `(this: GlobalEventHandlers, ev: Event) => any` |  |
| `onwebkitanimationstart` | `(this: GlobalEventHandlers, ev: Event) => any` |  |
| `onwebkittransitionend` | `(this: GlobalEventHandlers, ev: Event) => any` |  |
| `onwheel` | `(this: GlobalEventHandlers, ev: WheelEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/wheel_event) |
| `readonly clientInformation` | `Navigator` |  |
| `readonly closed` | `boolean` | The **`Window.closed`** read-only property indicates whether the referenced window is closed or not. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/closed) |
| `readonly cookieStore` | `CookieStore` | The **`cookieStore`** read-only property of the Window interface returns a reference to the CookieStore object for the current document context. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/cookieStore) |
| `readonly customElements` | `CustomElementRegistry` | The **`customElements`** read-only property of the Window interface returns a reference to the CustomElementRegistry object, which can be used to register new custom elements and get information about previously registered custom elements. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/customElements) |
| `readonly devicePixelRatio` | `number` | The **`devicePixelRatio`** of Window interface returns the ratio of the resolution in _physical pixels_ to the resolution in _CSS pixels_ for the current display device. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/devicePixelRatio) |
| `readonly document` | `Document` | **`window.document`** returns a reference to the document contained in the window. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/document) |
| `readonly event` | `Event` | The read-only Window property **`event`** returns the Event which is currently being handled by the site's code. |
| `readonly external` | `External` | The `external` property of the Window API returns an instance of the `External` interface, which was intended to contain functions related to adding external search providers to the browser. |
| `readonly frameElement` | `Element` | The **`Window.frameElement`** property returns the element (such as iframe or object) in which the window is embedded. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/frameElement) |
| `readonly frames` | `Window` | Returns the window itself, which is an array-like object, listing the direct sub-frames of the current window. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/frames) |
| `readonly history` | `History` | The `Window.history` read-only property returns a reference to the History object, which provides an interface for manipulating the browser _session history_ (pages visited in the tab or frame that the current page is loaded in). [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/history) |
| `readonly innerHeight` | `number` | The read-only **`innerHeight`** property of the including the height of the horizontal scroll bar, if present. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/innerHeight) |
| `readonly innerWidth` | `number` | The read-only Window property **`innerWidth`** returns the interior width of the window in pixels (that is, the width of the window's layout viewport). [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/innerWidth) |
| `readonly length` | `number` | Returns the number of frames (either frame or A number. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/length) |
| `get set location` | `Location` | The **`Window.location`** read-only property returns a Location object with information about the current location of the document. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/location) |
| `readonly locationbar` | `BarProp` | Returns the `locationbar` object. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/locationbar) |
| `readonly menubar` | `BarProp` | Returns the `menubar` object. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/menubar) |
| `name` | `string` | The `Window.name` property gets/sets the name of the window's browsing context. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/name) |
| `readonly navigator` | `Navigator` | The **`Window.navigator`** read-only property returns a reference to the Navigator object, which has methods and properties about the application running the script. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/navigator) |
| `ondevicemotion` | `(this: Window, ev: DeviceMotionEvent) => any` | Available only in secure contexts. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/devicemotion_event) |
| `ondeviceorientation` | `(this: Window, ev: DeviceOrientationEvent) => any` | Available only in secure contexts. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientation_event) |
| `ondeviceorientationabsolute` | `(this: Window, ev: DeviceOrientationEvent) => any` | Available only in secure contexts. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/deviceorientationabsolute_event) |
| `onorientationchange` | `(this: Window, ev: Event) => any` |  |
| `opener` | `any` | The Window interface's **`opener`** property returns a reference to the window that opened the window, either with Window.open, or by navigating a link with a `target` attribute. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/opener) |
| `readonly orientation` | `number` | Returns the orientation in degrees (in 90-degree increments) of the viewport relative to the device's natural orientation. |
| `readonly originAgentCluster` | `boolean` | The **`originAgentCluster`** read-only property of the Window interface returns `true` if this window belongs to an _origin-keyed agent cluster_: this means that the operating system has provided dedicated resources (for example an operating system process) to this window's origin that are not shared with windows from other origins. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/originAgentCluster) |
| `readonly outerHeight` | `number` | The **`Window.outerHeight`** read-only property returns the height in pixels of the whole browser window, including any sidebar, window chrome, and window-resizing borders/handles. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/outerHeight) |
| `readonly outerWidth` | `number` | **`Window.outerWidth`** read-only property returns the width of the outside of the browser window. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/outerWidth) |
| `readonly pageXOffset` | `number` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/scrollX) |
| `readonly pageYOffset` | `number` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/scrollY) |
| `readonly parent` | `Window` | The **`Window.parent`** property is a reference to the parent of the current window or subframe. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/parent) |
| `readonly personalbar` | `BarProp` | Returns the `personalbar` object. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/personalbar) |
| `readonly screen` | `Screen` | The Window property **`screen`** returns a reference to the screen object associated with the window. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/screen) |
| `readonly screenLeft` | `number` | The **`Window.screenLeft`** read-only property returns the horizontal distance, in CSS pixels, from the left border of the user's browser viewport to the left side of the screen. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/screenLeft) |
| `readonly screenTop` | `number` | The **`Window.screenTop`** read-only property returns the vertical distance, in CSS pixels, from the top border of the user's browser viewport to the top side of the screen. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/screenTop) |
| `readonly screenX` | `number` | The **`Window.screenX`** read-only property returns the horizontal distance, in CSS pixels, of the left border of the user's browser viewport to the left side of the screen. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/screenX) |
| `readonly screenY` | `number` | The **`Window.screenY`** read-only property returns the vertical distance, in CSS pixels, of the top border of the user's browser viewport to the top edge of the screen. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/screenY) |
| `readonly scrollX` | `number` | The read-only **`scrollX`** property of the Window interface returns the number of pixels by which the document is currently scrolled horizontally. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/scrollX) |
| `readonly scrollY` | `number` | The read-only **`scrollY`** property of the Window interface returns the number of pixels by which the document is currently scrolled vertically. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/scrollY) |
| `readonly scrollbars` | `BarProp` | Returns the `scrollbars` object. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/scrollbars) |
| `readonly self` | `Window & unknown` | The **`Window.self`** read-only property returns the window itself, as a WindowProxy. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/self) |
| `readonly speechSynthesis` | `SpeechSynthesis` | The `speechSynthesis` read-only property of the Window object returns a SpeechSynthesis object, which is the entry point into using Web Speech API speech synthesis functionality. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/speechSynthesis) |
| `status` | `string` | The **`status`** property of the bar at the bottom of the browser window. |
| `readonly statusbar` | `BarProp` | Returns the `statusbar` object. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/statusbar) |
| `readonly toolbar` | `BarProp` | Returns the `toolbar` object. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/toolbar) |
| `readonly top` | `Window` | Returns a reference to the topmost window in the window hierarchy. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/top) |
| `readonly visualViewport` | `VisualViewport` | The **`visualViewport`** read-only property of the Window interface returns a VisualViewport object representing the visual viewport for a given window, or `null` if current document is not fully active. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/visualViewport) |
| `readonly window` | `Window & unknown` | The **`window`** property of a Window object points to the window object itself. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/window) |
| `onafterprint` | `(this: WindowEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/afterprint_event) |
| `onbeforeprint` | `(this: WindowEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/beforeprint_event) |
| `onbeforeunload` | `(this: WindowEventHandlers, ev: BeforeUnloadEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/beforeunload_event) |
| `ongamepadconnected` | `(this: WindowEventHandlers, ev: GamepadEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/gamepadconnected_event) |
| `ongamepaddisconnected` | `(this: WindowEventHandlers, ev: GamepadEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/gamepaddisconnected_event) |
| `onhashchange` | `(this: WindowEventHandlers, ev: HashChangeEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/hashchange_event) |
| `onlanguagechange` | `(this: WindowEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/languagechange_event) |
| `onmessage` | `(this: WindowEventHandlers, ev: MessageEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/message_event) |
| `onmessageerror` | `(this: WindowEventHandlers, ev: MessageEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/messageerror_event) |
| `onoffline` | `(this: WindowEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/offline_event) |
| `ononline` | `(this: WindowEventHandlers, ev: Event) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/online_event) |
| `onpagehide` | `(this: WindowEventHandlers, ev: PageTransitionEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/pagehide_event) |
| `onpagereveal` | `(this: WindowEventHandlers, ev: PageRevealEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/pagereveal_event) |
| `onpageshow` | `(this: WindowEventHandlers, ev: PageTransitionEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/pageshow_event) |
| `onpageswap` | `(this: WindowEventHandlers, ev: PageSwapEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/pageswap_event) |
| `onpopstate` | `(this: WindowEventHandlers, ev: PopStateEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/popstate_event) |
| `onrejectionhandled` | `(this: WindowEventHandlers, ev: PromiseRejectionEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/rejectionhandled_event) |
| `onstorage` | `(this: WindowEventHandlers, ev: StorageEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/storage_event) |
| `onunhandledrejection` | `(this: WindowEventHandlers, ev: PromiseRejectionEvent) => any` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/unhandledrejection_event) |
| `onunload` | `(this: WindowEventHandlers, ev: Event) => any` |  |
| `readonly localStorage` | `Storage` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/localStorage) |
| `readonly caches` | `CacheStorage` | Available only in secure contexts. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/caches) |
| `readonly crossOriginIsolated` | `boolean` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/crossOriginIsolated) |
| `readonly crypto` | `Crypto` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/crypto) |
| `readonly indexedDB` | `IDBFactory` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/indexedDB) |
| `readonly isSecureContext` | `boolean` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/isSecureContext) |
| `readonly performance` | `Performance` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/performance) |
| `readonly sessionStorage` | `Storage` | [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/sessionStorage) |

##### alert

```typescript
alert(message?: any): void
```

`window.alert()` instructs the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/alert)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `message?` | `any` |  |

##### atob

```typescript
atob(data: string): string
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `data` | `string` |  |

```typescript
atob(data: string): string
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `data` | `string` |  |

##### blur

```typescript
blur(): void
```

The **`Window.blur()`** method does nothing.

##### btoa

```typescript
btoa(data: string): string
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `data` | `string` |  |

```typescript
btoa(data: string): string
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `data` | `string` |  |

##### cancelAnimationFrame

```typescript
cancelAnimationFrame(handle: number): void
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/cancelAnimationFrame)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `handle` | `number` |  |

```typescript
cancelAnimationFrame(handle: number): void
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/cancelAnimationFrame)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `handle` | `number` |  |

##### cancelIdleCallback

```typescript
cancelIdleCallback(handle: number): void
```

The **`window.cancelIdleCallback()`** method cancels a callback previously scheduled with window.requestIdleCallback().

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/cancelIdleCallback)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `handle` | `number` |  |

##### captureEvents

```typescript
captureEvents(): void
```

The **`Window.captureEvents()`** method does nothing.

##### clearInterval

```typescript
clearInterval(id: number): void
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `id` | `number` |  |

```typescript
clearInterval(id: number): void
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `id` | `number` |  |

##### clearTimeout

```typescript
clearTimeout(id: number): void
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `id` | `number` |  |

```typescript
clearTimeout(id: number): void
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `id` | `number` |  |

##### close

```typescript
close(): void
```

The **`Window.close()`** method closes the current window, or the window on which it was called.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/close)

##### confirm

```typescript
confirm(message?: string): boolean
```

`window.confirm()` instructs the browser to display a dialog with an optional message, and to wait until the user either confirms or cancels the dialog.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/confirm)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `message?` | `string` |  |

##### createImageBitmap

```typescript
createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise<ImageBitmap>
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `image` | `ImageBitmapSource` |  |
| `options?` | `ImageBitmapOptions` |  |

```typescript
createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>
```

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `image` | `ImageBitmapSource` |  |
| `sx` | `number` |  |
| `sy` | `number` |  |
| `sw` | `number` |  |
| `sh` | `number` |  |
| `options?` | `ImageBitmapOptions` |  |

```typescript
createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise<ImageBitmap>
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `image` | `ImageBitmapSource` |  |
| `options?` | `ImageBitmapOptions` |  |

```typescript
createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>
```

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `image` | `ImageBitmapSource` |  |
| `sx` | `number` |  |
| `sy` | `number` |  |
| `sw` | `number` |  |
| `sh` | `number` |  |
| `options?` | `ImageBitmapOptions` |  |

##### dispatchEvent

```typescript
dispatchEvent(event: Event): boolean
```

The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `event` | `Event` |  |

```typescript
dispatchEvent(event: Event): boolean
```

The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `event` | `Event` |  |

##### fetch

```typescript
fetch(input: URL | RequestInfo, init?: RequestInit): Promise<Response>
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `input` | `URL \| RequestInfo` |  |
| `init?` | `RequestInit` |  |

```typescript
fetch(input: URL | RequestInfo, init?: RequestInit): Promise<Response>
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `input` | `URL \| RequestInfo` |  |
| `init?` | `RequestInit` |  |

##### focus

```typescript
focus(): void
```

Makes a request to bring the window to the front.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/focus)

##### getComputedStyle

```typescript
getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration
```

The **`Window.getComputedStyle()`** method returns an object containing the values of all CSS properties of an element, after applying active stylesheets and resolving any basic computation those values may contain.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/getComputedStyle)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `elt` | `Element` |  |
| `pseudoElt?` | `string` |  |

##### getSelection

```typescript
getSelection(): Selection
```

The **`getSelection()`** method of the Window interface returns the Selection object associated with the window's document, representing the range of text selected by the user or the current position of the caret.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/getSelection)

##### matchMedia

```typescript
matchMedia(query: string): MediaQueryList
```

The Window interface's **`matchMedia()`** method returns a new MediaQueryList object that can then be used to determine if the document matches the media query string, as well as to monitor the document to detect when it matches (or stops matching) that media query.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/matchMedia)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `query` | `string` |  |

##### messageListenerCount

```typescript
messageListenerCount(): number
```

How many `message` listeners are registered.

##### moveBy

```typescript
moveBy(x: number, y: number): void
```

The **`moveBy()`** method of the Window interface moves the current window by a specified amount.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/moveBy)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `x` | `number` |  |
| `y` | `number` |  |

##### moveTo

```typescript
moveTo(x: number, y: number): void
```

The **`moveTo()`** method of the Window interface moves the current window to the specified coordinates.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/moveTo)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `x` | `number` |  |
| `y` | `number` |  |

##### open

```typescript
open(url?: string | URL, target?: string, features?: string): Window
```

The **`open()`** method of the `Window` interface loads a specified resource into a new or existing browsing context (that is, a tab, a window, or an iframe) under a specified name.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/open)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `url?` | `string \| URL` |  |
| `target?` | `string` |  |
| `features?` | `string` |  |

##### posted

```typescript
posted(): unknown[]
```

The data of every message posted to this window, in order, whether or not it was delivered.

##### print

```typescript
print(): void
```

Opens the print dialog to print the current document.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/print)

##### prompt

```typescript
prompt(message?: string, _default?: string): string
```

`window.prompt()` instructs the browser to display a dialog with an optional message prompting the user to input some text, and to wait until the user either submits the text or cancels the dialog.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/prompt)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `message?` | `string` |  |
| `_default?` | `string` |  |

##### queueMicrotask

```typescript
queueMicrotask(callback: VoidFunction): void
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `callback` | `VoidFunction` |  |

```typescript
queueMicrotask(callback: VoidFunction): void
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `callback` | `VoidFunction` |  |

##### receive

```typescript
receive(data: unknown, from?: MessageSender): void
```

Dispatches a `message` event to this window's listeners now, as if another window had posted it.

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `data` | `unknown` |  |
| `from?` | `MessageSender` |  |

##### releaseEvents

```typescript
releaseEvents(): void
```

Releases the window from trapping events of a specific type.

##### reportError

```typescript
reportError(e: any): void
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `e` | `any` |  |

```typescript
reportError(e: any): void
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `e` | `any` |  |

##### requestAnimationFrame

```typescript
requestAnimationFrame(callback: FrameRequestCallback): number
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/requestAnimationFrame)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `callback` | `FrameRequestCallback` |  |

```typescript
requestAnimationFrame(callback: FrameRequestCallback): number
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/requestAnimationFrame)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `callback` | `FrameRequestCallback` |  |

##### requestIdleCallback

```typescript
requestIdleCallback(callback: IdleRequestCallback, options?: IdleRequestOptions): number
```

The **`window.requestIdleCallback()`** method queues a function to be called during a browser's idle periods.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/requestIdleCallback)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `callback` | `IdleRequestCallback` |  |
| `options?` | `IdleRequestOptions` |  |

##### resizeBy

```typescript
resizeBy(x: number, y: number): void
```

The **`Window.resizeBy()`** method resizes the current window by a specified amount.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/resizeBy)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `x` | `number` |  |
| `y` | `number` |  |

##### resizeTo

```typescript
resizeTo(width: number, height: number): void
```

The **`Window.resizeTo()`** method dynamically resizes the window.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/resizeTo)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `width` | `number` |  |
| `height` | `number` |  |

##### scroll

```typescript
scroll(options?: ScrollToOptions): void
```

The **`Window.scroll()`** method scrolls the window to a particular place in the document.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/scroll)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `options?` | `ScrollToOptions` |  |

```typescript
scroll(x: number, y: number): void
```

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `x` | `number` |  |
| `y` | `number` |  |

##### scrollBy

```typescript
scrollBy(options?: ScrollToOptions): void
```

The **`Window.scrollBy()`** method scrolls the document in the window by the given amount.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/scrollBy)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `options?` | `ScrollToOptions` |  |

```typescript
scrollBy(x: number, y: number): void
```

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `x` | `number` |  |
| `y` | `number` |  |

##### scrollTo

```typescript
scrollTo(options?: ScrollToOptions): void
```

**`Window.scrollTo()`** scrolls to a particular set of coordinates in the document.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/scrollTo)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `options?` | `ScrollToOptions` |  |

```typescript
scrollTo(x: number, y: number): void
```

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `x` | `number` |  |
| `y` | `number` |  |

##### setInterval

```typescript
setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `handler` | `TimerHandler` |  |
| `timeout?` | `number` |  |
| `...arguments` | `any[]` |  |

```typescript
setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `handler` | `TimerHandler` |  |
| `timeout?` | `number` |  |
| `...arguments` | `any[]` |  |

##### setTimeout

```typescript
setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `handler` | `TimerHandler` |  |
| `timeout?` | `number` |  |
| `...arguments` | `any[]` |  |

```typescript
setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `handler` | `TimerHandler` |  |
| `timeout?` | `number` |  |
| `...arguments` | `any[]` |  |

##### stop

```typescript
stop(): void
```

The **`window.stop()`** stops further resource loading in the current browsing context, equivalent to the stop button in the browser.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/stop)

##### structuredClone

```typescript
structuredClone<T>(value: T, options?: StructuredSerializeOptions): T
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `value` | `T` |  |
| `options?` | `StructuredSerializeOptions` |  |

```typescript
structuredClone<T>(value: T, options?: StructuredSerializeOptions): T
```

[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone)

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| `value` | `T` |  |
| `options?` | `StructuredSerializeOptions` |  |

### Types

#### FakeWindowOptions

How a standalone fake window presents itself.

```typescript
type FakeWindowOptions = unknown
```

#### MessageSender

Where a message dispatched with `receive` claims to come from.

```typescript
type MessageSender = unknown
```

#### ObservedSize

A size to report for an observed element, in CSS pixels.

```typescript
type ObservedSize = unknown
```

#### ResizeObserverController

Drives the `ResizeObserver` that `installResizeObserver` put on the global.

```typescript
type ResizeObserverController = unknown
```

#### WindowPairOptions

How a linked pair of fake windows behaves.

```typescript
type WindowPairOptions = unknown
```

---

Canonical page: https://www.hyperfrontend.dev/docs/libraries/testing/browser/
This file: https://www.hyperfrontend.dev/docs/libraries/testing/browser.md
Documentation index: https://www.hyperfrontend.dev/llms.txt
