Skip to content

Commit

Permalink
[WIP] JavaScript Realm proposal integration
Browse files Browse the repository at this point in the history
This patch gives the TC39 JavaScript Realm proposal semantics in HTML.
Realms are given an environment settings object, which is especially
meaningful for module loading. Other aspects of the environment
settings object may be unreachable because Realms do not contain Web
APIs, but in general, Realms inherit their settings from the outer
environment.

Overall, the semantics of Realms are analogous to a same-origin iframe
without any Web APIs, just what JavaScript provides. When modules are
used in Realms, module specifiers are interpreted with respect to the
base URL of the surrounding environment, but when a module is imported
within a Realm, it is a separate copy from what may be loaded in the
surrounding environment or other Realms.

The Realm proposal is currently at Stage 2, and this patch should not
land until, at the earliest, the proposal is at Stage 3.
  • Loading branch information
littledan committed Mar 6, 2020
1 parent e910f6a commit 09770ca
Showing 1 changed file with 118 additions and 0 deletions.
118 changes: 118 additions & 0 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -3046,6 +3046,14 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li>The <dfn data-x="js-HostGetImportMetaProperties" data-x-href="https://tc39.es/proposal-import-meta/#sec-hostgetimportmetaproperties">HostGetImportMetaProperties</dfn> abstract operation</li>
</ul>

<p>User agents that support JavaScript must also implement the <cite>Realm</cite>
proposal. The following term is defined there, and used in this specification: <ref
spec=JSREALMS></p>

<ul class="brief">
<li>The <dfn data-x="js-HostInitializeUserRealm" data-x-href="https://rawgit.com/tc39/proposal-realms/master/index.html#sec-host-initialize-user-realm">HostInitializeUserRealm</dfn> abstract operation</li>
</ul>

<p>Users agents that support JavaScript must also implement <cite>ECMAScript
Internationalization API</cite>. <ref spec=JSINTL></p>
</dd>
Expand Down Expand Up @@ -92107,6 +92115,113 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {

</ol>

<h5><dfn data-x="the-hostinitializeuserrealm-implementation">HostInitializeUserRealm</dfn>(<var>realm</var>)</h5>

<p>JavaScript contains an implementation-defined <span
data-x="js-HostInitializeUserRealm">HostInitializeUserRealm</span>(<var>realm</var>) abstract
operation. User agents must use the following implementation:
<ref spec=JAVASCRIPT>

<ol>

<li><p>Let <var>parent settings object</var> be the <span>current settings object</span>.</p></li>

<li><p>Let <var>module map</var> be a new <span>module map</span>, initially empty.</p></li>

<li>
<p>Let <var>settings object</var> be a new <span>environment settings object</span> whose
algorithms are defined as follows:</p>

<dl>

<dt>The <span>realm execution context</span></dt>
<dd>

<p>Return <var>realm</var>.[[ExecutionContext]].</p>

</dd>

<dt>The <span data-x="concept-settings-object-module-map">module map</span></dt>
<dd>

<p>Return <var>module map</var>.</p>

</dd>

<dt>The <span>responsible browsing context</span></dt>
<dd>

<p>Return <var>parent settings object</var>'s <span>responsible browsing context</span>.</p>

</dd>

<dt>The <span>responsible event loop</span></dt>
<dd>

<p>Return <var>parent settings object</var>'s <span>responsible event loop</span>.</p>

</dd>

<dt>The <span>responsible document</span></dt>
<dd>

<p>Return <var>parent settings object</var>'s <span>responsible document</span>.</p>

</dd>

<dt>The <span>API URL character encoding</span></dt>
<dd>

<p>Return <var>parent settings object</var>'s <span>API URL character encoding</span>.</p>

</dd>

<dt>The <span>API base URL</span></dt>
<dd>

<p>Return <var>parent settings object</var>'s <span>API base URL</span>.</p>

</dd>

<dt>The <span data-x="concept-settings-object-origin">origin</span></dt>
<dd>

<p>Return <var>parent settings object</var>'s <span data-x="concept-settings-object-origin">origin</span>.</p>

</dd>

<dt>The <span>HTTPS state</span></dt>
<dd>

<p>Return <var>parent settings object</var>'s <span>HTTPS state</span>.</p>

</dd>

<dt>The <span data-x="concept-settings-object-referrer-policy">referrer policy</span></dt>
<dd>

<p>Return <var>parent settings object</var>'s <span data-x="concept-settings-object-referrer-policy">referrer policy</span>.</p>

</dd>

</dl>
</li>

<li><p>Set <var>settings object</var>'s <span data-x="concept-environment-id">id</span> to a new
unique opaque string, <var>settings object</var>'s <span
data-x="concept-environment-creation-url">creation URL</span> to <var>parent settings
object</var>'s <span data-x="concept-environment-creation-url">creation URL</span>, <var>settings
object</var>'s <span data-x="concept-environment-target-browsing-context">target browsing
context</span> to <var>parent settings object</var>'s <span
data-x="concept-environment-target-browsing-context">target browsing context</span>, and
<var>settings object</var>'s <span data-x="concept-environment-active-service-worker">active
service worker</span> to <var>parent settings object</var>'s <span
data-x="concept-environment-active-service-worker">active service worker</span>.</p></li>

<li><p>Set <var>realm</var>'s [[HostDefined]] field to <var>settings object</var>.</p></li>

</ol>

</div>

<h4>Event loops</h4> <!-- <dfn>event loop</dfn> -->
Expand Down Expand Up @@ -124875,6 +124990,9 @@ INSERT INTERFACES HERE
<dt id="refsJSON">[JSON]</dt>
<dd><cite><a href="https://tools.ietf.org/html/rfc7159">The JavaScript Object Notation (JSON) Data Interchange Format</a></cite>, T. Bray. IETF.</dd>

<dt id="refsJSREALMS">[JSREALMS]</dt>
<dd><cite><a href="https://rawgit.com/tc39/proposal-realms/master/index.html">Realms</a></cite>. Ecma International.</dd>

<dt id="refsLONGTASKS">[LONGTASKS]</dt>
<dd><cite><a href="https://w3c.github.io/longtasks/">Long Tasks</a></cite>, D. Denicola, I. Grigorik, S. Panicker. W3C.</dd>

Expand Down

0 comments on commit 09770ca

Please sign in to comment.