1. 7.3 The Window object
      1. 7.3.1 APIs for creating and navigating browsing contexts by name
      2. 7.3.2 Accessing other browsing contexts
      3. 7.3.3 Named access on the Window object
      4. 7.3.4 Discarding browsing contexts
      5. 7.3.5 Closing browsing contexts
      6. 7.3.6 Browser interface elements
      7. 7.3.7 Script settings for Window objects
    2. 7.4 The WindowProxy exotic object
      1. 7.4.1 [[GetPrototypeOf]] ( )
      2. 7.4.2 [[SetPrototypeOf]] ( V )
      3. 7.4.3 [[IsExtensible]] ( )
      4. 7.4.4 [[PreventExtensions]] ( )
      5. 7.4.5 [[GetOwnProperty]] ( P )
      6. 7.4.6 [[DefineOwnProperty]] ( P, Desc )
      7. 7.4.7 [[Get]] ( P, Receiver )
      8. 7.4.8 [[Set]] ( P, V, Receiver )
      9. 7.4.9 [[Delete]] ( P )
      10. 7.4.10 [[OwnPropertyKeys]] ( )

7.3 The Window object

Window

Support in all current engines.

Firefox1+Safari1+Chrome1+
Opera3+Edge79+
Edge (Legacy)12+Internet Explorer4+
Firefox Android?Safari iOS?Chrome Android?WebView Android37+Samsung Internet?Opera Android10.1+
[Global=Window,
 Exposed=Window,
 LegacyUnenumerableNamedProperties]
interface Window : EventTarget {
  // the current browsing context
  [LegacyUnforgeable] readonly attribute WindowProxy window;
  [Replaceable] readonly attribute WindowProxy self;
  [LegacyUnforgeable] readonly attribute Document document;
  attribute DOMString name;
  [PutForwards=href, LegacyUnforgeable] readonly attribute Location location;
  readonly attribute History history;
  readonly attribute CustomElementRegistry customElements;
  [Replaceable] readonly attribute BarProp locationbar;
  [Replaceable] readonly attribute BarProp menubar;
  [Replaceable] readonly attribute BarProp personalbar;
  [Replaceable] readonly attribute BarProp scrollbars;
  [Replaceable] readonly attribute BarProp statusbar;
  [Replaceable] readonly attribute BarProp toolbar;
  attribute DOMString status;
  undefined close();
  readonly attribute boolean closed;
  undefined stop();
  undefined focus();
  undefined blur();

  // other browsing contexts
  [Replaceable] readonly attribute WindowProxy frames;
  [Replaceable] readonly attribute unsigned long length;
  [LegacyUnforgeable] readonly attribute WindowProxy?top;
  attribute any opener;
  [Replaceable] readonly attribute WindowProxy?parent;
  readonly attribute Element?frameElement;
  WindowProxy?open(optional USVString url = "", optional DOMString target = "_blank", optional [LegacyNullToEmptyString] DOMString features = "");
  getter object (DOMString name);
  // Since this is the global object, the IDL named getter adds a NamedPropertiesObject exotic
  // object on the prototype chain. Indeed, this does not make the global object an exotic object.
  // Indexed access is taken care of by the WindowProxy exotic object.

  // the user agent
  readonly attribute Navigator navigator;
  readonly attribute Navigator clientInformation; // legacy alias of .navigator
  readonly attribute boolean originAgentCluster;

  // user prompts
  undefined alert();
  undefined alert(DOMString message);
  boolean confirm(optional DOMString message = "");
  DOMString?prompt(optional DOMString message = "", optional DOMString default = "");
  undefined print();

  undefined postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []);
  undefined postMessage(any message, optional WindowPostMessageOptions options = {});

  // also has obsolete members
};
Window includes GlobalEventHandlers;
Window includes WindowEventHandlers;

dictionary WindowPostMessageOptions : StructuredSerializeOptions {
  USVString targetOrigin = "/";
};
window.window

Window/window

Support in all current engines.

Firefox1+Safari3+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+Internet Explorer4+
Firefox Android?Safari iOS1+Chrome Android?WebView Android?Samsung Internet?Opera Android12.1+
window.frames

Window/frames

Support in all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+Internet Explorer4+
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android12.1+
window.self

Window/self

Support in all current engines.

Firefox1+Safari3+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+Internet Explorer4+
Firefox Android?Safari iOS1+Chrome Android?WebView Android?Samsung Internet?Opera Android12.1+

これらの属性はすべてwindowを返す。

window.document

Window/document

Support in all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+Internet Explorer4+
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android12.1+

windowと関連するDocumentを返す。

document.defaultView

Document/defaultView

Support in all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+Internet Explorer9+
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android12.1+

アクティブ文書Windowオブジェクトを返す。

The Window object has an associated Document, which is a Document object. It is set when the Window object is created, and only ever changed during navigation from the initial about:blank Document.

The Window object's browsing context is the Window object's associated Document's browsing context. It is either null or a browsing context.

The window, frames, and self getter steps are to return this's relevant realm.[[GlobalEnv]].[[GlobalThisValue]].

The document getter steps are to return this's associated Document.

The Document object associated with a Window object can change in exactly one case: when the navigate algorithm creates a new Document object for the first page loaded in a browsing context. In that specific case, the Window object of the initial about:blank page is reused and gets a new Document object.

The defaultView getter steps are:

  1. If this's browsing context is null, then return null.

  2. Return this's browsing context's WindowProxy object.


HTMLDocument

Support in all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+Internet Explorer4+
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android12.1+

For historical reasons, Window objects must also have a writable, configurable, non-enumerable property named HTMLDocument whose value is the Document interface object.

7.3.1 APIs for creating and navigating browsing contexts by name

window = window.open([ url [, target [, features ] ] ])

Window/open

Support in all current engines.

Firefox1+Safari1+Chrome1+
Opera3+Edge79+
Edge (Legacy)12+Internet Explorer4+
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android10.1+

Opens a window to show url (defaults to "about:blank"), and returns it. target (defaults to "_blank") gives the name of the new window. If a window already exists with that name, it is reused. The features argument can contain a set of comma-separated tokens:

"noopener"
"noreferrer"

These behave equivalently to the noopener and noreferrer link types on hyperlinks.

"popup"

Encourages user agents to provide a minimal web browser user interface for the new window. (Impacts the visible getter on all BarProp objects as well.)

globalThis.open("https://email.example/message/CAOOOkFcWW97r8yg=SsWg7GgCmp4suVX9o85y8BvNRqMjuc5PXg", undefined, "noopener,popup");
window.name [ = value ]

Window/name

Support in all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+Internet Explorer4+
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android12.1+

ウィンドウの名前を返す。

名前を変更する設定が可能である。

window.close()

Window/close

Support in all current engines.

Firefox1+Safari1+Chrome1+
Opera3+Edge79+
Edge (Legacy)12+Internet Explorer4+
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android10.1+

ウィンドウを閉じる。

window.closed

Window/closed

Support in all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+Internet Explorer4+
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android12.1+

ウィンドウが閉じられている場合はtrueを返し、そうでなければfalseを返す。

window.stop()

Window/stop

Support in all current engines.

Firefox1+Safari3+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)14+Internet ExplorerNo
Firefox Android?Safari iOS1+Chrome Android?WebView Android?Samsung Internet?Opera Android12.1+

ドキュメントの読み込みを中止する。

The window open steps, given a string url, a string target, and a string features, are as follows:

  1. If the event loop's termination nesting level is nonzero, return null.

  2. Let source browsing context be the entry global object's browsing context.

  3. If target is the empty string, then set target to "_blank".

  4. Let tokenizedFeatures be the result of tokenizing features.

  5. Let noopener and noreferrer be false.

  6. If tokenizedFeatures["noopener"] exists, then:

    1. Set noopener to the result of parsing tokenizedFeatures["noopener"] as a boolean feature.

    2. Remove tokenizedFeatures["noopener"].

  7. If tokenizedFeatures["noreferrer"] exists, then:

    1. Set noreferrer to the result of parsing tokenizedFeatures["noreferrer"] as a boolean feature.

    2. Remove tokenizedFeatures["noreferrer"].

  8. If noreferrer is true, then set noopener to true.

  9. Let target browsing context and windowType be the result of applying the rules for choosing a browsing context given target, source browsing context, and noopener.

    If there is a user agent that supports control-clicking a link to open it in a new tab, and the user control-clicks on an element whose onclick handler uses the window.open() API to open a page in an iframe element, the user agent could override the selection of the target browsing context to instead target a new tab.

  10. If target browsing context is null, then return null.

  11. If windowType is either "new and unrestricted" or "new with no opener", then:

    1. Set the target browsing context's is popup to the result of checking if a popup window is requested, given tokenizedFeatures.

    2. Set up browsing context features for target browsing context given tokenizedFeatures. [CSSOMVIEW]

    3. Let urlRecord be the URL record about:blank.

    4. If url is not the empty string, then parse url relative to the entry settings object, and set urlRecord to the resulting URL record, if any. If the parse a URL algorithm failed, then throw a "SyntaxError" DOMException.

    5. If urlRecord matches about:blank, then perform the URL and history update steps given target browsing context's active document and urlRecord.

      This is necessary in case url is something like about:blank?foo. If url is just plain about:blank, this will do nothing.

    6. Otherwise:

      1. Let request be a new request whose URL is urlRecord.

      2. If noreferrer is true, then set request's referrer to "no-referrer".

      3. Navigate target browsing context to request, with exceptionsEnabled set to true and the source browsing context set to source browsing context.

  12. Otherwise:

    1. If url is not the empty string, then:

      1. Let urlRecord be the URL record about:blank.

      2. Parse url relative to the entry settings object, and set urlRecord to the resulting URL record, if any. If the parse a URL algorithm failed, then throw a "SyntaxError" DOMException.

      3. Let request be a new request whose URL is urlRecord.

      4. If noreferrer is true, then set request's referrer to "noreferrer".

      5. Navigate target browsing context to request, with exceptionsEnabled set to true and the source browsing context set to source browsing context.

    2. If noopener is false, then set target browsing context's opener browsing context to source browsing context.

  13. If noopener is true or windowType is "new with no opener", then return null.

  14. Return target browsing context's WindowProxy object.

The open(url, target, features) method steps are to run the window open steps with url, target, and features.

The method provides a mechanism for navigating an existing browsing context or opening and navigating an auxiliary browsing context.


To tokenize the features argument:

  1. Let tokenizedFeatures be a new ordered map.

  2. Let position point at the first code point of features.

  3. While position is not past the end of features:

    1. Let name be the empty string.

    2. Let value be the empty string.

    3. Collect a sequence of code points that are feature separators from features given position. This skips past leading separators before the name.

    4. Collect a sequence of code points that are not feature separators from features given position. Set name to the collected characters, converted to ASCII lowercase.

    5. Set name to the result of normalizing the feature name name.

    6. While position is not past the end of features and the code point at position in features is not U+003D (=):

      1. If the code point at position in features is U+002C (,), or if it is not a feature separator, then break.

      2. Advance position by 1.

      This skips to the first U+003D (=) but does not skip past a U+002C (,) or a non-separator.

    7. If the code point at position in features is a feature separator:

      1. While position is not past the end of features and the code point at position in features is a feature separator:

        1. If the code point at position in features is U+002C (,), then break.

        2. Advance position by 1.

        This skips to the first non-separator but does not skip past a U+002C (,).

      2. Collect a sequence of code points that are not feature separators code points from features given position. Set value to the collected code points, converted to ASCII lowercase.

    8. If name is not the empty string, then set tokenizedFeatures[name] to value.

  4. Return tokenizedFeatures.

To check if a window feature is set, given tokenizedFeatures, featureName, and defaultValue:

  1. If tokenizedFeatures[featureName] exists, then return the result of parsing tokenizedFeatures[featureName] as a boolean feature.

  2. Return defaultValue.

To check if a popup window is requested, given tokenizedFeatures:

  1. If tokenizedFeatures is empty, then return false.

  2. If tokenizedFeatures["popup"] exists, then return the result of parsing tokenizedFeatures["popup"] as a boolean feature.

  3. Let location be the result of checking if a window feature is set, given tokenizedFeatures, "location", and false.

  4. Let toolbar be the result of checking if a window feature is set, given tokenizedFeatures, "toolbar", and false.

  5. If location and toolbar are both false, then return true.

  6. Let menubar be the result of checking if a window feature is set, given tokenizedFeatures, menubar", and false.

  7. If menubar is false, then return true.

  8. Let resizable be the result of checking if a window feature is set, given tokenizedFeatures, "resizable", and true.

  9. If resizable is false, then return true.

  10. Let scrollbars be the result of checking if a window feature is set, given tokenizedFeatures, "scrollbars", and false.

  11. If scrollbars is false, then return true.

  12. Let status be the result of checking if a window feature is set, given tokenizedFeatures, "status", and false.

  13. If status is false, then return true.

  14. Return false.

A code point is a feature separator if it is ASCII whitespace, U+003D (=), or U+002C (,).

For legacy reasons, there are some aliases of some feature names. To normalize a feature name name, switch on name:

"screenx"
Return "left".
"screeny"
Return "top".
"innerwidth"
Return "width".
"innerheight"
Return "height".
Anything else
Return name.

To parse a boolean feature given a string value:

  1. If value is the empty string, then return true.

  2. If value is "yes", then return true.

  3. If value is "true", then return true.

  4. Let parsed be the result of parsing value as an integer.

  5. If parsed is an error, then set it to 0.

  6. Return false if parsed is 0, and true otherwise.


The name getter steps are:

  1. If this's browsing context is null, then return the empty string.

  2. Return this's browsing context's name.

The name setter steps are:

  1. If this's browsing context is null, then return.

  2. Set this's browsing context's name to the given value.

The name gets reset when the browsing context is navigated to another origin.


The close() method steps are:

  1. Let current be this's browsing context.

  2. If current is null or its is closing is true, then return.

  3. If all the following are true

    then:

    1. Set current's is closing to true.

    2. Queue a task on the DOM manipulation task source to close current.

A browsing context is script-closable if it is an auxiliary browsing context that was created by a script (as opposed to by an action of the user), or if it is a top-level browsing context whose session history contains only one Document.

The closed getter steps are to return true if this's browsing context is null or its is closing is true; otherwise false.

The stop() method steps are to stop document loading given this's associated Document.

7.3.2 Accessing other browsing contexts

window.length

Window/length

Support in all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+Internet Explorer4+
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android12.1+

文書ツリー子ブラウジングコンテキストの数を返す。

window[index]

指示された文書ツリー子ブラウジングコンテキストを返す。

The number of document-tree child browsing contexts of a Window object W is the result of running these steps:

  1. If W's browsing context is null, then return 0.

  2. Return the number of document-tree child browsing contexts of W's browsing context.

The length getter steps are to return the number of document-tree child browsing contexts of this.

Indexed access to document-tree child browsing contexts is defined through the [[GetOwnProperty]] internal method of the WindowProxy object.

7.3.3 Named access on the Window object

window[name]

指示された要素または要素のコレクションを返す。

一般的な規則として、これに依存することはもろいコードを導く。Which IDs end up mapping to this API can vary over time, as new features are added to the web platform, for example. この代わりに、document.getElementById()またはdocument.querySelector()を使用する。

The document-tree child browsing context name property set of a Window object window is the return value of running these steps:

  1. If window's browsing context is null, then return the empty list.

  2. Let childBrowsingContexts be all document-tree child browsing contexts of window's browsing context whose browsing context name is not the empty string, in order, and including only the first document-tree child browsing context with a given name if multiple document-tree child browsing contexts have the same one.

  3. Remove each browsing context from childBrowsingContexts whose active document's origin is not same origin with window's relevant settings object's origin and whose browsing context name does not match the name of its container's name content attribute value.

  4. Return the browsing context names of childBrowsingContexts, in the same order.

This means that in the following example, hosted on https://example.org/, assuming https://elsewhere.example/ sets window.name to "spices", evaluating window.spices after everything has loaded will yield undefined:

<iframe src=https://elsewhere.example.com/></iframe>
<iframe name=spices></iframe>

The Window object supports named properties. The supported property names of a Window object window at any moment consist of the following, in tree order according to the element that contributed them, ignoring later duplicates:

To determine the value of a named property name in a Window object window, the user agent must return the value obtained using the following steps:

  1. Let objects be the list of named objects of window with the name name.

    There will be at least one such object, by definition.

  2. If objects contains a browsing context, then return the WindowProxy object of the nested browsing context of the first browsing context container in tree order whose nested browsing context is in objects.

  3. Otherwise, if objects has only one element, return that element.

  4. Otherwise return an HTMLCollection rooted at window's associated Document, whose filter matches only named objects of window with the name name. (By definition, these will all be elements.)

Named objects of Window object window with the name name, for the purposes of the above algorithm, consist of the following:

7.3.4 Discarding browsing contexts

To discard a Document document:

  1. Set document's salvageable state to false.

  2. Run any unloading document cleanup steps for document that are defined by this specification and other applicable specifications.

  3. Abort document.

  4. Remove any tasks associated with document in any task source, without running those tasks.

  5. Discard all the child browsing contexts of document.

  6. For each session history entry entry whose document is equal to document, set entry's document to null.

  7. Set document's browsing context to null.

  8. Remove document from the owner set of each WorkerGlobalScope object whose set contains document.

  9. For each workletGlobalScope in document's worklet global scopes, terminate workletGlobalScope.

To discard a browsing context browsingContext, run these steps:

  1. Discard all Document objects for all the entries in browsingContext's session history.

  2. If browsingContext is a top-level browsing context, then remove browsingContext.

User agents may discard top-level browsing contexts at any time (typically, in response to user requests, e.g., when a user force-closes a window containing one or more top-level browsing contexts). Other browsing contexts must be discarded once their WindowProxy object is eligible for garbage collection, in addition to the other places where this specification requires them to be discarded.

7.3.5 Closing browsing contexts

To close a browsing context browsingContext, run these steps:

  1. If the result of calling prompt to unload with browsingContext's active document is "refuse", then return.

  2. Unload browsingContext's active document.

  3. Remove browsingContext from the user interface (e.g., close or hide its tab in a tabbed browser).

  4. Discard browsingContext.

ユーザーエージェントは、ユーザーが任意に任意のトップレベルブラウジングコンテキスト閉じる機能を提供すべきである。

7.3.6 Browser interface elements

For historical reasons, the Window interface had some attributes that represented the visibility of certain web browser interface elements.

For privacy and interoperability reasons, those attributes now return values that represent whether the Window's browsing context's is popup property is true or false.

各インターフェイス要素はBarPropオブジェクトによって表される:

BarProp

Support in all current engines.

Firefox1+Safari3+Chrome1+
Opera?Edge79+
Edge (Legacy)12+Internet ExplorerNo
Firefox Android?Safari iOS1+Chrome Android?WebView Android37+Samsung Internet?Opera Android?
[Exposed=Window]
interface BarProp {
  readonly attribute boolean visible;
};
window.locationbar.visible

Window/locationbar

Support in all current engines.

Firefox1+Safari3+Chrome1+
Opera?Edge79+
Edge (Legacy)12+Internet ExplorerNo
Firefox Android?Safari iOS1+Chrome Android?WebView Android?Samsung Internet?Opera Android?
window.menubar.visible

Window/menubar

Support in all current engines.

Firefox1+Safari3+Chrome1+
Opera?Edge79+
Edge (Legacy)12+Internet ExplorerNo
Firefox Android?Safari iOS1+Chrome Android?WebView Android?Samsung Internet?Opera Android?
window.personalbar.visible

Window/personalbar

Support in all current engines.

Firefox1+Safari3+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+Internet ExplorerNo
Firefox Android?Safari iOS1+Chrome Android?WebView Android?Samsung Internet?Opera Android12.1+
window.scrollbars.visible

Window/scrollbars

Support in all current engines.

Firefox1+Safari3+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+Internet ExplorerNo
Firefox Android?Safari iOS1+Chrome Android?WebView Android?Samsung Internet?Opera Android12.1+
window.statusbar.visible

Window/statusbar

Support in all current engines.

Firefox1+Safari3+Chrome1+
Opera?Edge79+
Edge (Legacy)12+Internet ExplorerNo
Firefox Android?Safari iOS1+Chrome Android?WebView Android?Samsung Internet?Opera Android?
window.toolbar.visible

Window/toolbar

Support in all current engines.

Firefox1+Safari3+Chrome1+
Opera?Edge79+
Edge (Legacy)12+Internet ExplorerNo
Firefox Android?Safari iOS1+Chrome Android?WebView Android?Samsung Internet?Opera Android?

Returns true if the top-level browsing context is not a popup; otherwise, returns false.

BarProp/visible

Support in all current engines.

Firefox1+Safari3+Chrome1+
Opera?Edge79+
Edge (Legacy)12+Internet ExplorerNo
Firefox Android?Safari iOS1+Chrome Android?WebView Android37+Samsung Internet?Opera Android?

The visible getter steps are:

  1. Let browsingContext be this's relevant global object's browsing context.

  2. If browsingContext is null, then return true.

  3. Return the negation of browsingContext's top-level browsing context's is popup.

The following BarProp objects must exist for each Window object:

The location bar BarProp object
Historically represented the user interface element that contains a control that displays the browser's location bar.
The menu bar BarProp object
Historically represented the user interface element that contains a list of commands in menu form, or some similar interface concept.
The personal bar BarProp object
Historically represented the user interface element that contains links to the user's favorite pages, or some similar interface concept.
The scrollbar BarProp object
Historically represented the user interface element that contains a scrolling mechanism, or some similar interface concept.
The status bar BarProp object
Historically represented a user interface element found immediately below or after the document, as appropriate for the user's media, which typically provides information about ongoing network activity or information about elements that the user's pointing device is currently indicating.
The toolbar BarProp object
Historically represented the user interface element found immediately above or before the document, as appropriate for the user's media, which typically provides session history traversal controls (back and forward buttons, reload buttons, etc.).

The locationbar attribute must return the location bar BarProp object.

The menubar attribute must return the menu bar BarProp object.

The personalbar attribute must return the personal bar BarProp object.

The scrollbars attribute must return the scrollbar BarProp object.

The statusbar attribute must return the status bar BarProp object.

The toolbar attribute must return the toolbar BarProp object.


For historical reasons, the status attribute on the Window object must, on getting, return the last string it was set to, and on setting, must set itself to the new value. When the Window object is created, the attribute must be set to the empty string. It does not do anything else.

7.3.7 Script settings for Window objects

To set up a window environment settings object, given a URL creationURL, a JavaScript execution context execution context, null or an environment reservedEnvironment, a URL topLevelCreationURL, and an origin topLevelOrigin, run these steps:

  1. Let realm be the value of execution context's Realm component.

  2. Let window be realm's global object.

  3. Let settings object be a new environment settings object whose algorithms are defined as follows:

    The realm execution context

    Return execution context.

    The module map

    Return the module map of window's associated Document.

    The API URL character encoding

    Return the current character encoding of window's associated Document.

    The API base URL

    Return the current base URL of window's associated Document.

    The origin

    Return the origin of window's associated Document.

    The policy container

    Return the policy container of window's associated Document.

    The cross-origin isolated capability

    Return true if both of the following hold, and false otherwise:

    1. realm's agent cluster's cross-origin-isolation mode is "concrete", and

    2. window's associated Document is allowed to use the "cross-origin-isolated" feature.

    The time origin

    Return window's associated Document's load timing info's navigation start time.

  4. If reservedEnvironment is non-null, then:

    1. Set settings object's id to reservedEnvironment's id, target browsing context to reservedEnvironment's target browsing context, and active service worker to reservedEnvironment's active service worker.

    2. Set reservedEnvironment's id to the empty string.

      The identity of the reserved environment is considered to be fully transferred to the created environment settings object. The reserved environment is not searchable by the environment’s id from this point on.

  5. Otherwise, set settings object's id to a new unique opaque string, settings object's target browsing context to null, and settings object's active service worker to null.

  6. Set settings object's creation URL to creationURL, settings object's top-level creation URL to topLevelCreationURL, and settings object's top-level origin to topLevelOrigin.

  7. Set realm's [[HostDefined]] field to settings object.

7.4 The WindowProxy exotic object

A WindowProxy is an exotic object that wraps a Window ordinary object, indirecting most operations through to the wrapped object. Each browsing context has an associated WindowProxy object. When the browsing context is navigated, the Window object wrapped by the browsing context's associated WindowProxy object is changed.

The WindowProxy exotic object must use the ordinary internal methods except where it is explicitly specified otherwise below.

There is no WindowProxy interface object.

Every WindowProxy object has a [[Window]] internal slot representing the wrapped Window object.

Although WindowProxy is named as a "proxy", it does not do polymorphic dispatch on its target's internal methods as a real proxy would, due to a desire to reuse machinery between WindowProxy and Location objects. As long as the Window object remains an ordinary object this is unobservable and can be implemented either way.

7.4.1 [[GetPrototypeOf]] ( )

  1. Let W be the value of the [[Window]] internal slot of this.

  2. If IsPlatformObjectSameOrigin(W) is true, then return ! OrdinaryGetPrototypeOf(W).

  3. Return null.

7.4.2 [[SetPrototypeOf]] ( V )

  1. Return ! SetImmutablePrototype(this, V).

7.4.3 [[IsExtensible]] ( )

  1. Return true.

7.4.4 [[PreventExtensions]] ( )

  1. Return false.

7.4.5 [[GetOwnProperty]] ( P )

  1. Let W be the value of the [[Window]] internal slot of this.

  2. If P is an array index property name, then:

    1. Let index be ! ToUint32(P).

    2. Let maxProperties be the number of document-tree child browsing contexts of W.

    3. Let value be undefined.

    4. If maxProperties is greater than 0 and index is less than maxProperties, then set value to the WindowProxy object of the indexth document-tree child browsing context of W's browsing context, sorted in the order that their browsing context container elements were most recently inserted into W's associated Document, the WindowProxy object of the most recently inserted browsing context container's nested browsing context being last.

    5. If value is undefined, then:

      1. If IsPlatformObjectSameOrigin(W) is true, then return undefined.

      2. Throw a "SecurityError" DOMException.

    6. Return PropertyDescriptor{ [[Value]]: value, [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: true }.

  3. If IsPlatformObjectSameOrigin(W) is true, then return ! OrdinaryGetOwnProperty(W, P).

    This is a willful violation of the JavaScript specification's invariants of the essential internal methods to maintain compatibility with existing web content. See tc39/ecma262 issue #672 for more information. [JAVASCRIPT]

  4. Let property be CrossOriginGetOwnPropertyHelper(W, P).

  5. If property is not undefined, then return property.

  6. If property is undefined and P is in W's document-tree child browsing context name property set, then:

    1. Let value be the WindowProxy object of the named object of W with the name P.

    2. Return PropertyDescriptor{ [[Value]]: value, [[Enumerable]]: false, [[Writable]]: false, [[Configurable]]: true }.

      The reason the property descriptors are non-enumerable, despite this mismatching the same-origin behavior, is for compatibility with existing web content. See issue #3183 for details.

  7. Return ? CrossOriginPropertyFallback(P).

7.4.6 [[DefineOwnProperty]] ( P, Desc )

  1. Let W be the value of the [[Window]] internal slot of this.

  2. If IsPlatformObjectSameOrigin(W) is true, then:

    1. If P is an array index property name, return false.

    2. Return ? OrdinaryDefineOwnProperty(W, P, Desc).

      This is a willful violation of the JavaScript specification's invariants of the essential internal methods to maintain compatibility with existing web content. See tc39/ecma262 issue #672 for more information. [JAVASCRIPT]

  3. Throw a "SecurityError" DOMException.

7.4.7 [[Get]] ( P, Receiver )

  1. Let W be the value of the [[Window]] internal slot of this.

  2. Check if an access between two browsing contexts should be reported, given the current global object's browsing context, W's browsing context, P, and the current settings object.

  3. If IsPlatformObjectSameOrigin(W) is true, then return ? OrdinaryGet(this, P, Receiver).

  4. Return ? CrossOriginGet(this, P, Receiver).

this is passed rather than W as OrdinaryGet and CrossOriginGet will invoke the [[GetOwnProperty]] internal method.

7.4.8 [[Set]] ( P, V, Receiver )

  1. Let W be the value of the [[Window]] internal slot of this.

  2. Check if an access between two browsing contexts should be reported, given the current global object's browsing context, W's browsing context, P, and the current settings object.

  3. If IsPlatformObjectSameOrigin(W) is true, then:

    1. If P is an array index property name, then return false.

    2. Return ? OrdinarySet(W, P, V, Receiver).

  4. Return ? CrossOriginSet(this, P, V, Receiver).

    this is passed rather than W as CrossOriginSet will invoke the [[GetOwnProperty]] internal method.

7.4.9 [[Delete]] ( P )

  1. Let W be the value of the [[Window]] internal slot of this.

  2. If IsPlatformObjectSameOrigin(W) is true, then:

    1. If P is an array index property name, then:

      1. Let desc be ! this.[[GetOwnProperty]](P).

      2. If desc is undefined, then return true.

      3. Return false.

    2. Return ? OrdinaryDelete(W, P).

  3. Throw a "SecurityError" DOMException.

7.4.10 [[OwnPropertyKeys]] ( )

  1. Let W be the value of the [[Window]] internal slot of this.

  2. Let keys be a new empty List.

  3. Let maxProperties be the number of document-tree child browsing contexts of W.

  4. indexを0にする。

  5. Repeat while index < maxProperties,

    1. Add ! ToString(index) as the last element of keys.

    2. Increment index by 1.

  6. If IsPlatformObjectSameOrigin(W) is true, then return the concatenation of keys and OrdinaryOwnPropertyKeys(W).

  7. Return the concatenation of keys and ! CrossOriginOwnPropertyKeys(W).