Skip to content

Commit

Permalink
Editorial: cleanup close a browsing context and prompt to unload
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk authored and foolip committed May 10, 2017
1 parent 3d38e20 commit b714a7b
Showing 1 changed file with 60 additions and 79 deletions.
139 changes: 60 additions & 79 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -78943,27 +78943,20 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span

<h4>Closing browsing contexts</h4>

<p>When the user agent is required to <dfn>close a browsing context</dfn>, it must run the
following steps:</p>
<p>To <dfn>close a browsing context</dfn> <var>browsingContext</var>, run these steps:</p>

<ol>
<li><p><span>Prompt to unload</span> <var>browsingContext</var>'s <span>active document</span>.
If the user <span>refused to allow the document to be unloaded</span>, then return.</p></li>

<li><p>Let <var>specified browsing context</var> be the <span>browsing context</span>
being closed.</p></li>

<li><p><span data-x="prompt to unload a document">Prompt to unload</span> the <span>active
document</span> of the <var>specified browsing context</var>. If the user <span>refused
to allow the document to be unloaded</span>, then abort these steps.</p></li>

<li><p><span data-x="unload a document">Unload</span> the <span>active document</span> of the <var>specified browsing context</var> with the <var>recycle</var> parameter set to
false.</p></li>

<li><p>Remove the <var>specified browsing context</var> from the user interface (e.g.
close or hide its tab in a tabbed browser).</p></li>
<li><p><span data-x="unload a document">Unload</span> <var>browsingContext</var>'s <span>active
document</span> with the <var>recycle</var> parameter set to false.</p></li>

<li><p><span data-x="a browsing context is discarded">Discard</span> the <var>specified
browsing context</var>.</p></li>
<li><p>Remove <var>browsingContext</var> from the user interface (e.g., close or hide its tab in
a tabbed browser).</p></li>

<li><p><span data-x="a browsing context is discarded">Discard</span>
<var>browsingContext</var>.</p></li>
</ol>

<p>User agents should offer users the ability to arbitrarily <span data-x="close a browsing
Expand Down Expand Up @@ -80741,9 +80734,9 @@ interface <dfn>History</dfn> {

<ol>

<li><p><span data-x="prompt to unload a document">Prompt to unload</span> the <span>active
document</span> of the <var>specified browsing context</var>. If the user
<span>refused to allow the document to be unloaded</span>, then abort these steps.</p></li>
<li><p><span>Prompt to unload</span> the <span>active document</span> of the <var>specified
browsing context</var>. If the user <span>refused to allow the document to be
unloaded</span>, then abort these steps.</p></li>

<li><p><span data-x="unload a document">Unload</span> the <span>active document</span> of the
<var>specified browsing context</var> with the <var>recycle</var> parameter
Expand Down Expand Up @@ -82008,9 +82001,9 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O
https://github.com/whatwg/html/issues/1213
-->

<li><p>If the <span>prompt to unload a document</span> algorithm is being run for the
<span>active document</span> of <var>browsingContext</var>, then abort these steps without
affecting the <span>prompt to unload a document</span> algorithm.</p></li>
<li><p>If the <span>prompt to unload</span> algorithm is being run for the <span>active
document</span> of <var>browsingContext</var>, then abort these steps without affecting the
<span>prompt to unload</span> algorithm.</p></li>
<!-- https://software.hixie.ch/utilities/js/live-dom-viewer/?saved=1946 to 1955 -->

<li id="navigate-fragid-step"><p>If this is not a <dfn>reload-triggered navigation</dfn>,
Expand All @@ -82033,15 +82026,13 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O
later.)</p></li>

<li>

<p><span data-x="prompt to unload a document">Prompt to unload</span> the <span>active
document</span> of <var>browsingContext</var>. If the user <span>refused to allow the document
to be unloaded</span>, then abort these steps.</p>
<p><span>Prompt to unload</span> the <span>active document</span> of <var>browsingContext</var>.
If the user <span>refused to allow the document to be unloaded</span>, then abort these
steps.</p>

<p>If this instance of the <span data-x="navigate">navigation</span> algorithm gets canceled
while this step is running, the <span>prompt to unload a document</span> algorithm must
nonetheless be run to completion.</p>

while this step is running, the <span>prompt to unload</span> algorithm must nonetheless be run
to completion.</p>
</li>

<li><p><span data-x="abort a document">Abort</span> the <span>active document</span> of
Expand Down Expand Up @@ -83651,18 +83642,18 @@ dictionary <dfn>PageTransitionEventInit</dfn> : <span>EventInit</span> {
<code data-x="event-pageshow">pageshow</code>, or vice versa).</p>

<p><span data-x="event loop">Event loops</span> have a <dfn>termination nesting level</dfn>
counter, which must initially be zero.</p>
counter, which must initially be 0.</p>

<p>When a user agent is to <dfn>prompt to unload a document</dfn>, it must run the following
steps.</p>
<p>To <dfn id="prompt-to-unload-a-document">prompt to unload</dfn>, given a <code>Document</code>
object <var>document</var> and optionally a <var>recursiveFlag</var>, run these steps:</p>

<ol>

<li><p>Increase the <span>event loop</span>'s <span>termination nesting level</span> by
one.</p></li>
1.</p></li>

<li><p>Increase the <code>Document</code>'s <span>ignore-opens-during-unload counter</span> by
one.</p></li>
<li><p>Increase the <var>document</var>'s <span>ignore-opens-during-unload counter</span> by
1.</p></li>

<li><p>Let <var>event</var> be the result of <span>creating an event</span> using
<code>BeforeUnloadEvent</code>.</p></li>
Expand All @@ -83672,18 +83663,17 @@ dictionary <dfn>PageTransitionEventInit</dfn> : <span>EventInit</span> {
data-x="dom-Event-cancelable">cancelable</code> attribute true.</p></li>

<li><p><i>Dispatch</i>: <span data-x="concept-event-dispatch">Dispatch</span> <var>event</var> at
the <code>Document</code>'s <code>Window</code> object.</p></li>
<var>document</var>'s <code>Window</code> object.</p></li>

<li><p>Decrease the <span>event loop</span>'s <span>termination nesting level</span> by
one.</p></li>
1.</p></li>

<li><p>If any event listeners were triggered by the earlier <i>dispatch</i> step, then set the
<code>Document</code>'s <i data-x="concept-document-salvageable">salvageable</i> state to
<li><p>If any event listeners were triggered by the earlier <i>dispatch</i> step, then set
<var>document</var>'s <i data-x="concept-document-salvageable">salvageable</i> state to
false.</p></li>

<li>

<p>If the <code>Document</code>'s <span>active sandboxing flag set</span> does not have its
<p>If <var>document</var>'s <span>active sandboxing flag set</span> does not have its
<span>sandboxed modals flag</span> set, and the <code
data-x="dom-BeforeUnloadEvent-returnValue">returnValue</code> attribute of the <var>event</var>
object is not the empty string, or if the event was canceled, then the user agent may ask the
Expand All @@ -83703,42 +83693,36 @@ dictionary <dfn>PageTransitionEventInit</dfn> : <span>EventInit</span> {

<p>If the user did not confirm the page navigation, then the user agent <dfn>refused to allow
the document to be unloaded</dfn>.</p>

</li>

<li><p>If this algorithm was invoked by another instance of the "prompt to unload a document"
algorithm (i.e. through the steps below that invoke this algorithm for all descendant browsing
contexts), then jump to the step labeled <i>end</i>.</p></li>

<li><p>Let <var>descendants</var> be the <span>list of the descendant browsing
contexts</span> of the <code>Document</code>.</p></li>

<li>

<p>If <var>descendants</var> is not an empty list, then for each <span>browsing
context</span> <var>b</var> in <var>descendants</var> run the following
substeps:</p>
<p>If the <var>recursiveFlag</var> is not set, then:</p>

<ol>
<li><p>Let <var>descendants</var> be the <span>list of the descendant browsing contexts</span>
of <var>document</var>.</p></li>

<li><p><span data-x="prompt to unload a document">Prompt to unload</span> the <span>active
document</span> of the <span>browsing context</span> <var>b</var>. If the user
<span>refused to allow the document to be unloaded</span>, then the user implicitly also <span
data-x="refused to allow the document to be unloaded">refused to allow <em>this</em> document to
be unloaded</span>; jump to the step labeled <i>end</i>.</p>

<li><p>If the <i data-x="concept-document-salvageable">salvageable</i> state of the <span>active
document</span> of the <span>browsing context</span> <var>b</var> is false, then set
the <i data-x="concept-document-salvageable">salvageable</i> state of <em>this</em> document to
false also.</p></li>
<li>
<p>For each <var>browsingContext</var> in <var>descendants</var>:</p>

<ol>
<li><p><span>Prompt to unload</span> <var>browsingContext</var>'s <span>active
document</span> with the <var>recursiveFlag</var> set. If the user <span>refused to allow
the document to be unloaded</span>, then the user implicitly also <span data-x="refused to
allow the document to be unloaded">refused to allow <var>document</var> to be
unloaded</span>; <span>break</span>.</p></li>

<li><p>If the <i data-x="concept-document-salvageable">salvageable</i> state of
<var>browsingContext</var>'s <span>active document</span> is false, then set the <i
data-x="concept-document-salvageable">salvageable</i> state of <var>document</var> to
false.</p></li>
</ol>
</li>
</ol>

</li>

<li><p><i>End</i>: Decrease the <code>Document</code>'s <span>ignore-opens-during-unload
counter</span> by one.</p></li>

<li><p>Decrease the <var>document</var>'s <span>ignore-opens-during-unload counter</span> by
1.</p></li>
</ol>

<p>When a user agent is to <dfn data-export="">unload a document</dfn>, it must run the following
Expand Down Expand Up @@ -83882,20 +83866,18 @@ dictionary <dfn>PageTransitionEventInit</dfn> : <span>EventInit</span> {
<p class="note">There are no <code>BeforeUnloadEvent</code>-specific initialization methods.</p>

<p>The <code>BeforeUnloadEvent</code> interface is a legacy interface which allows <span
data-x="prompt to unload a document">prompting to unload the document</span> to be controlled
not only by canceling the event, but by setting the <code
data-x="dom-BeforeUnloadEvent-returnValue">returnValue</code> attribute to a value besides the
empty string. Authors should use the <code
data-x="prompt to unload">prompting to unload</span> to be controlled not only by canceling the
event, but by setting the <code data-x="dom-BeforeUnloadEvent-returnValue">returnValue</code>
attribute to a value besides the empty string. Authors should use the <code
data-x="dom-Event-preventDefault">preventDefault()</code> method, or other means of canceling
events, instead of using <code data-x="dom-BeforeUnloadEvent-returnValue">returnValue</code>.</p>

<div w-nodev>

<p>The <dfn><code data-x="dom-BeforeUnloadEvent-returnValue">returnValue</code></dfn> attribute
controls the process of <span data-x="prompt to unload a document">prompting to unload the
document</span>. When the event is created, the attribute must be set to
the empty string. On getting, it must return the last value it was set to. On setting, the
attribute must be set to the new value.</p>
controls the process of <span data-x="prompt to unload">prompting to unload</span>. When the event
is created, the attribute must be set to the empty string. On getting, it must return the last
value it was set to. On setting, the attribute must be set to the new value.</p>

<p class="note">This attribute is a <code data-x="">DOMString</code> only for historical reasons.
Any value besides the empty string will be treated as a request to ask the user for
Expand Down Expand Up @@ -90573,10 +90555,9 @@ document.body.appendChild(frame)</pre>
<li><p>Set the <code>Document</code>'s <i
data-x="concept-document-salvageable">salvageable</i> state to false.</p></li>

<li><p><span data-x="prompt to unload a document">Prompt to unload</span> the
<code>Document</code> object. If the user <span>refused to allow the document to be
unloaded</span>, then abort these steps and return the <code>Document</code> object on which the
method was invoked.</p></li>
<li><p><span>Prompt to unload</span> the <code>Document</code> object. If the user <span>refused
to allow the document to be unloaded</span>, then abort these steps and return the
<code>Document</code> object on which the method was invoked.</p></li>

<li><p><span data-x="unload a document">Unload</span> the <code>Document</code> object, with the
<var>recycle</var> parameter set to true.</p></li>
Expand Down

0 comments on commit b714a7b

Please sign in to comment.