Skip to content

Commit

Permalink
[giow] (0) Prepare the spec for exposing failed closes.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.whatwg.org/webapps@4817 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Mar 2, 2010
1 parent e0de2b9 commit 1dafe63
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 20 deletions.
41 changes: 31 additions & 10 deletions complete.html
Expand Up @@ -945,7 +945,8 @@ <h2 class="no-num no-toc" id=contents>Table of contents</h2>
<li><a href=#the-websocket-interface><span class=secno>10.3.2 </span>The <code>WebSocket</code> interface</a></li>
<li><a href=#feedback-from-the-protocol><span class=secno>10.3.3 </span>Feedback from the protocol</a>
<ol>
<li><a href=#garbage-collection-1><span class=secno>10.3.3.1 </span>Garbage collection</a></ol></li>
<li><a href=#event-definitions-1><span class=secno>10.3.3.1 </span>Event definitions</a></li>
<li><a href=#garbage-collection-1><span class=secno>10.3.3.2 </span>Garbage collection</a></ol></li>
<li><a href=#websocket-protocol title="The WebSocket protocol enables
two-way communication between a user agent running untrusted code
running in a controlled environment to a remote host that has
Expand Down Expand Up @@ -67120,28 +67121,48 @@ <h4 id=the-websocket-interface><span class=secno>10.3.2 </span>The <code><a href
object.</p>

<p id=closeWebSocket>When the <i><a href=#websocket-connection-is-closed>WebSocket connection is
closed</a></i>, the user agent must <a href=#queue-a-task>queue a task</a> to first
change the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code>
attribute's value to <code title=dom-WebSocket-CLOSED><a href=#dom-websocket-closed>CLOSED</a></code> (2), and then <a href=#fire-a-simple-event>fire
a simple event</a> named <code title=event-close>close</code>
at the <code><a href=#websocket>WebSocket</a></code> object. (If the <code title=dom-WebSocket-close><a href=#dom-websocket-close>close()</a></code> method was called, the
<code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's
value will already be set to <code title=dom-WebSocket-CLOSED><a href=#dom-websocket-closed>CLOSED</a></code> (2) when this task
closed</a></i>, the user agent must create an event that uses the
<code><a href=#closeevent>CloseEvent</a></code> interface, with the event name <code title=event-close>close</code>, which does not bubble, is not
cancelable, has no default action, and whose <code title=dom-CloseEvent-wasClean><a href=#dom-closeevent-wasclean>wasClean</a></code> attribute is set to
false, and <a href=#queue-a-task>queue a task</a> to first change the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value
to <code title=dom-WebSocket-CLOSED><a href=#dom-websocket-closed>CLOSED</a></code> (2), and then
dispatch the event at the <code><a href=#websocket>WebSocket</a></code> object. (If the
<code title=dom-WebSocket-close><a href=#dom-websocket-close>close()</a></code> method was called,
the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code>
attribute's value will already be set to <code title=dom-WebSocket-CLOSED><a href=#dom-websocket-closed>CLOSED</a></code> (2) when this task
runs.)</p>

<p>The <a href=#task-source>task source</a> for all <a href=#concept-task title=concept-task>tasks</a> <a href=#queue-a-task title="queue a
task">queued</a> in this section is the <dfn id=websocket-task-source>WebSocket task
source</dfn>.</p>


<h5 id=garbage-collection-1><span class=secno>10.3.3.1 </span>Garbage collection</h5>
<h5 id=event-definitions-1><span class=secno>10.3.3.1 </span>Event definitions</h5>

<pre class=idl>interface <dfn id=closeevent>CloseEvent</dfn> : <a href=#event>Event</a> {
readonly attribute boolean <a href=#dom-closeevent-wasclean title=dom-CloseEvent-wasClean>wasClean</a>;
void <a href=#dom-closeevent-initcloseevent title=dom-CloseEvent-initCloseEvent>initCloseEvent</a>(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in boolean wasCleanArg);
};</pre>

<p>The <dfn id=dom-closeevent-initcloseevent title=dom-CloseEvent-initCloseEvent><code>initCloseEvent()</code></dfn>
method must initialize the event in a manner analogous to the
similarly-named method in the DOM Events interfaces. <a href=#refsDOMEVENTS>[DOMEVENTS]</a></p>

<p>The <dfn id=dom-closeevent-wasclean title=dom-CloseEvent-wasClean><code>wasClean</code></dfn>
attribute represents whether the connection closed cleanly or
not.</p>



<h5 id=garbage-collection-1><span class=secno>10.3.3.2 </span>Garbage collection</h5>

<p>A <code><a href=#websocket>WebSocket</a></code> object with an open connection must not
be garbage collected if there are any event listeners registered for
<code title=event-message><a href=#event-message>message</a></code> events.</p>

<p>If a <code><a href=#websocket>WebSocket</a></code> object is garbage collected while its
connection is still open, the user agent must <a href=#close-the-websocket-connection>close the WebSocket connection</a>.</p>
connection is still open, the user agent must <a href=#close-the-websocket-connection>close the
WebSocket connection</a>.</p>



Expand Down
44 changes: 34 additions & 10 deletions source
Expand Up @@ -75469,15 +75469,18 @@ socket.onopen = function () {
object.</p>

<p id="closeWebSocket">When the <i>WebSocket connection is
closed</i>, the user agent must <span>queue a task</span> to first
change the <code title="dom-WebSocket-readyState">readyState</code>
attribute's value to <code
title="dom-WebSocket-CLOSED">CLOSED</code> (2), and then <span>fire
a simple event</span> named <code title="event-close">close</code>
at the <code>WebSocket</code> object. (If the <code
title="dom-WebSocket-close">close()</code> method was called, the
<code title="dom-WebSocket-readyState">readyState</code> attribute's
value will already be set to <code
closed</i>, the user agent must create an event that uses the
<code>CloseEvent</code> interface, with the event name <code
title="event-close">close</code>, which does not bubble, is not
cancelable, has no default action, and whose <code
title="dom-CloseEvent-wasClean">wasClean</code> attribute is set to
false, and <span>queue a task</span> to first change the <code
title="dom-WebSocket-readyState">readyState</code> attribute's value
to <code title="dom-WebSocket-CLOSED">CLOSED</code> (2), and then
dispatch the event at the <code>WebSocket</code> object. (If the
<code title="dom-WebSocket-close">close()</code> method was called,
the <code title="dom-WebSocket-readyState">readyState</code>
attribute's value will already be set to <code
title="dom-WebSocket-CLOSED">CLOSED</code> (2) when this task
runs.)</p>

Expand All @@ -75487,14 +75490,35 @@ socket.onopen = function () {
source</dfn>.</p>


<h5>Event definitions</h5>

<pre class="idl">interface <dfn>CloseEvent</dfn> : <span>Event</span> {
readonly attribute boolean <span title="dom-CloseEvent-wasClean">wasClean</span>;
void <span title="dom-CloseEvent-initCloseEvent">initCloseEvent</span>(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in boolean wasCleanArg);
};</pre>

<p>The <dfn
title="dom-CloseEvent-initCloseEvent"><code>initCloseEvent()</code></dfn>
method must initialize the event in a manner analogous to the
similarly-named method in the DOM Events interfaces. <a
href="#refsDOMEVENTS">[DOMEVENTS]</a></p>

<p>The <dfn
title="dom-CloseEvent-wasClean"><code>wasClean</code></dfn>
attribute represents whether the connection closed cleanly or
not.</p>



<h5>Garbage collection</h5>

<p>A <code>WebSocket</code> object with an open connection must not
be garbage collected if there are any event listeners registered for
<code title="event-message">message</code> events.</p>

<p>If a <code>WebSocket</code> object is garbage collected while its
connection is still open, the user agent must <span>close the WebSocket connection</span>.</p>
connection is still open, the user agent must <span>close the
WebSocket connection</span>.</p>


<!--END websocket-api-->
Expand Down

0 comments on commit 1dafe63

Please sign in to comment.