-
Notifications
You must be signed in to change notification settings - Fork 17
/
index.html
122 lines (80 loc) · 27.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!doctype html>
<head><meta charset="utf-8">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
<script src="https://bterlson.github.io/ecmarkup/ecmarkup.js"></script>
<link rel="stylesheet" href="https://bterlson.github.io/ecmarkup/elements.css">
<title>ECMAScript Frozen Realms Spec Proposal</title><script type="application/json" id="menu-search-biblio">[{"type":"clause","id":"sec-realms-objects","aoid":null,"title":"Realms Objects","number":"1","namespace":"https://rawgit.com/FUDCo/frozen-realms/master/index.html","location":"","key":"Realms Objects"},{"type":"clause","id":"sec-realms-abstracts","aoid":null,"title":"Abstract Operations","number":"1.1","namespace":"https://rawgit.com/FUDCo/frozen-realms/master/index.html","location":"","key":"Abstract Operations"},{"type":"op","aoid":"SetSpawnGlobalBindings","refId":"sec-setspawnglobalbindings","location":"","key":"SetSpawnGlobalBindings"},{"type":"clause","id":"sec-setspawnglobalbindings","aoid":"SetSpawnGlobalBindings","title":"SetSpawnGlobalBindings ( _realmRec_, _globalNames_ )","number":"1.1.1","namespace":"https://rawgit.com/FUDCo/frozen-realms/master/index.html","location":"","key":"SetSpawnGlobalBindings ( _realmRec_, _globalNames_ )"},{"type":"op","aoid":"CreateSpawnIntrinsics","refId":"sec-createspawnintrinsics","location":"","key":"CreateSpawnIntrinsics"},{"type":"clause","id":"sec-createspawnintrinsics","aoid":"CreateSpawnIntrinsics","title":"CreateSpawnIntrinsics ( _realmRec_, _parentIntrinsics_, _freshIntrinsicNames_ )","number":"1.1.2","namespace":"https://rawgit.com/FUDCo/frozen-realms/master/index.html","location":"","key":"CreateSpawnIntrinsics ( _realmRec_, _parentIntrinsics_, _freshIntrinsicNames_ )"},{"type":"op","aoid":"CreateSpawnRealm","refId":"sec-createspawnrealm","location":"","key":"CreateSpawnRealm"},{"type":"clause","id":"sec-createspawnrealm","aoid":"CreateSpawnRealm","title":"CreateSpawnRealm ( _parentRealmRec_ )","number":"1.1.3","namespace":"https://rawgit.com/FUDCo/frozen-realms/master/index.html","location":"","key":"CreateSpawnRealm ( _parentRealmRec_ )"},{"type":"op","aoid":"SetFrozenGlobalBindings","refId":"sec-setfrozenglobalbindings","location":"","key":"SetFrozenGlobalBindings"},{"type":"clause","id":"sec-setfrozenglobalbindings","aoid":"SetFrozenGlobalBindings","title":"SetFrozenGlobalBindings ( _realmRec_ )","number":"1.1.4","namespace":"https://rawgit.com/FUDCo/frozen-realms/master/index.html","location":"","key":"SetFrozenGlobalBindings ( _realmRec_ )"},{"type":"op","aoid":"FreezeRealmIntrinsics","refId":"sec-freezerealmintrinsics","location":"","key":"FreezeRealmIntrinsics"},{"type":"clause","id":"sec-freezerealmintrinsics","aoid":"FreezeRealmIntrinsics","title":"FreezeRealmIntrinsics ( _realmRec_ )","number":"1.1.5","namespace":"https://rawgit.com/FUDCo/frozen-realms/master/index.html","location":"","key":"FreezeRealmIntrinsics ( _realmRec_ )"},{"type":"clause","id":"sec-properties-of-the-realm-constructor","aoid":null,"title":"Properties of the Realm Constructor","number":"1.2","namespace":"https://rawgit.com/FUDCo/frozen-realms/master/index.html","location":"","key":"Properties of the Realm Constructor"},{"type":"clause","id":"sec-realm.immutableroot","aoid":null,"title":"Realm.immutableRoot ()","number":"1.2.1","namespace":"https://rawgit.com/FUDCo/frozen-realms/master/index.html","location":"","key":"Realm.immutableRoot ()"},{"type":"clause","id":"sec-properties-of-the-realm-prototype-object","aoid":null,"title":"Properties of the Realm Prototype Object","number":"1.3","namespace":"https://rawgit.com/FUDCo/frozen-realms/master/index.html","location":"","key":"Properties of the Realm Prototype Object"},{"type":"clause","id":"sec-realm-prototype-spawn","aoid":null,"title":"Realm.prototype.spawn ([ _endowments_ ])","number":"1.3.1","namespace":"https://rawgit.com/FUDCo/frozen-realms/master/index.html","location":"","key":"Realm.prototype.spawn ([ _endowments_ ])"}]</script></head><body><div id="menu-toggle">☰</div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle">◢</span><a href="#sec-realms-objects" title="Realms Objects"><span class="secnum">1</span> Realms Objects</a><ol class="toc"><li><span class="item-toggle">◢</span><a href="#sec-realms-abstracts" title="Abstract Operations"><span class="secnum">1.1</span> Abstract Operations</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-setspawnglobalbindings" title="SetSpawnGlobalBindings ( _realmRec_, _globalNames_ )"><span class="secnum">1.1.1</span> SetSpawnGlobalBindings ( <var>realmRec</var>, <var>globalNames</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-createspawnintrinsics" title="CreateSpawnIntrinsics ( _realmRec_, _parentIntrinsics_, _freshIntrinsicNames_ )"><span class="secnum">1.1.2</span> CreateSpawnIntrinsics ( <var>realmRec</var>, <var>parentIntrinsics</var>, <var>freshIntrinsicNames</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-createspawnrealm" title="CreateSpawnRealm ( _parentRealmRec_ )"><span class="secnum">1.1.3</span> CreateSpawnRealm ( <var>parentRealmRec</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-setfrozenglobalbindings" title="SetFrozenGlobalBindings ( _realmRec_ )"><span class="secnum">1.1.4</span> SetFrozenGlobalBindings ( <var>realmRec</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-freezerealmintrinsics" title="FreezeRealmIntrinsics ( _realmRec_ )"><span class="secnum">1.1.5</span> FreezeRealmIntrinsics ( <var>realmRec</var> )</a></li></ol></li><li><span class="item-toggle">◢</span><a href="#sec-properties-of-the-realm-constructor" title="Properties of the Realm Constructor"><span class="secnum">1.2</span> Properties of the Realm Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-realm.immutableroot" title="Realm.immutableRoot ()"><span class="secnum">1.2.1</span> Realm.immutableRoot ()</a></li></ol></li><li><span class="item-toggle">◢</span><a href="#sec-properties-of-the-realm-prototype-object" title="Properties of the Realm Prototype Object"><span class="secnum">1.3</span> Properties of the Realm Prototype Object</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-realm-prototype-spawn" title="Realm.prototype.spawn ([ _endowments_ ])"><span class="secnum">1.3.1</span> Realm.prototype.spawn ([ <var>endowments</var> ])</a></li></ol></li></ol></li></ol></div></div><h1 class="version">May 11, 2016</h1><h1 class="title">ECMAScript Frozen Realms Spec Proposal</h1>
<emu-clause id="sec-realms-objects">
<h1><span class="secnum">1</span>Realms Objects<span class="utils"><span class="anchor"><a href="#sec-realms-objects">#</a></span></span></h1>
<emu-note><span class="note">Note</span>
<emu-val>IMPORTANT</emu-val> this section references the <emu-xref href="#realm"><a href="https://tc39.github.io/ecma262/#realm">Realm</a></emu-xref> API <a href="https://github.com/caridy/proposal-realms">spec proposal</a>, specifically, it adds new capabilities to the <emu-xref href="#realm"><a href="https://tc39.github.io/ecma262/#realm">Realm</a></emu-xref> Objects.
</emu-note>
<emu-clause id="sec-realms-abstracts">
<h1><span class="secnum">1.1</span>Abstract Operations<span class="utils"><span class="anchor"><a href="#sec-realms-abstracts">#</a></span></span></h1>
<emu-clause id="sec-setspawnglobalbindings" aoid="SetSpawnGlobalBindings">
<h1><span class="secnum">1.1.1</span>SetSpawnGlobalBindings ( <var>realmRec</var>, <var>globalNames</var> )<span class="utils"><span class="anchor"><a href="#sec-setspawnglobalbindings">#</a></span></span></h1>
<p>The abstract operation SetSpawnGlobalBindings with arguments <var>realmRec</var>, and <var>globalNames</var> performs the following steps:</p>
<emu-alg><ol><li>Assert: <var>realmRec</var> is a <emu-xref href="#realm-record"><a href="https://tc39.github.io/ecma262/#realm-record">Realm Record</a></emu-xref>.</li><li>Assert: <var>globalNames</var> is a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.github.io/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Let <var>global</var> be <var>realmRec</var>.[[GlobalObject]].</li><li>For each element <var>name</var> of <var>globalNames</var> in <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.github.io/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> order,<ol><li>Assert: <var>name</var> is specified as a Global Object in clause <emu-xref href="#sec-global-object"><a href="https://tc39.github.io/ecma262/#sec-global-object">18</a></emu-xref>.</li><li>Let <var>desc</var> be the fully populated data property descriptor for the property containing the specified attributes for the Global Object denoted by <var>name</var>. For those listed in <emu-xref href="#sec-function-properties-of-the-global-object"><a href="https://tc39.github.io/ecma262/#sec-function-properties-of-the-global-object">18.2</a></emu-xref>, <emu-xref href="#sec-constructor-properties-of-the-global-object"><a href="https://tc39.github.io/ecma262/#sec-constructor-properties-of-the-global-object">18.3</a></emu-xref>, or <emu-xref href="#sec-other-properties-of-the-global-object"><a href="https://tc39.github.io/ecma262/#sec-other-properties-of-the-global-object">18.4</a></emu-xref> the value of the [[Value]] attribute is the corresponding intrinsic object from <var>realmRec</var>.</li><li>Perform ? <emu-xref aoid="DefinePropertyOrThrow"><a href="https://tc39.github.io/ecma262/#sec-definepropertyorthrow">DefinePropertyOrThrow</a></emu-xref>(<var>global</var>, <var>name</var>, <var>desc</var>).</li></ol></li><li>Return <var>global</var>.
</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-createspawnintrinsics" aoid="CreateSpawnIntrinsics">
<h1><span class="secnum">1.1.2</span>CreateSpawnIntrinsics ( <var>realmRec</var>, <var>parentIntrinsics</var>, <var>freshIntrinsicNames</var> )<span class="utils"><span class="anchor"><a href="#sec-createspawnintrinsics">#</a></span></span></h1>
<p>The abstract operation CreateSpawnIntrinsics with arguments <var>realmRec</var>, <var>parentIntrinsics</var>, and <var>intrinsicNames</var> performs the following steps:</p>
<emu-alg><ol><li>Assert: <var>realmRec</var> is a <emu-xref href="#realm-record"><a href="https://tc39.github.io/ecma262/#realm-record">Realm Record</a></emu-xref>.</li><li>Assert: <var>parentIntrinsics</var> is a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.github.io/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref>.</li><li>Assert: <var>freshIntrinsicNames</var> is a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.github.io/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Let <var>intrinsics</var> be a new <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.github.io/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref>.</li><li>Set <var>realmRec</var>.[[Intrinsics]] to <var>intrinsics</var>.</li><li>For each <var>name</var> listed in column one of <emu-xref href="#table-7"><a href="https://tc39.github.io/ecma262/#table-7">Table 7</a></emu-xref>,<ol><li>If <var>freshIntrinsicNames</var> contains the value of <var>name</var>, then<ol><li>Let <var>O</var> be a new object value fully and recursively populated with property values as defined by the specification of each object in clauses 18-26. All object property values are newly created object values. All values that are built-in function objects are created by performing <emu-xref aoid="CreateBuiltinFunction"><a href="https://tc39.github.io/ecma262/#sec-createbuiltinfunction">CreateBuiltinFunction</a></emu-xref>(<var>realmRec</var>, <steps>, <prototype>, <slots>) where <steps> is the definition of that function provided by this specification, <prototype> is the specified value of the function's [[Prototype]] internal slot and <slots> is a list of the names, if any, of the function's specified internal slots.</li></ol></li><li>Else,<ol><li>Let <var>O</var> be the value corresponding to the field name denoted by <var>name</var> from <var>parentIntrinsics</var> record.</li></ol></li><li>Set field of <var>intrinsics</var> whose field name is <var>name</var> and value is <var>O</var>.</li></ol></li><li>Return <var>intrinsics</var>.
</li></ol></emu-alg>
<emu-note><span class="note">Note</span>
<p>The creation of the intrinsics and their properties must be ordered to avoid any dependencies upon objects that have not yet been created.</p>
</emu-note>
</emu-clause>
<emu-clause id="sec-createspawnrealm" aoid="CreateSpawnRealm">
<h1><span class="secnum">1.1.3</span>CreateSpawnRealm ( <var>parentRealmRec</var> )<span class="utils"><span class="anchor"><a href="#sec-createspawnrealm">#</a></span></span></h1>
The abstract operation <emu-val>CreateSpawnRealm</emu-val> with argument <var>parentRealmRec</var> performs the following steps:
<emu-alg><ol><li>Assert: <var>parentRealmRec</var> is a <emu-xref href="#realm-record"><a href="https://tc39.github.io/ecma262/#realm-record">Realm Record</a></emu-xref>.</li><li>Let <var>realmRec</var> be a new <emu-xref href="#realm-record"><a href="https://tc39.github.io/ecma262/#realm-record">Realm Record</a></emu-xref>.</li><li>Let <var>intrinsics</var> be ! <emu-xref aoid="CreateSpawnIntrinsics"><a href="#sec-createspawnintrinsics">CreateSpawnIntrinsics</a></emu-xref>(<var>realmRec</var>, <var>parentRealmRec</var>.[[Intrinsics]], « <emu-val>"<emu-xref href="#sec-eval-x"><a href="https://tc39.github.io/ecma262/#sec-eval-x">%eval%</a></emu-xref>"</emu-val>, <emu-val>"<emu-xref href="#sec-function-constructor"><a href="https://tc39.github.io/ecma262/#sec-function-constructor">%Function%</a></emu-xref>"</emu-val> »).</li><li>Set <var>realmRec</var>.[[Intrinsics]] to <var>intrinsics</var>.</li><li>Set realmRec.[[TemplateMap]] to a new empty <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.github.io/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Let <var>freshObject</var> to <emu-xref aoid="ObjectCreate"><a href="https://tc39.github.io/ecma262/#sec-objectcreate">ObjectCreate</a></emu-xref>(<var>parentRealmRec</var>.[[GlobalObject]]).</li><li>Perform ? <emu-xref aoid="SetRealmGlobalObject"><a href="https://tc39.github.io/ecma262/#sec-setrealmglobalobject">SetRealmGlobalObject</a></emu-xref>(<var>realmRec</var>, <var>freshObject</var>, <emu-val>undefined</emu-val>).</li><li>Perform ? <emu-xref aoid="SetSpawnGlobalBindings"><a href="#sec-setspawnglobalbindings">SetSpawnGlobalBindings</a></emu-xref>(<var>realmRec</var>, « <emu-val>"eval"</emu-val>, <emu-val>"Function"</emu-val> »).</li><li>Return <var>realmRec</var>.
</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-setfrozenglobalbindings" aoid="SetFrozenGlobalBindings">
<h1><span class="secnum">1.1.4</span>SetFrozenGlobalBindings ( <var>realmRec</var> )<span class="utils"><span class="anchor"><a href="#sec-setfrozenglobalbindings">#</a></span></span></h1>
The abstract operation <emu-val>SetFrozenGlobalBindings</emu-val> with argument <var>realmRec</var> performs the following steps:
<emu-alg><ol><li>Assert: <var>realmRec</var> is a <emu-xref href="#realm-record"><a href="https://tc39.github.io/ecma262/#realm-record">Realm Record</a></emu-xref>.</li><li>Let <var>global</var> be <var>realmRec</var>.[[GlobalObject]].</li><li>For each property of the Global Object specified in clause <emu-xref href="#sec-global-object"><a href="https://tc39.github.io/ecma262/#sec-global-object">18</a></emu-xref>, do<ol><li>Let <var>name</var> be the String value of the property name.</li><li>Let <var>desc</var> be the fully populated data property descriptor for the immutable property containing the specified attributes for the property. For properties listed in <emu-xref href="#sec-function-properties-of-the-global-object"><a href="https://tc39.github.io/ecma262/#sec-function-properties-of-the-global-object">18.2</a></emu-xref>, <emu-xref href="#sec-constructor-properties-of-the-global-object"><a href="https://tc39.github.io/ecma262/#sec-constructor-properties-of-the-global-object">18.3</a></emu-xref>, or <emu-xref href="#sec-other-properties-of-the-global-object"><a href="https://tc39.github.io/ecma262/#sec-other-properties-of-the-global-object">18.4</a></emu-xref> the value of the [[Value]] attribute is the corresponding intrinsic object from <var>realmRec</var>.</li><li>Perform ? <emu-xref aoid="DefinePropertyOrThrow"><a href="https://tc39.github.io/ecma262/#sec-definepropertyorthrow">DefinePropertyOrThrow</a></emu-xref>(<var>global</var>, <var>name</var>, <var>desc</var>).</li></ol></li><li>Return <var>global</var>.
</li></ol></emu-alg>
<emu-note><span class="note">Note</span>
These primordials include <emu-val>all</emu-val> the primordials defined as mandatory in ES2017. These primordials must include no other objects or properties beyond those specified here.
</emu-note>
</emu-clause>
<emu-clause id="sec-freezerealmintrinsics" aoid="FreezeRealmIntrinsics">
<h1><span class="secnum">1.1.5</span>FreezeRealmIntrinsics ( <var>realmRec</var> )<span class="utils"><span class="anchor"><a href="#sec-freezerealmintrinsics">#</a></span></span></h1>
The abstract operation <emu-val>FreezeRealmIntrinsics</emu-val> with argument <var>realmRec</var> performs the following steps:
<emu-alg><ol><li>Assert: <var>realmRec</var> is a <emu-xref href="#realm-record"><a href="https://tc39.github.io/ecma262/#realm-record">Realm Record</a></emu-xref>.</li><li>Let <var>intrinsics</var> be <var><emu-xref href="#realm"><a href="https://tc39.github.io/ecma262/#realm">realm</a></emu-xref></var>.[[Intrinsics]].</li><li>Let <var>DatePrototype</var> be <var>intrinsics</var>.[[<emu-xref href="#sec-properties-of-the-date-prototype-object"><a href="https://tc39.github.io/ecma262/#sec-properties-of-the-date-prototype-object">%DatePrototype%</a></emu-xref>]].</li><li>Perform ? <emu-xref aoid="CreateMethodProperty"><a href="https://tc39.github.io/ecma262/#sec-createmethodproperty">CreateMethodProperty</a></emu-xref> (<var>DatePrototype</var>, <emu-val>"now"</emu-val>, <emu-val>undefined</emu-val>).</li><li>Let <var>Math</var> be <var>intrinsics</var>.[[<emu-xref href="#sec-math-object"><a href="https://tc39.github.io/ecma262/#sec-math-object">%Math%</a></emu-xref>]].</li><li>Perform ? <emu-xref aoid="CreateMethodProperty"><a href="https://tc39.github.io/ecma262/#sec-createmethodproperty">CreateMethodProperty</a></emu-xref> (<var>Math</var>, <emu-val>"random"</emu-val>, <emu-val>undefined</emu-val>).</li><li>For each <var>value</var> corresponding to a field name in <var>intrinsics</var>, do:<ol><li>Perform ? <emu-xref aoid="SetIntegrityLevel"><a href="https://tc39.github.io/ecma262/#sec-setintegritylevel">SetIntegrityLevel</a></emu-xref>(<var>value</var>, "frozen") and make the <var>value</var> object transitively immutable.</li></ol></li><li>Return <var>intrinsics</var>.
</li></ol></emu-alg>
<emu-note><span class="note">Note</span>
In order to attain the necessary deep immutability of an immutable root <emu-xref href="#realm"><a href="https://tc39.github.io/ecma262/#realm">realm</a></emu-xref>, two of its primordials must be modified from the existing standard: An immutable root <emu-xref href="#realm"><a href="https://tc39.github.io/ecma262/#realm">realm</a></emu-xref>'s <code>Date</code> object has its <code>now()</code> method removed and the Date Constructor should throw a <code>TypeError</code> when called as a constructor or a function, rather than reveal the current time. An immutable root <emu-xref href="#realm"><a href="https://tc39.github.io/ecma262/#realm">realm</a></emu-xref>'s <code>Math</code> object has its <code>random()</code> method removed.
</emu-note>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-the-realm-constructor">
<h1><span class="secnum">1.2</span>Properties of the Realm Constructor<span class="utils"><span class="anchor"><a href="#sec-properties-of-the-realm-constructor">#</a></span></span></h1>
The value of the [[Prototype]] internal slot of the <emu-val><emu-xref href="#realm"><a href="https://tc39.github.io/ecma262/#realm">Realm</a></emu-xref></emu-val> constructor is the intrinsic object <emu-xref href="#sec-properties-of-the-function-constructor"><a href="https://tc39.github.io/ecma262/#sec-properties-of-the-function-constructor">%FunctionPrototype%</a></emu-xref>.
<emu-clause id="sec-realm.immutableroot">
<h1><span class="secnum">1.2.1</span>Realm.immutableRoot ()<span class="utils"><span class="anchor"><a href="#sec-realm.immutableroot">#</a></span></span></h1>
When the <emu-val>Realm.immutableRoot</emu-val> function is called with no arguments, the following steps are taken:
<emu-alg><ol><li>If NewTarget is <emu-val>undefined</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>O</var> be ? <emu-xref aoid="OrdinaryCreateFromConstructor"><a href="https://tc39.github.io/ecma262/#sec-ordinarycreatefromconstructor">OrdinaryCreateFromConstructor</a></emu-xref>(NewTarget, "%RealmPrototype%", « [[Realm]] »).</li><li>Let <var>realmRec</var> be <emu-xref aoid="CreateRealm"><a href="https://tc39.github.io/ecma262/#sec-createrealm">CreateRealm</a></emu-xref>().</li><li>Set <var>O</var>'s [[Realm]] internal slot to <var>realmRec</var>.</li><li>Perform ? ExtractRealmMethods(<var>O</var>).</li><li>Perform ? <emu-xref aoid="SetRealmGlobalObject"><a href="https://tc39.github.io/ecma262/#sec-setrealmglobalobject">SetRealmGlobalObject</a></emu-xref>(<var>realmRec</var>, <emu-val>undefined</emu-val>, <emu-val>undefined</emu-val>).</li><li>Perform ? <emu-xref aoid="FreezeRealmIntrinsics"><a href="#sec-freezerealmintrinsics">FreezeRealmIntrinsics</a></emu-xref>(<var>realmRec</var>).</li><li>Let <var>globalObject</var> be ? <emu-xref aoid="SetFrozenGlobalBindings"><a href="#sec-setfrozenglobalbindings">SetFrozenGlobalBindings</a></emu-xref>(<var>realmRec</var>).</li><li>Perform ? <emu-xref aoid="SetIntegrityLevel"><a href="https://tc39.github.io/ecma262/#sec-setintegritylevel">SetIntegrityLevel</a></emu-xref>(<var>globalObject</var>, "frozen").</li><li>Return <var>O</var>.
</li></ol></emu-alg>
<emu-note><span class="note">Note 1</span>
<code>Realm.immutableRoot()</code> obtains an <def>immutable root <emu-xref href="#realm"><a href="https://tc39.github.io/ecma262/#realm">realm</a></emu-xref></def> in which all primordials are already transitively immutable. These primordials must include no other objects or properties beyond those specified here. In an immutable root <emu-xref href="#realm"><a href="https://tc39.github.io/ecma262/#realm">realm</a></emu-xref> the <emu-xref href="#global-object"><a href="https://tc39.github.io/ecma262/#global-object">global object</a></emu-xref> itself is also transitively immutable. Specifically, it contains no host-specific objects. This frozen <emu-xref href="#global-object"><a href="https://tc39.github.io/ecma262/#global-object">global object</a></emu-xref> is a plain object whose <code>[[Prototype]]</code> is <code>Object.prototype</code>, i.e., the <code>%ObjectPrototype%</code> intrinsic of that immutable root <emu-xref href="#realm"><a href="https://tc39.github.io/ecma262/#realm">realm</a></emu-xref>.
</emu-note>
<emu-note><span class="note">Note 2</span>
Since two immutable root realms are forever the same in all ways except object identity, we leave it implementation-defined whether <code>Realm.immutableRoot()</code> always creates a fresh one, or always returns the same one. On any given implementation, it must either be always fresh or always the same.
</emu-note>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-the-realm-prototype-object">
<h1><span class="secnum">1.3</span>Properties of the Realm Prototype Object<span class="utils"><span class="anchor"><a href="#sec-properties-of-the-realm-prototype-object">#</a></span></span></h1>
<emu-clause id="sec-realm-prototype-spawn">
<h1><span class="secnum">1.3.1</span>Realm.prototype.spawn ([ <var>endowments</var> ])<span class="utils"><span class="anchor"><a href="#sec-realm-prototype-spawn">#</a></span></span></h1>
When the <emu-val>Realm.prototype.spawn</emu-val> function is called with optional argument <var>endowments</var>, the following steps are taken:
<emu-alg><ol><li>Let <var>parent</var> be <emu-val>this</emu-val> value.</li><li>If <emu-xref aoid="Type"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>parent</var>) is not Object, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>parent</var> is not an instance of a concrete instance of <emu-xref href="#realm"><a href="https://tc39.github.io/ecma262/#realm">Realm</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>O</var> be ? <emu-xref aoid="ObjectCreate"><a href="https://tc39.github.io/ecma262/#sec-objectcreate">ObjectCreate</a></emu-xref>(<var>parent</var>, « [[Realm]] »).</li><li>Let <var>realmRec</var> be ? <emu-xref aoid="CreateSpawnRealm"><a href="#sec-createspawnrealm">CreateSpawnRealm</a></emu-xref>(<var>parent</var>.[[Realm]]).</li><li>Set <var>O</var>'s [[Realm]] internal slot to <var>realmRec</var>.</li><li>If <var>endowments</var> is provided, then<ol><li>If <emu-xref aoid="Type"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>endowments</var>) is not an Object, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>globalObject</var> be <var>realmRec</var>.[[GlobalObject]].</li><li>Let <var>props</var> be ? <emu-xref aoid="ToObject"><a href="https://tc39.github.io/ecma262/#sec-toobject">ToObject</a></emu-xref>(<var>endowments</var>).</li><li>Let <var>keys</var> be ? <var>props</var>.[[OwnPropertyKeys]]().</li><li>Repeat for each element <var>propName</var> of keys in <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.github.io/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> order,<ol><li>Let <var>propDesc</var> be ? <var>props</var>.[[GetOwnProperty]](<var>propName</var>).</li><li>If <var>propDesc</var> is not <emu-val>undefined</emu-val> and <var>propDesc</var>.[[Enumerable]] is <emu-val>true</emu-val>, then<ol><li>Let <var>propValue</var> be ? <emu-xref aoid="Get"><a href="https://tc39.github.io/ecma262/#sec-get-o-p">Get</a></emu-xref>(<var>props</var>, <var>propName</var>).</li><li>Perform ? <emu-xref aoid="CreateDataPropertyOrThrow"><a href="https://tc39.github.io/ecma262/#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>globalObject</var>, <var>propName</var>, <var>propValue</var>).</li></ol></li></ol></li></ol></li><li>Return <var>O</var>.
</li></ol></emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
</body>