このセクションは、ウェブブラウザーに最も直接的に適用される機能について説明する。それでもやはり、特に指定しない限り、このセクションで定義されている要件は、ウェブブラウザーであるかどうかに関わらず、すべてのユーザーエージェントに適用される。
ブラウジングコンテキストはDocument
オブジェクトがユーザーに提示される環境である。
ウェブブラウザーのタブまたはウィンドウは通常、iframe
またはframeset
内のframe
を含む、ブラウジングコンテキストを含む。
ブラウジングコンテキストは、対応するWindowProxy
オブジェクトを持つ。
A browsing context has an opener browsing context, which is null or a browsing context. It is initially null.
A browsing context has a disowned boolean. 最初はfalseである。
A browsing context has an is closing boolean. 最初はfalseである。
ブラウジングコンテキストは、ブラウジングコンテキストが提示されていた、している、またはするだろうDocument
オブジェクトを一覧表示するセッション履歴を持つ。ブラウジングコンテキストのアクティブ文書は、そのWindowProxy
オブジェクトの[[Window]]内部スロット値に関連付けられたDocument
である。A Document
's browsing context is the browsing context whose session history contains the Document
, if any such browsing context exists and has not been discarded, and null otherwise.
In general, there is a 1-to-1 mapping from the Window
object to the Document
object, as long as the Document
object has a non-null browsing context. There is one exception. A Window
can be reused for the presentation of a second Document
in the same browsing context, such that the mapping is then 1-to-2. 交換が有効な、ブラウジングコンテキストが初期about:blank
Document
から別のものにナビゲートしたとき、これは起こる。
A Document
does not necessarily have a non-null browsing context. 具体的には、データマイニングツールはブラウジングコンテキストをインスタンス化できないだろう。A Document
created using an API such as createDocument()
never has a non-null browsing context. 文書から削除されて以来、iframe
要素で当初は作成されたDocument
は、そのブラウジングコンテキストが破棄されたので、関連付けられたブラウジングコンテキストを持たない。
To set the active document of a browsing context browsingContext to a Document
object document, run these steps:
Let window be document's relevant global object.
Per this standard document can be created before window, which does not make much sense. See issue #2688.
Set browsingContext's WindowProxy
object's [[Window]] internal slot value to window.
Set window's associated Document
to document.
Set window's relevant settings object's execution ready flag.
A browsing context has an associated creator origin (null or returns an origin), creator URL (null or returns a URL), and creator base URL (null or returns a URL). These are all initially null.
To determine the origin, given browsing context browsingContext, URL url, sandboxing flag set sandboxFlags, and two origins invocationOrigin and activeDocumentNavigationOrigin:
If sandboxFlags has its sandboxed origin browsing context flag set, then return a new opaque origin.
If url is null, then return a new opaque origin.
If activeDocumentOrigin is not null, and url's scheme is "javascript
", then return activeDocumentNavigationOrigin.
If invocationOrigin is non-null and url is about:blank
, then return invocationOrigin.
The result here is that two documents end up with the same underlying origin, meaning that document.domain
affects both.
If url is about:srcdoc
, then return the origin of browsingContext's container document.
Return url's origin.
To create a new browsing context, given null or a Document
object creator and browsing context group group:
Let browsingContext be a new browsing context.
If creator is non-null, then set browsingContext's creator origin to return creator's origin, browsingContext's creator URL to return creator's URL, and browsingContext's creator base URL to return creator's base URL.
Let sandboxFlags be the result of determining sandboxing flags given browsingContext.
Let origin be the result of determining the origin given browsingContext, about:blank
, sandboxFlags, browsingContext's creator origin, and null.
Let featurePolicy be the result of creating a feature policy given browsingContext and origin. [FEATUREPOLICY]
Let agent be the result of obtaining a similar-origin window agent given origin and group.
Let realm execution context be the result of creating a new JavaScript realm with the following customizations:
For the agent, use agent. This pointer is not yet defined in the JavaScript specification; see tc39/ecma262#1357.
For the global object, create a new Window
object.
For the global this binding, use browsingContext's WindowProxy
object.
Set up a window environment settings object with realm execution context, and let settingsObject be the result.
Let document be a new Document
, marked as an HTML document in quirks mode, whose content type is "text/html
", origin is origin, active sandboxing flag set is sandboxFlags, feature policy is feature policy, and which is both ready for post-load tasks and completely loaded immediately.
Ensure that document has a single child html
node, which itself has two empty child nodes: a head
element, and a body
element.
Set the active document of browsingContext to document.
If browsingContext's creator URL is non-null, then set document's referrer to the serialization of it.
If creator is non-null, then set document's referrer policy to creator's referrer policy.
Add document to browsingContext's session history.
Return browsingContext.
To create a new top-level browsing context:
Let group be the result of creating a new browsing context group.
Return group's browsing context set[0].
This creates a top-level browsing context.
To create a new auxiliary browsing context, given a browsing context opener:
Let group be opener's top-level browsing context's group
Assert: group is non-null, as navigating invokes this directly.
Let browsingContext be the result of creating a new browsing context with opener's active document and group.
Append browsingContext to group.
Set browsingContext's opener browsing context to opener.
Assert: browsingContext's creator origin is non-null.
If browsingContext's creator origin is same origin with browsingContext's active document's origin, then copy the sessionStorage
storage area of opener into browsingContext's set of session storage areas. These areas must be considered separate, not affecting each other in any way.
Return browsingContext.
This creates a top-level browsing context that is also an auxiliary browsing context.
To create a new nested browsing context, given an element element:
Let browsingContext be the result of creating a new browsing context with element's node document and element's node document's browsing context's top-level browsing context's group.
Set element's nested browsing context to browsingContext.
If element has a name
attribute, then set browsingContext's name to the value of this attribute.
特定の要素(たとえば、iframe
要素)は、ブラウジングコンテキストをさらにインスタンス化できる。この要素は、ブラウジングコンテキストコンテナと呼ばれる。
各ブラウジングコンテキストコンテナは、ブラウジングコンテキストまたはnullのいずれとなる、ネストされたブラウジングコンテキストを持つ。It is initially null.
The container of a browsing context bc is the browsing context container whose nested browsing context is bc, or null if there is no such element.
Each browsing context bc has a container document, which is the result of running these steps:
If bc's container is null, then return null.
Return bc's container's node document.
This is equal to bc's container's shadow-including root as bc's container has to be connected.
A browsing context child is said to be a child browsing context of another browsing context parent, if child's container document is non-null and child's container document's browsing context is parent.
A browsing context child is a document-tree child browsing context of parent if child is a child browsing context and child's container is in a document tree.
ブラウジングコンテキストchildは親ブラウジングコンテキストを持ってもよい。もしそのようなブラウジングコンテキストが存在すれば、これは子ブラウジングコンテキストとしてchildを持つ一意なブラウジングコンテキストである。そうでなければ、ブラウジングコンテキストは、親ブラウジングコンテキストを持たない。
ブラウジングコンテキストAがAの子ブラウジングコンテキストであり、かつBの祖先自身であるブラウジングコンテキストA'が存在する場合、またはブラウジングコンテキストAがBの親ブラウジングコンテキストである場合、ブラウジングコンテキストBの祖先であると言われる。
A browsing context that has no parent browsing context is the top-level browsing context for itself and all of the browsing contexts for which it is an ancestor browsing context.
A top-level browsing context has an associated group (null or a browsing context group). It is initially null.
It is possible to create new browsing contexts that are related to a top-level browsing context while their container is null. Such browsing contexts are called auxiliary browsing contexts. Auxiliary browsing contexts are always top-level browsing contexts.
The transitive closure of parent browsing contexts for a browsing context that is a child browsing context gives the list of ancestor browsing contexts.
Document
dの子孫ブラウジングコンテキストのリストは、以下のアルゴリズムによって返される(順序の)リストである:
Let list be an empty list.
For each browsing context container container, whose nested browsing context is non-null and whose shadow-including root is d, in shadow-including tree order:
Let nestedBC be container's nested browsing context.
Append nestedBC to list.
Extend list with the list of the descendant browsing contexts of nestedBC's active document.
listを返す。
A Document
d is said to be fully active when d's browsing context is non-null, d's browsing context's active document is d, and either d's browsing context is a top-level browsing context, or d's container document is fully active.
Because they are associated with an element, child browsing contexts are always tied to a specific Document
in their parent browsing context. ユーザーエージェントは、ユーザーにがいない自身が完全にアクティブでないDocument
にある要素の子ブラウジングコンテキストと対話することを許可してはならない。
The following example illustrates the differences between active and fully active Document
objects. Here a.html
is loaded into a browser window, b-1.html
starts out loaded into an iframe
as shown, and b-2.html
and c.html
are omitted (they can simply be an empty document).
<!-- a.html -->
<!DOCTYPE html>
< html lang = "en" >
< title > Browsing context A</ title >
< iframe src = "b-1.html" ></ iframe >
< button onclick = "frames[0].location.href = 'b-2.html'" > Click me</ button >
<!-- b-1.html -->
<!DOCTYPE html>
< html lang = "en" >
< title > Browsing context B</ title >
< iframe src = "c.html" ></ iframe >
At this point, the documents given by a.html
, b-1.html
, and c.html
are all the active documents of their respective browsing contexts. They are also all fully active.
After clicking on the button
, and thus loading a new Document
from b-2.html
into browsing context B, we have the following results:
The a.html
Document
remains both the active document of browsing context A, and fully active.
The b-1.html
Document
is now not the active document of browsing context B. As such it is also not fully active.
The new b-2.html
Document
is now the active document of browsing context B, and is also fully active.
The c.html
Document
is still the active document of browsing context C. However, since C's container document is the b-1.html
Document
, which is itself not fully active, this means the c.html
Document
is now not fully active (even though it is active).
For more explorations of the complexities involved here, especially as it impacts the session history, see A Model of Navigation History. [NAVMODEL]
A child browsing context can be put into a delaying load
events mode. This is used when it is navigated, to delay the load event of its container before the new Document
is created.
ブラウジングコンテキストのドキュメントファミリーは、そのブラウジングコンテキストのセッション履歴ですべてのDocument
オブジェクト およびすべてのそれらDocument
オブジェクトのドキュメントファミリーの結合で構成される。The document family of a Document
object consists of the union of all the document families of the browsing contexts in the list of the descendant browsing contexts of the Document
object.
The content document of a browsing context container container is the result of the following algorithm:
If container's nested browsing context is null, then return null.
Let context be container's nested browsing context.
Let document be context's active document.
If document's origin and the origin specified by the current settings object are not same origin-domain, then return null.
Return document.
top
opener
[ = value ]Returns the WindowProxy
for the opener browsing context.
Returns null if there isn't one or if it has been set to null.
Can be set to null.
parent
親ブラウジングコンテキストに対するWindowProxy
を返す。
frameElement
存在しない場合、クロスオリジンの状況でnullを返す。
The top
attribute's getter must run these steps:
If this Window
object's browsing context is null, then return null.
Return this Window
object's browsing context's top-level browsing context's WindowProxy
object.
The opener
attribute's getter must run these steps:
Let current be this Window
object's browsing context.
If current is null, then return null.
If current's disowned is true, then return null.
If current's opener browsing context is null, then return null.
Return current's opener browsing context's WindowProxy
object.
The opener
attribute's setter must run these steps:
If the given value is null and this Window
object's browsing context is non-null, then set this Window
object's browsing context's disowned to true.
If the given value is non-null, then return ? OrdinaryDefineOwnProperty(this Window
object, "opener
", { [[Value]]: the given value, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }).
If a browsing context's disowned is true, its window.opener
attribute is null. That prevents scripts in the browsing context from changing any properties of its opener browsing context's Window
object (i.e., the Window
object from which the browsing context was created).
Otherwise, if a browsing context's disowned is false, then scripts in that browsing context can use window.opener
to change properties of its opener browsing context's Window
object. For example, a script running in the browsing context can change the value of window.opener.location
, causing the opener browsing context to navigate to a completely different document.
The parent
attribute's getter must run these steps:
Let current be this Window
object's browsing context.
If current is null, then return null.
If current is a child browsing context of another browsing context parent, then return parent's WindowProxy
object.
Assert: current is a top-level browsing context.
Return current's WindowProxy
object.
The frameElement
attribute's getter must run these steps:
Let current be this Window
object's browsing context.
If current is null, then return null.
Let container be current's container.
If container is null, then return null.
If container's node document's origin is not same origin-domain with the current settings object's origin, then return null.
Return container.
An example of when these IDL attributes can return null is as follows:
<!DOCTYPE html>
< iframe ></ iframe >
< script >
"use strict" ;
const element = document. querySelector( "iframe" );
const iframeWindow = element. contentWindow;
element. remove();
console. assert( iframeWindow. top === null );
console. assert( iframeWindow. parent === null );
console. assert( iframeWindow. frameElement === null );
</ script >
Here the browsing context corresponding to iframeWindow
was discarded when element
was removed from the document.
A browsing context A is familiar with a second browsing context B if one of the following conditions is true:
A browsing context A is allowed to navigate a second browsing context B if the following algorithm returns true:
If A is not the same browsing context as B, and A is not one of the ancestor browsing contexts of B, and B is not a top-level browsing context, and A's active document's active sandboxing flag set has its sandboxed navigation browsing context flag set, then return false.
Otherwise, if B is a top-level browsing context, and is one of the ancestor browsing contexts of A, then:
If A's WindowProxy
's [[Window]] value has transient activation and A's active document's active sandboxing flag set has its sandboxed top-level navigation with user activation browsing context flag set, then return false.
Otherwise, if A's WindowProxy
's [[Window]] value does not have transient activation and A's active document's active sandboxing flag set has its sandboxed top-level navigation without user activation browsing context flag set, then return false.
Otherwise, if B is a top-level browsing context, and is neither A nor one of the ancestor browsing contexts of A, and A's Document
's active sandboxing flag set has its sandboxed navigation browsing context flag set, and A is not the one permitted sandboxed navigator of B, then return false.
Return true.
An element has a browsing context scope origin if its Document
's browsing context is a top-level browsing context or if all of its Document
's ancestor browsing contexts all have active documents whose origin are the same origin as the element's node document's origin. If an element has a browsing context scope origin, then its value is the origin of the element's node document.
A user agent holds a browsing context group set (a set of browsing context groups).
A browsing context group holds a browsing context set (a set of top-level browsing contexts).
A browsing context group has an associated agent cluster map (a weak map of agent cluster keys to agent clusters). User agents are responsible for collecting agent clusters when it is deemed that nothing can access them anymore.
To create a new browsing context group, run these steps:
Let group be a new browsing context group.
Append group to the user agent's browsing context group set.
Let browsingContext be the result of creating a new browsing context with null and group.
Append browsingContext to group.
Return group.
To append a top-level browsing context browsingContext to a browsing context group group, run these steps:
Append browsingContext to group's browsing context set.
Set browsingContext's group to group.
To remove a top-level browsing context browsingContext, run these steps:
Assert: browsingContext's group is non-null, because a browsing context only gets discarded once.
Let group be browsingContext's group.
Set browsingContext's group to null.
Remove browsingContext from group's browsing context set.
If group's browsing context set is empty, then remove group from the user agent's browsing context group set.
Append and remove are primitive operations that help define the lifetime of a browsing context group. They are called from creating a new browsing context group, creating a new auxiliary browsing context, and discarding a browsing context.
The HTML Standard used to define "
" and " ". These have been removed as they were not adequate.ブラウジングコンテキストは、ブラウジングコンテキスト名を持つことができる。特に明記しない限り、それは空文字列である。
妥当なブラウジングコンテキスト名は、U+005F LOW LINE文字で始まらない少なくとも1文字をもつ任意の文字列である。(アンダースコアで始まる名前は、特別なキーワードのために予約されている。)
妥当なブラウジングコンテキスト名またはキーワードは、妥当なブラウジングコンテキスト名またはASCII大文字・小文字不区別で_blank
、_self
、_parent
、または_top
の1つにマッチするいずれかとなる任意の文字列である。
これらの値は、以下の(非規範的な)テーブルで要約されるように、ページがサンドボックス化されるかどうかに基づいて異なる意味を持つ。この表において、"current"はリンクまたはスクリプト内にあるブラウジングコンテキストを意味し、"parent"はリンクまたはスクリプト内にあるいずれかの親ブラウジングコンテキストを意味し、"top"はリンクまたはスクリプトがあるいずれかのトップレベルブラウジングコンテキストを意味し、"new"はさまざまなユーザー設定とユーザーエージェントのポリシーに次第で、新しいトップレベルブラウジングコンテキストまたは補助ブラウジングコンテキストが作成されることを意味し、"none"は何も起こらないことを意味し、"maybe new"は"allow-popups
"キーワードはまたsandbox
属性で指定される場合(またはユーザーがサンドボックスを覆う場合)、"new"と同じであり、そうでなければ"none"と同じである。
キーワード | 普通の効果 | iframe での効果 | |
---|---|---|---|
sandbox="" | sandbox="allow-top-navigation" | ||
リンクおよびフォーム送信に対して、何も指定しない | current | current | current |
空文字列 | current | current | current |
_blank | new | maybe new | maybe new |
_self | current | current | current |
親が存在しない場合の_parent | current | current | current |
親がまたトップである場合の_parent | parent/top | none | parent/top |
存在するがトップでない場合の_parent | parent | none | none |
トップが現在である場合の_top | current | current | current |
トップが現在でない場合の_top | top | none | top |
名前が存在しない | new | maybe new | maybe new |
名前が存在しかつ子孫である | specified descendant | specified descendant | specified descendant |
名前が存在し現在である | current | current | current |
名前が存在しかつトップとなる祖先である | specified ancestor | none | specified ancestor/top |
名前が存在しかつトップでない祖先である | specified ancestor | none | none |
他の名前が共通のトップとともに存在する | specified | none | none |
familiarかつある許可されたサンドボックス化されたナビゲーターである場合、異なるトップをもつ名前が存在する | specified | specified | specified |
familiarだがある許可されたサンドボックス化されたナビゲーターでない場合、異なるトップをもつ名前が存在する | specified | none | none |
familiarでない、異なるトップをもつ名前が存在する | new | maybe new | maybe new |
サンドボックス化されたブラウジングコンテキストの制限のほとんどは、他のアルゴリズムにより適用される。たとえば、下記で与えられるブラウジングコンテキスト名で与えられたをブラウジングコンテキストを選択するための規則でなく、ナビゲーションアルゴリズムとして。
The rules for choosing a browsing context, given a browsing context name name, a browsing context current, and a boolean noopener are as follows:
Let chosen be null.
Let new be false.
Let sandboxingFlagSet be current's active document's active sandboxing flag set.
If name is the empty string or an ASCII case-insensitive match for "_self
", then set chosen to current.
Otherwise, if name is an ASCII case-insensitive match for "_parent
", set chosen to current's parent browsing context, if any, and current otherwise.
Otherwise, if name is an ASCII case-insensitive match for "_top
", set chosen to current's top-level browsing context, if any, and current otherwise.
Otherwise, if name is not an ASCII case-insensitive match for "_blank
", there exists a browsing context whose name is the same as name, current is familiar with that browsing context, and the user agent determines that the two browsing contexts are related enough that it is ok if they reach each other, set chosen to that browsing context. If there are multiple matching browsing contexts, the user agent should set chosen to one in some arbitrary consistent manner, such as the most recently opened, most recently focused, or more closely related.
This will be made more precise in issue #313.
Otherwise, a new browsing context is being requested, and what happens depends on the user agent's configuration and abilities — it is determined by the rules given for the first applicable option from the following list:
WindowProxy
's [[Window]] value does not have transient activation and the user agent has been configured to not show popups (i.e. the user agent has a "popup blocker" enabled)The user agent may inform the user that a popup has been blocked.
The user agent may offer the user one of:
Set chosen to the result of creating a new top-level browsing context and set new to true.
Set chosen to an existing top-level browsing context.
If this case occurs, it means that an author has explicitly sandboxed the document that is trying to open a link.
If the user declines or the user agent doesn't offer the above, the variables remain unchanged.
Set new to true.
If noopener is true, then set chosen to the result of creating a new top-level browsing context.
Otherwise:
Set chosen to the result of creating a new auxiliary browsing context with current.
If sandboxingFlagSet's sandboxed navigation browsing context flag is set, then current must be set as chosen's one permitted sandboxed navigator.
If sandboxingFlagSet's sandbox propagates to auxiliary browsing contexts flag is set, then all the flags that are set in sandboxingFlagSet must be set in chosen's popup sandboxing flag set.
If name is not an ASCII case-insensitive match for "_blank
", then set chosen's name to name.
If the newly created browsing context is immediately navigated, then the navigation will be done with replacement enabled.
Set chosen to current.
Do nothing.
User agents are encouraged to provide a way for users to configure the user agent to always reuse current.
Return chosen and new.
Window
, WindowProxy
, and Location
objectsAlthough typically objects cannot be accessed across origins, the web platform would not be true to itself if it did not have some legacy exceptions to that rule that the web depends upon.
When perform a security check is invoked, with a platformObject, identifier, and type, run these steps:
If platformObject is a Window
or Location
object, then:
Repeat for each e that is an element of ! CrossOriginProperties(platformObject):
If SameValue(e.[[Property]], identifier) is true, then:
If type is "method
" and e has neither [[NeedsGet]] nor [[NeedsSet]], then return.
Otherwise, if type is "getter
" and e.[[NeedsGet]] is true, then return.
Otherwise, if type is "setter
" and e.[[NeedsSet]] is true, then return.
If ! IsPlatformObjectSameOrigin(platformObject) is false, then throw a "SecurityError
" DOMException
.
Window
and Location
objects both have a [[CrossOriginPropertyDescriptorMap]] internal slot, whose value is initially an empty map.
The [[CrossOriginPropertyDescriptorMap]] internal slot contains a map with entries whose keys are (currentGlobal, objectGlobal, propertyKey)-tuples and values are property descriptors, as a memoization of what is visible to scripts when currentGlobal inspects a Window
or Location
object from objectGlobal. It is filled lazily by CrossOriginGetOwnPropertyHelper, which consults it on future lookups.
User agents should allow a value held in the map to be garbage collected along with its corresponding key when nothing holds a reference to any part of the value. That is, as long as garbage collection is not observable.
For example, with const href = Object.getOwnPropertyDescriptor(crossOriginLocation, "href").set
the value and its corresponding key in the map cannot be garbage collected as that would be observable.
User agents may have an optimization whereby they remove key-value pairs from the map when document.domain
is set. This is not observable as document.domain
cannot revisit an earlier value.
For example, setting document.domain
to "example.com
" on www.example.com means user agents can remove all key-value pairs from the map where part of the key is www.example.com, as that can never be part of the origin again and therefore the corresponding value could never be retrieved from the map.
If O is a Location
object, then return « { [[Property]]: "href
", [[NeedsGet]]: false, [[NeedsSet]]: true }, { [[Property]]: "replace
" } ».
Let crossOriginWindowProperties be « { [[Property]]: "window
", [[NeedsGet]]: true, [[NeedsSet]]: false }, { [[Property]]: "self
", [[NeedsGet]]: true, [[NeedsSet]]: false }, { [[Property]]: "location
", [[NeedsGet]]: true, [[NeedsSet]]: true }, { [[Property]]: "close
" }, { [[Property]]: "closed
", [[NeedsGet]]: true, [[NeedsSet]]: false }, { [[Property]]: "focus
" }, { [[Property]]: "blur
" }, { [[Property]]: "frames
", [[NeedsGet]]: true, [[NeedsSet]]: false }, { [[Property]]: "length
", [[NeedsGet]]: true, [[NeedsSet]]: false }, { [[Property]]: "top
", [[NeedsGet]]: true, [[NeedsSet]]: false }, { [[Property]]: "opener
", [[NeedsGet]]: true, [[NeedsSet]]: false }, { [[Property]]: "parent
", [[NeedsGet]]: true, [[NeedsSet]]: false }, { [[Property]]: "postMessage
" } ».
Repeat for each e that is an element of O's document-tree child browsing context name property set:
Add { [[Property]]: e, [[HideFromKeys]]: true } as the last element of crossOriginWindowProperties.
Return crossOriginWindowProperties.
Indexed properties do not need to be safelisted as they are handled directly by the WindowProxy
object.
If P is "then
", @@toStringTag, @@hasInstance, or @@isConcatSpreadable, then return PropertyDescriptor{ [[Value]]: undefined, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
Throw a "SecurityError
" DOMException
.
Return true if the current settings object's origin is same origin-domain with O's relevant settings object's origin, and false otherwise.
If this abstract operation returns undefined and there is no custom behavior, the caller needs to throw a "SecurityError
" DOMException
. In practice this is handled by the caller calling CrossOriginPropertyFallback.
Let crossOriginKey be a tuple consisting of the current settings object, O's relevant settings object, and P.
Repeat for each e that is an element of ! CrossOriginProperties(O):
If SameValue(e.[[Property]], P) is true, then:
If the value of the [[CrossOriginPropertyDescriptorMap]] internal slot of O contains an entry whose key is crossOriginKey, then return that entry's value.
Let originalDesc be OrdinaryGetOwnProperty(O, P).
Let crossOriginDesc be undefined.
If e.[[NeedsGet]] and e.[[NeedsSet]] are absent, then:
Let value be originalDesc.[[Value]].
If ! IsCallable(value) is true, then set value to an anonymous built-in function, created in the current Realm Record, that performs the same steps as the IDL operation P on object O.
Set crossOriginDesc to PropertyDescriptor{ [[Value]]: value, [[Enumerable]]: false, [[Writable]]: false, [[Configurable]]: true }.
Otherwise:
Let crossOriginGet be undefined.
If e.[[NeedsGet]] is true, then set crossOriginGet to an anonymous built-in function, created in the current Realm Record, that performs the same steps as the getter of the IDL attribute P on object O.
Let crossOriginSet be undefined.
If e.[[NeedsSet]] is true, then set crossOriginSet to an anonymous built-in function, created in the current Realm Record, that performs the same steps as the setter of the IDL attribute P on object O.
Set crossOriginDesc to PropertyDescriptor{ [[Get]]: crossOriginGet, [[Set]]: crossOriginSet, [[Enumerable]]: false, [[Configurable]]: true }.
Create an entry in the value of the [[CrossOriginPropertyDescriptorMap]] internal slot of O with key crossOriginKey and value crossOriginDesc.
Return crossOriginDesc.
Return undefined.
The reason that the property descriptors produced here are configurable is to preserve the invariants of the essential internal methods required by the JavaScript specification. In particular, since the value of the property can change as a consequence of navigation, it is required that the property be configurable. (However, see tc39/ecma262 issue #672 and references to it elsewhere in this specification for cases where we are not able to preserve these invariants, for compatibility with existing Web content.) [JAVASCRIPT]
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.
Let desc be ? O.[[GetOwnProperty]](P).
Assert: desc is not undefined.
If ! IsDataDescriptor(desc) is true, then return desc.[[Value]].
Assert: IsAccessorDescriptor(desc) is true.
Let getter be desc.[[Get]].
If getter is undefined, then throw a "SecurityError
" DOMException
.
Return ? Call(getter, Receiver).
Let desc be ? O.[[GetOwnProperty]](P).
Assert: desc is not undefined.
If desc.[[Set]] is present and its value is not undefined, then:
Perform ? Call(setter, Receiver, «V»).
Return true.
Throw a "SecurityError
" DOMException
.
Let keys be a new empty List.
Repeat for each e that is an element of ! CrossOriginProperties(O):
If e.[[HideFromKeys]] is not true, append e.[[Property]] to keys.
If keys does not contain "then
", then append "then
" to keys.
Return the concatenation of keys and « @@toStringTag, @@hasInstance, @@isConcatSpreadable ».