Skip to content

Commit

Permalink
Centralize setting the active document
Browse files Browse the repository at this point in the history
This makes browsing context's active document a getter, returning
browsing context's WindowProxy object's [[Window]] internal slot's
associated Document.

This removes some service worker text that was added in #1776.
Reinstating that in some manner is #2687.

Fixes #2657, fixes #2676.
  • Loading branch information
annevk committed May 17, 2017
1 parent d43b705 commit 8684463
Showing 1 changed file with 47 additions and 72 deletions.
119 changes: 47 additions & 72 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -77085,13 +77085,14 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {

<p>A <span>browsing context</span> has a <span>session history</span>, which lists the
<code>Document</code> objects that the <span>browsing context</span> has presented, is presenting,
or will present. At any time, one <code>Document</code> in each <span>browsing context</span> is
designated the <dfn data-export="">active document</dfn>.
A <dfn data-x="concept-document-bc" data-lt="browsing context" data-dfn-for="Document"
data-export=""><code>Document</code>'s browsing context</dfn> is the <span>browsing context</span>
whose <span>session history</span> contains the <code>Document</code>, if any such browsing
context exists and has not been <span data-x="a browsing context is
discarded">discarded</span>.</p>
or will present. A <span>browsing context</span>'s <dfn data-export="">active document</dfn> is
its <code>WindowProxy</code> object's <span data-x="concept-windowproxy-window">[[Window]]</span>
internal slot value's <span data-x="concept-document-window">associated
<code>Document</code></span>. A <dfn data-x="concept-document-bc" data-lt="browsing context"
data-dfn-for="Document" data-export=""><code>Document</code>'s browsing context</dfn> is the
<span>browsing context</span> whose <span>session history</span> contains the
<code>Document</code>, if any such browsing context exists and has not been <span data-x="a
browsing context is discarded">discarded</span>.</p>

<p class="note">In general, there is a 1-to-1 mapping from the <code>Window</code> object to the
<code>Document</code> object, as long as the <code>Document</code> object has a <span
Expand All @@ -77114,6 +77115,31 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {
browsing context, since that browsing context was <span data-x="a browsing context is
discarded">discarded</span>.</p>

<p>To <dfn>set the active document</dfn>, given a <span>browsing context</span>
<var>browsingContext</var>, <code>Document</code> object <var>document</var>, and optionally a
<code>Window</code> object <var>window</var>, run these steps:</p>

<ol>
<li>
<p>If <var>window</var> is not given, let <var>window</var> be <var>document</var>'s <span
data-x="concept-relevant-global">relevant global object</span>.</p>

<p class="&#x0058;&#x0058;&#x0058;">Per this standard <var>document</var> can be created before
<var>window</var>, which does not make much sense. See <a
href="https://github.com/whatwg/html/issues/2688">issue #2688</a>.</p>
</li>

<li><p>Set <var>browsingContext</var>'s <code>WindowProxy</code> object's <span
data-x="concept-windowproxy-window">[[Window]]</span> internal slot value to
<var>window</var>.</p></li>

<li><p>Set <var>window</var>'s <span data-x="concept-document-window">associated
<code>Document</code></span> to <var>document</var>.</p></li>

<li><p>Set <var>document</var>'s <span>relevant settings object</span>'s <span
data-x="concept-environment-execution-ready-flag">execution ready flag</span>.</p></li>
</ol>

<hr>

<p>A <span>browsing context</span> can have a <dfn data-export="">creator browsing context</dfn>,
Expand Down Expand Up @@ -77183,16 +77209,8 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {
<li><p>Ensure that <var>document</var> has a single child <code>html</code> node, which itself
has two empty child nodes: a <code>head</code> element, and a <code>body</code> element.</p></li>

<li><p>Set <var>window</var>'s <span data-x="concept-document-window">associated
<code>Document</code></span> to <var>document</var>.</p></li>

<li>
<p>Set <var>browsingContext</var>'s <code>WindowProxy</code> object's
<span data-x="concept-windowproxy-window">[[Window]]</span> internal slot
value to <var>window</var>.</p>

<p class="note">The internal slot value is updated when navigations occur.</p>
</li>
<li><p><span>Set the active document</span> with <var>browsingContext</var> and
<var>document</var>.</p></li>

<li>
<p id="about-blank-origin">Set the <span>origin</span> of <var>document</var>:</p>
Expand All @@ -77218,9 +77236,6 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {

<li><p><span>Set the allow* flags</span> for <var>document</var>.</p></li>

<li><p>Set <var>settingsObject</var>'s <span
data-x="concept-environment-execution-ready-flag">execution ready flag</span>.</p></li>

<li><p>Add <var>document</var> to <var>browsingContext</var>'s <span>session
history</span>.</p></li>

Expand Down Expand Up @@ -82531,20 +82546,14 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O
additionally run the following algorithm after creating the new object:</p>

<ol>
<li><p>Let <var>window</var> be null.</p></li>

<li><p>Let <var>settingsObject</var> be null.</p></li>

<li><p>If <var>browsingContext</var>'s only entry in its <span>session history</span> is the
<code>about:blank</code> <code>Document</code> that was added when <var>browsingContext</var>
was <span data-x="creating a new browsing context">created</span>, and navigation is occurring
with <span>replacement enabled</span>, and that <code>Document</code> has the <span>same
origin</span> as the new <code>Document</code>, then set <var>window</var> to the
<code>Window</code> object of that <code>Document</code>, and set <var>settingsObject</var> to
<var>window</var>'s <span>relevant settings object</span>.</p></li>
origin</span> as the new <code>Document</code>, then do nothing.</p></li>

<li>
<p>Otherwise,</p>
<p>Otherwise:</p>

<ol>
<li>
Expand All @@ -82553,8 +82562,7 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O
with the following customizations:</p>

<ul>
<li><p>For the global object, create a new <code>Window</code> object and set
<var>window</var> to it.</p></li>
<li><p>For the global object, create a new <code>Window</code> object.</p></li>

<li><p>For the global <b>this</b> value, use <var>browsingContext</var>'s
<code>WindowProxy</code> object.</p></li>
Expand All @@ -82565,18 +82573,10 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O
</li>

<li><p><span>Set up a window environment settings object</span> with <var>realm execution
context</var> and <var>reservedEnvironment</var>, if present, and set
<var>settingsObject</var> to the result.</p></li>
context</var> and <var>reservedEnvironment</var>, if present.</p></li>
</ol>
</li>

<li><p>Set <var>window</var>'s <span data-x="concept-document-window">associated
<code>Document</code></span> to the new <code>Document</code>.</p></li>

<li><p>Set <var>browsingContext</var>'s <code>WindowProxy</code> object's
<span data-x="concept-windowproxy-window">[[Window]]</span> internal slot
value to <var>window</var>.</p></li>

<li><p>Set the <code>Document</code>'s <span data-x="concept-document-https-state">HTTPS
state</span> to the <span data-x="concept-response-https-state">HTTPS state</span> of the <span
data-x="concept-response">response</span> used to generate the document.</p></li>
Expand Down Expand Up @@ -82608,35 +82608,7 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O
<li><p><span>Implement the sandboxing</span> for the <code>Document</code>.</p></li>

<li><p><span>Set the allow* flags</span> for the <code>Document</code>.</p></li>

<li><p>Set <var>settingsObject</var>'s <span
data-x="concept-environment-execution-ready-flag">execution ready flag</span>.</p></li>

<li>
<p>If <var>settingsObject</var>'s <span
data-x="concept-environment-active-service-worker">active service worker</span> is not null,
then:</p>

<ol>
<li>
<p>If <var>settingsObject</var> is a <span data-x="secure-context">secure context</span>,
then:</p>

<ol>
<li><p>If <var>browsingContext</var> has an <span>opener browsing context</span> and
<var>request</var>'s <span data-x="concept-request-client">client</span> is a <span
data-x="non-secure-context">non-secure context</span>, then <span data-x="disowned its
opener">disown <var>browsingContext</var>'s opener</span>.</p></li>
</ol>
</li>

<li><p>Otherwise, set <var>settingsObject</var>'s <span
data-x="concept-environment-active-service-worker">active service worker</span> to
null.</p></li>
</ol>
</li>
</ol>

</li>

<li id="navigate-non-Document">
Expand Down Expand Up @@ -83318,8 +83290,8 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O

</li>

<li id="appcache-history-2"><p>Make <var>entry</var>'s <code>Document</code> object the
<span>active document</span> of the <span>browsing context</span>.</p></li>
<li id="appcache-history-2"><p><span>Set the active document</span> with the <span>browsing
context</span> and <var>entry</var>'s <code>Document</code> object.</p></li>

<li>

Expand Down Expand Up @@ -90651,14 +90623,17 @@ document.body.appendChild(frame)</pre>
<li><p>Let <var>realm execution context</var> be the created <span>JavaScript execution
context</span>.</p></li>
</ul>
</li>

<li><p>Set <var>window</var>'s <span data-x="concept-document-window">associated
<code>Document</code></span> to <var>document</var>.</p></li>
<p class="&#x0058;&#x0058;&#x0058;">This is not universally implemented and can perhaps be
removed; see <a href="https://github.com/whatwg/html/issues/1698">issue #1698</a>.</p>
</li>

<li><p><span>Set up a window environment settings object</span> with <var>realm execution
context</var>.</p></li>

<li><p><span>Set the active document</span> with <var>document</var>'s
<span>browsing context</span>, <var>document</var>, and <var>window</var>.</p></li>

<li><p>Replace <var>document</var>'s singleton objects with new instances of those objects,
created in <var>window</var>'s <span data-x="concept-global-object-realm">Realm</span>. (This
includes in particular the <code>History</code>, <code>ApplicationCache</code>, and
Expand Down

0 comments on commit 8684463

Please sign in to comment.