Skip to content

Commit

Permalink
[giow] (1) Allow browsers to bail early for showModalDialog, alert, c…
Browse files Browse the repository at this point in the history
…onfirm, and prompt during pagehide, beforeunload, and unload events.

Affected topics: DOM APIs, HTML

git-svn-id: http://svn.whatwg.org/webapps@6966 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Feb 6, 2012
1 parent b60a516 commit 1d1c3c2
Show file tree
Hide file tree
Showing 3 changed files with 247 additions and 80 deletions.
106 changes: 79 additions & 27 deletions complete.html
Expand Up @@ -3417,8 +3417,11 @@ <h3 id=conformance-requirements><span class=secno>2.2 </span>Conformance require
<p>The key words "MUST", "MUST NOT", "REQUIRED", <!--"SHALL", "SHALL
NOT",--> "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
"OPTIONAL" in the normative parts of this document are to be
interpreted as described in RFC2119. For readability, these words do
not appear in all uppercase letters in this specification. <a href=#refsRFC2119>[RFC2119]</a></p>
interpreted as described in RFC2119. The key word "OPTIONALLY" in
the normative parts of this document is to be interpreted with the
same normative meaning as "MAY" and "OPTIONAL". For readability,
these words do not appear in all uppercase letters in this
specification. <a href=#refsRFC2119>[RFC2119]</a></p>

<div class=impl>

Expand Down Expand Up @@ -64827,18 +64830,28 @@ <h4 id=unloading-documents><span class=secno>6.5.11 </span>Unloading documents</
<div class=impl>

<p>A <code><a href=#document>Document</a></code> has a <dfn id=concept-document-salvageable title=concept-document-salvageable><var>salvageable</var></dfn>
state, which is initially true.</p>
state, which must initially be true.</p>

<p><a href=#event-loop title="event loop">Event loops</a> have a
<dfn id=termination-nesting-level>termination nesting level</dfn> counter, which must initially
be zero.</p>

<p>When a user agent is to <dfn id=prompt-to-unload-a-document>prompt to unload a document</dfn>,
it must run the following steps.</p>

<ol><li><p>Let <var title="">event</var> be a new
<ol><li><p>Increase the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination
nesting level</a> by one.</li>

<li><p>Let <var title="">event</var> be a new
<code><a href=#beforeunloadevent>BeforeUnloadEvent</a></code> event object with the name <code title=event-beforeunload>beforeunload</code>, which does not
bubble but is cancelable.</li>

<li><p><i>Dispatch</i>: Dispatch <var title="">event</var> at the
<code><a href=#document>Document</a></code>'s <code><a href=#window>Window</a></code> object.</li>

<li><p>Decrease the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination
nesting level</a> by one.</li>

<li><p>Release the <a href=#storage-mutex>storage mutex</a>.</li>

<li><p>If any event listeners were triggered by the earlier
Expand Down Expand Up @@ -64901,7 +64914,10 @@ <h4 id=unloading-documents><span class=secno>6.5.11 </span>Unloading documents</
whether the <code><a href=#document>Document</a></code> object is going to be
re-used. (This is set by the <code title=dom-document-open><a href=#dom-document-open>document.open()</a></code> method.)</p>

<ol><li><p>Fire a <code title=event-pagehide><a href=#event-pagehide>pagehide</a></code> event at
<ol><li><p>Increase the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination
nesting level</a> by one.</li>

<li><p>Fire a <code title=event-pagehide><a href=#event-pagehide>pagehide</a></code> event at
the <code><a href=#window>Window</a></code> object of the <code><a href=#document>Document</a></code>, but
with its <code title=dom-event-target><a href=#dom-event-target>target</a></code> set to the
<code><a href=#document>Document</a></code> object (and the <code title=dom-event-currentTarget>currentTarget</code> set to the
Expand All @@ -64914,6 +64930,9 @@ <h4 id=unloading-documents><span class=secno>6.5.11 </span>Unloading documents</
<code title=event-unload>unload</code> at the
<code><a href=#document>Document</a></code>'s <code><a href=#window>Window</a></code> object.</li>

<li><p>Decrease the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination
nesting level</a> by one.</li>

<li><p>Release the <a href=#storage-mutex>storage mutex</a>.</li>

<li><p>If any event listeners were triggered by the earlier
Expand Down Expand Up @@ -69328,31 +69347,60 @@ <h4 id=simple-dialogs><span class=secno>7.4.1 </span>Simple dialogs</h4>

</dl><div class=impl>

<p>The <dfn id=dom-alert title=dom-alert><code>alert(<var title="">message</var>)</code></dfn> method, when invoked, must
release the <a href=#storage-mutex>storage mutex</a> and show the given <var title="">message</var> to the user. The user agent may make the
method wait for the user to acknowledge the message before
returning; if so, the user agent must <a href=#pause>pause</a> while the
method is waiting.</p>
<p>The <dfn id=dom-alert title=dom-alert><code>alert(<var title="">message</var>)</code></dfn> method, when invoked, must run
the following steps:</p>

<p>The <dfn id=dom-confirm title=dom-confirm><code>confirm(<var title="">message</var>)</code></dfn> method, when invoked, must
release the <a href=#storage-mutex>storage mutex</a> and show the given <var title="">message</var> to the user, and ask the user to respond with
a positive or negative response. The user agent must then
<a href=#pause>pause</a> as the method waits for the user's response. If
the user responds positively, the method must return true, and if
the user responds negatively, the method must return false.</p>
<ol><li><p>If the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination nesting
level</a> is non-zero, optionally abort these steps.</li>

<p>The <dfn id=dom-prompt title=dom-prompt><code>prompt(<var title="">message</var>, <var title="">default</var>)</code></dfn>
method, when invoked, must release the <a href=#storage-mutex>storage mutex</a>,
show the given <var title="">message</var> to the user, and ask the
user to either respond with a string value or abort. The user agent
must then <a href=#pause>pause</a> as the method waits for the user's
response. The second argument is optional. If the second argument
(<var title="">default</var>) is present, then the response must be
defaulted to the value given by <var title="">default</var>. If the
user aborts, then the method must return null; otherwise, the method
must return the string that the user responded with.</p>
<li><p>Release the <a href=#storage-mutex>storage mutex</a>.</li>

</div>
<li><p>Show the given <var title="">message</var> to the
user.</li>

<li><p>Optionally, <a href=#pause>pause</a> while waiting for for the
user to acknowledge the message.</li>

</ol><p>The <dfn id=dom-confirm title=dom-confirm><code>confirm(<var title="">message</var>)</code></dfn> method, when invoked, must run
the following steps:</p>

<ol><li><p>If the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination nesting
level</a> is non-zero, optionally abort these steps, returning
false.</li>

<li><p>Release the <a href=#storage-mutex>storage mutex</a>.</li>

<li><p>Show the given <var title="">message</var> to the user, and
ask the user to respond with a positive or negative
response.</li>

<li><p><a href=#pause>Pause</a> until the user responds either positively
or negatively.</li>

<li><p>If the user responded positively, return true; otherwise,
the user responded negatively: return false.</li>

</ol><p>The <dfn id=dom-prompt title=dom-prompt><code>prompt(<var title="">message</var>, <var title="">default</var>)</code></dfn>
method, when invoked, must run the following steps:</p>

<ol><li><p>If the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination nesting
level</a> is non-zero, optionally abort these steps, returning
null.</li>

<li><p>Release the <a href=#storage-mutex>storage mutex</a>.</li>

<li><p>Show the given <var title="">message</var> to the user, and
ask the user to either respond with a string value or abort. The
second argument is optional. If the second argument (<var title="">default</var>) is present, then the response must be
defaulted to the value given by <var title="">default</var>.</li>

<li><p><a href=#pause>Pause</a> while waiting for the user's
response.</li>

<li><p>If the user aborts, then return null; otherwise, return the
string that the user responded with.</li>

</ol></div>


<h4 id=printing><span class=secno>7.4.2 </span>Printing</h4>
Expand Down Expand Up @@ -69486,6 +69534,10 @@ <h4 id=dialogs-implemented-using-separate-documents><span class=secno>7.4.3 </sp

</li>

<li><p>If the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination nesting
level</a> is non-zero, optionally abort these steps, returning
the empty string.</li>

<li>

<p>Release the <a href=#storage-mutex>storage mutex</a>.</p>
Expand Down
106 changes: 79 additions & 27 deletions index
Expand Up @@ -3417,8 +3417,11 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
<p>The key words "MUST", "MUST NOT", "REQUIRED", <!--"SHALL", "SHALL
NOT",--> "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
"OPTIONAL" in the normative parts of this document are to be
interpreted as described in RFC2119. For readability, these words do
not appear in all uppercase letters in this specification. <a href=#refsRFC2119>[RFC2119]</a></p>
interpreted as described in RFC2119. The key word "OPTIONALLY" in
the normative parts of this document is to be interpreted with the
same normative meaning as "MAY" and "OPTIONAL". For readability,
these words do not appear in all uppercase letters in this
specification. <a href=#refsRFC2119>[RFC2119]</a></p>

<div class=impl>

Expand Down Expand Up @@ -64827,18 +64830,28 @@ dictionary <dfn id=pagetransitioneventinit>PageTransitionEventInit</dfn> : <a hr
<div class=impl>

<p>A <code><a href=#document>Document</a></code> has a <dfn id=concept-document-salvageable title=concept-document-salvageable><var>salvageable</var></dfn>
state, which is initially true.</p>
state, which must initially be true.</p>

<p><a href=#event-loop title="event loop">Event loops</a> have a
<dfn id=termination-nesting-level>termination nesting level</dfn> counter, which must initially
be zero.</p>

<p>When a user agent is to <dfn id=prompt-to-unload-a-document>prompt to unload a document</dfn>,
it must run the following steps.</p>

<ol><li><p>Let <var title="">event</var> be a new
<ol><li><p>Increase the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination
nesting level</a> by one.</li>

<li><p>Let <var title="">event</var> be a new
<code><a href=#beforeunloadevent>BeforeUnloadEvent</a></code> event object with the name <code title=event-beforeunload>beforeunload</code>, which does not
bubble but is cancelable.</li>

<li><p><i>Dispatch</i>: Dispatch <var title="">event</var> at the
<code><a href=#document>Document</a></code>'s <code><a href=#window>Window</a></code> object.</li>

<li><p>Decrease the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination
nesting level</a> by one.</li>

<li><p>Release the <a href=#storage-mutex>storage mutex</a>.</li>

<li><p>If any event listeners were triggered by the earlier
Expand Down Expand Up @@ -64901,7 +64914,10 @@ dictionary <dfn id=pagetransitioneventinit>PageTransitionEventInit</dfn> : <a hr
whether the <code><a href=#document>Document</a></code> object is going to be
re-used. (This is set by the <code title=dom-document-open><a href=#dom-document-open>document.open()</a></code> method.)</p>

<ol><li><p>Fire a <code title=event-pagehide><a href=#event-pagehide>pagehide</a></code> event at
<ol><li><p>Increase the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination
nesting level</a> by one.</li>

<li><p>Fire a <code title=event-pagehide><a href=#event-pagehide>pagehide</a></code> event at
the <code><a href=#window>Window</a></code> object of the <code><a href=#document>Document</a></code>, but
with its <code title=dom-event-target><a href=#dom-event-target>target</a></code> set to the
<code><a href=#document>Document</a></code> object (and the <code title=dom-event-currentTarget>currentTarget</code> set to the
Expand All @@ -64914,6 +64930,9 @@ dictionary <dfn id=pagetransitioneventinit>PageTransitionEventInit</dfn> : <a hr
<code title=event-unload>unload</code> at the
<code><a href=#document>Document</a></code>'s <code><a href=#window>Window</a></code> object.</li>

<li><p>Decrease the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination
nesting level</a> by one.</li>

<li><p>Release the <a href=#storage-mutex>storage mutex</a>.</li>

<li><p>If any event listeners were triggered by the earlier
Expand Down Expand Up @@ -69328,31 +69347,60 @@ setTimeout({ toString: function () {

</dl><div class=impl>

<p>The <dfn id=dom-alert title=dom-alert><code>alert(<var title="">message</var>)</code></dfn> method, when invoked, must
release the <a href=#storage-mutex>storage mutex</a> and show the given <var title="">message</var> to the user. The user agent may make the
method wait for the user to acknowledge the message before
returning; if so, the user agent must <a href=#pause>pause</a> while the
method is waiting.</p>
<p>The <dfn id=dom-alert title=dom-alert><code>alert(<var title="">message</var>)</code></dfn> method, when invoked, must run
the following steps:</p>

<p>The <dfn id=dom-confirm title=dom-confirm><code>confirm(<var title="">message</var>)</code></dfn> method, when invoked, must
release the <a href=#storage-mutex>storage mutex</a> and show the given <var title="">message</var> to the user, and ask the user to respond with
a positive or negative response. The user agent must then
<a href=#pause>pause</a> as the method waits for the user's response. If
the user responds positively, the method must return true, and if
the user responds negatively, the method must return false.</p>
<ol><li><p>If the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination nesting
level</a> is non-zero, optionally abort these steps.</li>

<p>The <dfn id=dom-prompt title=dom-prompt><code>prompt(<var title="">message</var>, <var title="">default</var>)</code></dfn>
method, when invoked, must release the <a href=#storage-mutex>storage mutex</a>,
show the given <var title="">message</var> to the user, and ask the
user to either respond with a string value or abort. The user agent
must then <a href=#pause>pause</a> as the method waits for the user's
response. The second argument is optional. If the second argument
(<var title="">default</var>) is present, then the response must be
defaulted to the value given by <var title="">default</var>. If the
user aborts, then the method must return null; otherwise, the method
must return the string that the user responded with.</p>
<li><p>Release the <a href=#storage-mutex>storage mutex</a>.</li>

</div>
<li><p>Show the given <var title="">message</var> to the
user.</li>

<li><p>Optionally, <a href=#pause>pause</a> while waiting for for the
user to acknowledge the message.</li>

</ol><p>The <dfn id=dom-confirm title=dom-confirm><code>confirm(<var title="">message</var>)</code></dfn> method, when invoked, must run
the following steps:</p>

<ol><li><p>If the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination nesting
level</a> is non-zero, optionally abort these steps, returning
false.</li>

<li><p>Release the <a href=#storage-mutex>storage mutex</a>.</li>

<li><p>Show the given <var title="">message</var> to the user, and
ask the user to respond with a positive or negative
response.</li>

<li><p><a href=#pause>Pause</a> until the user responds either positively
or negatively.</li>

<li><p>If the user responded positively, return true; otherwise,
the user responded negatively: return false.</li>

</ol><p>The <dfn id=dom-prompt title=dom-prompt><code>prompt(<var title="">message</var>, <var title="">default</var>)</code></dfn>
method, when invoked, must run the following steps:</p>

<ol><li><p>If the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination nesting
level</a> is non-zero, optionally abort these steps, returning
null.</li>

<li><p>Release the <a href=#storage-mutex>storage mutex</a>.</li>

<li><p>Show the given <var title="">message</var> to the user, and
ask the user to either respond with a string value or abort. The
second argument is optional. If the second argument (<var title="">default</var>) is present, then the response must be
defaulted to the value given by <var title="">default</var>.</li>

<li><p><a href=#pause>Pause</a> while waiting for the user's
response.</li>

<li><p>If the user aborts, then return null; otherwise, return the
string that the user responded with.</li>

</ol></div>


<h4 id=printing><span class=secno>7.4.2 </span>Printing</h4>
Expand Down Expand Up @@ -69486,6 +69534,10 @@ setTimeout({ toString: function () {

</li>

<li><p>If the <a href=#event-loop>event loop</a>'s <a href=#termination-nesting-level>termination nesting
level</a> is non-zero, optionally abort these steps, returning
the empty string.</li>

<li>

<p>Release the <a href=#storage-mutex>storage mutex</a>.</p>
Expand Down

0 comments on commit 1d1c3c2

Please sign in to comment.