* 仕様書

[REFS[
- [14] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2016-05-03 13:56:46 +09:00]]) <https://html.spec.whatwg.org/#realms-settings-objects-global-objects>
-- [6] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2016-01-21 11:56:00 +09:00]] 版) <https://html.spec.whatwg.org/#environment-settings-object's-realm>
-- [12] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2016-03-27 03:13:07 +09:00]] 版) <https://html.spec.whatwg.org/#concept-global-object-realm>
]REFS]

* 状態

[11] 
[FIG(list members)[
: [F(ss)[GlobalObject]] :
[[大域オブジェクト]]です。
: [F(ss)[HostDefined]] :
[[Web]] では、[F[設定群オブジェクト]]です。
]FIG]

* [F[Realm]]

[13] [DFN[[RUBYB[大域オブジェクトの [F[Realm]]]@en[the global object's [F[Realm]]]]]]
[SRC[>>12]] は、その[[大域オブジェクト]]に対応する [[Realm]] です。
両者には1:1の対応関係があります。当該 [[Realm]] の初期化時に[[大域オブジェクト]]が作成されていて、
以後変化しません。

[7] [[環境設定群オブジェクト]]の [DFN[[F[Realm]]]] は、
[[環境設定群オブジェクト]]の[F[realm実行文脈]]の[F[Realm]] です [SRC[>>6]]。

* 作成

[23] 
[DFN[[RUBY[新しいJavaScript realmを作成]@en[create a new JavaScript realm]]]]するには、
[VAR[[[大域オブジェクト]]]]と[VAR[大域[CODE[this]]束縛]]について、
次のようにします [SRC[[CITE[HTML Standard]]]]。 

[FIG(steps)[
= [24] 
[VAR[大域オブジェクト]]と[VAR[大域[CODE[this]]束縛]]について、
[CODE[InitializeHostDefinedRealm]] 
を実行します。
= [25] 
[VAR[realm実行文脈]]を、
[[走っているJavaScript実行文脈]]に設定します。
= [26] 
[VAR[realm実行文脈]]を、
[[JavaScript実行文脈スタック]]から削除します。
= [27] 
[VAR[realm実行文脈]]を返します。
]FIG]

* 関連

[10] [[Web]] においては、 [[Realm]]、[[大域オブジェクト]]、[[環境設定群オブジェクト]]に
1:1:1 対応関係が常に成立します。

[98] [[入口Realm]]、[[現職Realm]]、[[現在Realm]]、[[関連Realm]]については、
[[設定群オブジェクト]]を参照。

* 歴史

[1] [CITE@en[Bug 26603 – Consider merging the concept of incumbent global with the current realm]]
( ([TIME[2014-08-19 08:44:57 +09:00]] 版))
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=26603>

[2] [CITE@en[Bug 24652 – Deal with associated global / Realm]]
([TIME[2015-03-31 11:23:51 +09:00]] 版)
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=24652>

[35] [CITE@en[Bug 3138 – Realm initialisation for Web browsers]]
( ([TIME[2014-09-13 00:50:54 +09:00]] 版))
<https://bugs.ecmascript.org/show_bug.cgi?id=3138>

[3] [CITE@en[Fix refs to some terms from the ES spec · whatwg/html@40295ff]] ([TIME[2015-12-21 11:37:11 +09:00]] 版) <https://github.com/whatwg/html/commit/40295ff11d8f2629a8eeb4b31d64ae0679ad741f>

[4] [CITE@en[26603 – Consider merging the concept of incumbent global with the current realm]]
([TIME[2015-12-22 23:39:43 +09:00]] 版)
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=26603>

[5] [CITE@en[Add <script type="module"> and module resolution/fetching/evaluation · whatwg/html@cd1a9fb]] ([TIME[2016-01-21 23:26:55 +09:00]] 版) <https://github.com/whatwg/html/commit/cd1a9fb1e83f7d0bc30be8b34ecdaf444a0b19a4>

[8] [CITE@en[24318 – Define the Realm of objects]]
([TIME[2016-03-15 11:58:01 +09:00]] 版)
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=24318>

[9] [CITE@en[Clarify settings object, realm, and global relationships · whatwg/html@0866f1b]]
([TIME[2016-03-27 23:11:13 +09:00]] 版)
<https://github.com/whatwg/html/commit/0866f1b3f4b4ea5a99a30909e9bbe557dea0b460>

[15] [CITE@en[Merge pull request #113 from domenic/modernize-invoke]]
( ([[bzbarsky]]著, [TIME[2016-05-21 05:55:00 +09:00]]))
<https://github.com/heycam/webidl/commit/09c011d8de1077fe5991ceded97838650e376f6c>

[16] [CITE@en[Formalize '''[''''''['''Realm''']'''''']''' internal slot of ordinary objects · Issue #573 · tc39/ecma262]]
( ([TIME[2016-06-07 10:20:03 +09:00]]))
<https://github.com/tc39/ecma262/issues/573>

[17] [CITE@en[Add a new section detailing the various potential realms]]
([[domenic]]著, [TIME[2016-05-03 06:09:12 +09:00]])
<https://github.com/whatwg/html/commit/6399af334edd6000bd394685923df5f0519194ab>

[18] [CITE@en[Use the relevant realm of the event target when firing an event]]
([[domenic]]著, [TIME[2016-10-28 02:24:52 +09:00]])
<https://github.com/whatwg/dom/commit/5f39374c6f1d7893ece8101b083b8f6ccf8d1d72>

[19] [CITE@en[Event handlers are not compiled against the right global, per spec · Issue #1956 · whatwg/html]]
([TIME[2016-11-02 20:43:37 +09:00]])
<https://github.com/whatwg/html/issues/1956>

[20] [CITE@en[Specify the realm for the SSE MessageEvent]]
([[domenic]]著, [TIME[2016-10-28 02:17:38 +09:00]])
<https://github.com/whatwg/html/commit/91d19d647433203f1f319e2afe76e63ceae646ca>

[21] [CITE@en[Creating a %TypedArray% instance in a different realm · Issue #418 · tc39/ecma262]]
([TIME[2017-04-19 20:26:35 +09:00]])
<https://github.com/tc39/ecma262/issues/418>

[22] [CITE@en[Fix calls to InitializeHostDefinedRealm]]
([[TimothyGu]]著, [TIME[2018-07-29 04:10:47 +09:00]])
<https://github.com/whatwg/html/commit/39c948ba5ec55677e209bc4fc631636f1e8e2baf>

[28] [CITE@en[Pop execution context off the stack after InitializeHostDefinedRealm · Issue #3784 · whatwg/html]]
([TIME[2018-07-30 17:44:53 +09:00]])
<https://github.com/whatwg/html/issues/3784>

[29] [CITE@en[Fix calls to InitializeHostDefinedRealm by TimothyGu · Pull Request #3838 · whatwg/html]]
([TIME[2018-07-30 17:45:34 +09:00]])
<https://github.com/whatwg/html/pull/3838>

[30] [CITE@en[document.open() simplifications, part 1]]
([[TimothyGu]]著, [TIME[2018-08-17 07:20:44 +09:00]])
<https://github.com/whatwg/html/commit/6f769b8089a843066aa19f5991405bf4c84458b3>

[31] [CITE@en[Calling InitializeHostDefinedRealm in document.open is probably unnecessary · Issue #1698 · whatwg/html]]
([TIME[2018-08-23 20:15:44 +09:00]])
<https://github.com/whatwg/html/issues/1698>

[32] [CITE@en[document.open() simplifications: realm creation, unloading, tasks removal by TimothyGu · Pull Request #3918 · whatwg/html]]
([TIME[2018-08-23 20:19:14 +09:00]])
<https://github.com/whatwg/html/pull/3918>

[33] [CITE@en[Formally define a '''[''''''['''Realm''']'''''']''' slot on platform objects]]
([[Ms2ger]]著, [TIME[2019-02-22 19:45:37 +09:00]])
<https://github.com/heycam/webidl/commit/c705ce6ce80f0313e323ee024cb13984a538b55b>

[34] [CITE@en[Formally define a '''[''''''['''Realm''']'''''']''' slot on platform objects by Ms2ger · Pull Request #658 · heycam/webidl]]
([TIME[2019-06-21 17:16:23 +09:00]])
<https://github.com/heycam/webidl/pull/658>

[36] [CITE@en[Remove references to ECMAScript global environments]]
([[Ms2ger]]著, [TIME[2019-03-08 02:16:38 +09:00]])
<https://github.com/heycam/webidl/commit/b4f9467f5f22871d882d833c3526c46007048982>

[37] [CITE@en[Remove references to ECMAScript global environments by Ms2ger · Pull Request #681 · heycam/webidl]]
([TIME[2019-07-22 11:53:16 +09:00]])
<https://github.com/heycam/webidl/pull/681>