Skip to content

Commit

Permalink
[giow] (0) Reintroduce 'error' events for WebSockets.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.whatwg.org/webapps@6191 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Jun 6, 2011
1 parent 227651c commit eb8d1c4
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 62 deletions.
58 changes: 27 additions & 31 deletions complete.html
Expand Up @@ -79113,8 +79113,8 @@ <h4 id=the-websocket-interface><span class=secno>11.3.2 </span>The <code><a href

// networking
attribute <a href=#function>Function</a> <a href=#handler-websocket-onopen title=handler-WebSocket-onopen>onopen</a>;
<!-- attribute <span>Function</span> <span title="handler-WebSocket-onerror">onerror</span>;
--> attribute <a href=#function>Function</a> <a href=#handler-websocket-onclose title=handler-WebSocket-onclose>onclose</a>;
attribute <a href=#function>Function</a> <a href=#handler-websocket-onerror title=handler-WebSocket-onerror>onerror</a>;
attribute <a href=#function>Function</a> <a href=#handler-websocket-onclose title=handler-WebSocket-onclose>onclose</a>;
readonly attribute DOMString <a href=#dom-websocket-extensions title=dom-WebSocket-extensions>extensions</a>;
readonly attribute DOMString <a href=#dom-websocket-protocol title=dom-WebSocket-protocol>protocol</a>;
void <a href=#dom-websocket-close title=dom-WebSocket-close>close</a>(in optional unsigned long code, in optional DOMString reason);
Expand Down Expand Up @@ -79496,7 +79496,7 @@ <h4 id=the-websocket-interface><span class=secno>11.3.2 </span>The <code><a href
<table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a>
<tbody><tr><td><dfn id=handler-websocket-onopen title=handler-WebSocket-onopen><code>onopen</code></dfn> <td> <code title=event-open>open</code>
<tr><td><dfn id=handler-websocket-onmessage title=handler-WebSocket-onmessage><code>onmessage</code></dfn> <td> <code title=event-message><a href=#event-message>message</a></code>
<!-- <tr><td><dfn title="handler-WebSocket-onerror"><code>onerror</code></dfn> <td> <code title="event-error">error</code>-->
<tr><td><dfn id=handler-websocket-onerror title=handler-WebSocket-onerror><code>onerror</code></dfn> <td> <code title=event-error>error</code>
<tr><td><dfn id=handler-websocket-onclose title=handler-WebSocket-onclose><code>onclose</code></dfn> <td> <code title=event-close>close</code>
</table><h4 id=feedback-from-the-protocol><span class=secno>11.3.3 </span>Feedback from the protocol</h4>

Expand Down Expand Up @@ -79575,16 +79575,7 @@ <h4 id=the-websocket-interface><span class=secno>11.3.2 </span>The <code><a href
data back to RAM before running this <a href=#concept-task title=concept-task>task</a> so as to avoid stalling the main
thread while it created the <code>ArrayBuffer</code> object.</p>

<hr><!--
<p>When <i>a WebSocket error has been detected</i>, the user agent
must <span>queue a task</span> to check to see if the <code
title="dom-WebSocket-readyState">readyState</code> attribute's value
is <code title="dom-WebSocket-OPEN">OPEN</code> (1) or <code
title="dom-WebSocket-CLOSING">CLOSING</code> (2), and if so,
<span>fire a simple event</span> named <code
title="event-error">error</code> at the <code>WebSocket</code>
object. <a href="#refsWSP">[WSP]</a></p>
--><p>When <i><a href=#the-websocket-closing-handshake-is-started>the WebSocket closing handshake is started</a></i>, the user
<hr><p>When <i><a href=#the-websocket-closing-handshake-is-started>the WebSocket closing handshake is started</a></i>, the user
agent must <a href=#queue-a-task>queue a task</a> to change the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value
to <code title=dom-WebSocket-CLOSING><a href=#dom-websocket-closing>CLOSING</a></code> (2). (If the
<code title=dom-WebSocket-close><a href=#dom-websocket-close>close()</a></code> method was called,
Expand All @@ -79594,20 +79585,27 @@ <h4 id=the-websocket-interface><span class=secno>11.3.2 </span>The <code><a href

<p id=closeWebSocket>When <i><a href=#the-websocket-connection-is-closed>the WebSocket connection is
closed</a></i>, possibly <i title="">cleanly</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, whose
<code title=dom-CloseEvent-wasClean><a href=#dom-closeevent-wasclean>wasClean</a></code> attribute is
set to true if the connection closed <i title="">cleanly</i> and
false otherwise, whose <code title=dom-CloseEvent-code><a href=#dom-closeevent-code>code</a></code>
attribute is set to <i><a href=#the-websocket-connection-close-code>the WebSocket connection close code</a></i>, and
whose <code title=dom-CloseEvent-reason><a href=#dom-closeevent-reason>reason</a></code> attribute is
set to <i><a href=#the-websocket-connection-close-reason>the WebSocket connection close reason</a></i>; 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> (3), and then
dispatch the event at the <code><a href=#websocket>WebSocket</a></code> object. <a href=#refsWSP>[WSP]</a></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
<a href=#queue-a-task>queue a task</a> to run the following substeps:</p>

<ol><li><p>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>
(3).</li>

<li><p>If the user agent was required to <i><a href=#fail-the-websocket-connection>fail the websocket
connection</a></i>, <a href=#fire-a-simple-event>fire a simple event</a> named <code title="">error</code> at the <code><a href=#websocket>WebSocket</a></code> object. <a href=#refsWSP>[WSP]</a></li>

<li><p>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, whose <code title=dom-CloseEvent-wasClean><a href=#dom-closeevent-wasclean>wasClean</a></code> attribute is set to
true if the connection closed <i title="">cleanly</i> and false
otherwise, whose <code title=dom-CloseEvent-code><a href=#dom-closeevent-code>code</a></code>
attribute is set to <i><a href=#the-websocket-connection-close-code>the WebSocket connection close code</a></i>, and
whose <code title=dom-CloseEvent-reason><a href=#dom-closeevent-reason>reason</a></code> attribute
is set to <i><a href=#the-websocket-connection-close-reason>the WebSocket connection close reason</a></i>
<a href=#decoded-as-utf-8,-with-error-handling>decoded as UTF-8, with error handling</a>, and dispatch
the event at the <code><a href=#websocket>WebSocket</a></code> object. <a href=#refsWSP>[WSP]</a></li>

</ol><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>

Expand Down Expand Up @@ -79646,14 +79644,12 @@ <h5 id=garbage-collection-2><span class=secno>11.3.3.2 </span>Garbage collection
(0) as of the last time the <a href=#event-loop>event loop</a> started
executing a <a href=#concept-task title=concept-task>task</a> must not be
garbage collected if there are any event listeners registered for
<code title=event-open>open</code> events, <code title=event-message><a href=#event-message>message</a></code> events<!--, <code
title="event-error">error</code> events-->, or <code title=event-close>close</code> events.</p>
<code title=event-open>open</code> events, <code title=event-message><a href=#event-message>message</a></code> events, <code title=event-error>error</code> events, or <code title=event-close>close</code> events.</p>

<p>A <code><a href=#websocket>WebSocket</a></code> object whose <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value
was set to <code title=dom-WebSocket-OPEN><a href=#dom-websocket-open>OPEN</a></code> (1) or <code title=dom-WebSocket-CLOSING><a href=#dom-websocket-closing>CLOSING</a></code> (2) as of the last time
the <a href=#event-loop>event loop</a> started executing a <a href=#concept-task title=concept-task>task</a> 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<!--, <code
title="event-error">error</code> events-->, or <code title=event-close>close</code> events.</p>
there are any event listeners registered for <code title=event-message><a href=#event-message>message</a></code> events, <code title=event-error>error</code>, or <code title=event-close>close</code> events.</p>

<p>A <code><a href=#websocket>WebSocket</a></code> object with <i title="the WebSocket
connection is established"><a href=#the-websocket-connection-is-established>an established connection</a></i> that has
Expand Down
68 changes: 37 additions & 31 deletions source
Expand Up @@ -89803,8 +89803,8 @@ interface <dfn>WebSocket</dfn> {

// networking
attribute <span>Function</span> <span title="handler-WebSocket-onopen">onopen</span>;
<!-- attribute <span>Function</span> <span title="handler-WebSocket-onerror">onerror</span>;
--> attribute <span>Function</span> <span title="handler-WebSocket-onclose">onclose</span>;
attribute <span>Function</span> <span title="handler-WebSocket-onerror">onerror</span>;
attribute <span>Function</span> <span title="handler-WebSocket-onclose">onclose</span>;
readonly attribute DOMString <span title="dom-WebSocket-extensions">extensions</span>;
readonly attribute DOMString <span title="dom-WebSocket-protocol">protocol</span>;
void <span title="dom-WebSocket-close">close</span>(in optional unsigned long code, in optional DOMString reason);
Expand Down Expand Up @@ -90271,7 +90271,7 @@ socket.onopen = function () {
<tbody>
<tr><td><dfn title="handler-WebSocket-onopen"><code>onopen</code></dfn> <td> <code title="event-open">open</code>
<tr><td><dfn title="handler-WebSocket-onmessage"><code>onmessage</code></dfn> <td> <code title="event-message">message</code>
<!-- <tr><td><dfn title="handler-WebSocket-onerror"><code>onerror</code></dfn> <td> <code title="event-error">error</code>-->
<tr><td><dfn title="handler-WebSocket-onerror"><code>onerror</code></dfn> <td> <code title="event-error">error</code>
<tr><td><dfn title="handler-WebSocket-onclose"><code>onclose</code></dfn> <td> <code title="event-close">close</code>
</table>

Expand Down Expand Up @@ -90392,16 +90392,7 @@ socket.onopen = function () {
thread while it created the <code>ArrayBuffer</code> object.</p>

<hr>
<!--
<p>When <i>a WebSocket error has been detected</i>, the user agent
must <span>queue a task</span> to check to see if the <code
title="dom-WebSocket-readyState">readyState</code> attribute's value
is <code title="dom-WebSocket-OPEN">OPEN</code> (1) or <code
title="dom-WebSocket-CLOSING">CLOSING</code> (2), and if so,
<span>fire a simple event</span> named <code
title="event-error">error</code> at the <code>WebSocket</code>
object. <a href="#refsWSP">[WSP]</a></p>
-->

<p>When <i>the WebSocket closing handshake is started</i>, the user
agent must <span>queue a task</span> to change the <code
title="dom-WebSocket-readyState">readyState</code> attribute's value
Expand All @@ -90414,20 +90405,35 @@ socket.onopen = function () {

<p id="closeWebSocket">When <i>the WebSocket connection is
closed</i>, possibly <i title="">cleanly</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, whose
<code title="dom-CloseEvent-wasClean">wasClean</code> attribute is
set to true if the connection closed <i title="">cleanly</i> and
false otherwise, whose <code title="dom-CloseEvent-code">code</code>
attribute is set to <i>the WebSocket connection close code</i>, and
whose <code title="dom-CloseEvent-reason">reason</code> attribute is
set to <i>the WebSocket connection close reason</i>; 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> (3), and then
dispatch the event at the <code>WebSocket</code> object. <a
href="#refsWSP">[WSP]</a></p>
<span>queue a task</span> to run the following substeps:</p>

<ol>

<li><p>Change the <code
title="dom-WebSocket-readyState">readyState</code> attribute's
value to <code title="dom-WebSocket-CLOSED">CLOSED</code>
(3).</p></li>

<li><p>If the user agent was required to <i>fail the websocket
connection</i>, <span>fire a simple event</span> named <code
title="">error</code> at the <code>WebSocket</code> object. <a
href="#refsWSP">[WSP]</a></p></li>

<li><p>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, whose <code
title="dom-CloseEvent-wasClean">wasClean</code> attribute is set to
true if the connection closed <i title="">cleanly</i> and false
otherwise, whose <code title="dom-CloseEvent-code">code</code>
attribute is set to <i>the WebSocket connection close code</i>, and
whose <code title="dom-CloseEvent-reason">reason</code> attribute
is set to <i>the WebSocket connection close reason</i>
<span>decoded as UTF-8, with error handling</span>, and dispatch
the event at the <code>WebSocket</code> object. <a
href="#refsWSP">[WSP]</a></p></li>

</ol>

<p>The <span>task source</span> for all <span
title="concept-task">tasks</span> <span title="queue a
Expand Down Expand Up @@ -90475,8 +90481,8 @@ socket.onopen = function () {
executing a <span title="concept-task">task</span> must not be
garbage collected if there are any event listeners registered for
<code title="event-open">open</code> events, <code
title="event-message">message</code> events<!--, <code
title="event-error">error</code> events-->, or <code
title="event-message">message</code> events, <code
title="event-error">error</code> events, or <code
title="event-close">close</code> events.</p>

<p>A <code>WebSocket</code> object whose <code
Expand All @@ -90486,8 +90492,8 @@ socket.onopen = function () {
the <span>event loop</span> started executing a <span
title="concept-task">task</span> must not be garbage collected if
there are any event listeners registered for <code
title="event-message">message</code> events<!--, <code
title="event-error">error</code> events-->, or <code
title="event-message">message</code> events, <code
title="event-error">error</code>, or <code
title="event-close">close</code> events.</p>

<p>A <code>WebSocket</code> object with <i title="the WebSocket
Expand Down

0 comments on commit eb8d1c4

Please sign in to comment.