Skip to content

Commit

Permalink
[giow] (0) Add WebSocket.onmessageerror to report unexpected frames.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.whatwg.org/webapps@4816 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Mar 2, 2010
1 parent a4b9d8b commit e0de2b9
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 24 deletions.
43 changes: 31 additions & 12 deletions complete.html
Original file line number Diff line number Diff line change
Expand Up @@ -66940,6 +66940,7 @@ <h4 id=the-websocket-interface><span class=secno>10.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 <a href=#function>Function</a> <a href=#handler-websocket-onmessage title=handler-WebSocket-onmessage>onmessage</a>;
attribute <a href=#function>Function</a> <a href=#handler-websocket-onmessageerror title=handler-WebSocket-onmessageerror>onmessageerror</a>;
attribute <a href=#function>Function</a> <a href=#handler-websocket-onclose title=handler-WebSocket-onclose>onclose</a>;
boolean <a href=#dom-websocket-send title=dom-WebSocket-send>send</a>(in DOMString data);
void <a href=#dom-websocket-close title=dom-WebSocket-close>close</a>();
Expand Down Expand Up @@ -67093,6 +67094,7 @@ <h4 id=the-websocket-interface><span class=secno>10.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 id=handler-websocket-onmessageerror title=handler-WebSocket-onmessageerror><code>onmessageerror</code></dfn> <td> <code title=event-messageerror>messageerror</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>10.3.3 </span>Feedback from the protocol</h4>

Expand All @@ -67110,6 +67112,13 @@ <h4 id=the-websocket-interface><span class=secno>10.3.2 </span>The <code><a href
(1), and if so, dispatch the event at the <code><a href=#websocket>WebSocket</a></code>
object.</p>

<p>When <i><a href=#a-websocket-error-has-been-detected>a WebSocket error has been detected</a></i>, the user agent
must <a href=#queue-a-task>queue a task</a> to set to <var title="">data</var>,
and <a href=#queue-a-task>queue a task</a> to check to see if the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value
is <code title=dom-WebSocket-OPEN><a href=#dom-websocket-open>OPEN</a></code> (1), and if so,
<a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-messageerror>messageerror</code> at the <code><a href=#websocket>WebSocket</a></code>
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>
Expand Down Expand Up @@ -68526,17 +68535,22 @@ <h6 id=handshake-0><span class=secno>10.3.4.3.1 </span>Handshake</h6>

</ol><h6 id=data-framing><span class=secno>10.3.4.3.2 </span>Data framing</h6>

<p>Once a <a href=#websocket-connection-is-established>WebSocket connection is established</a>, the
user agent must run through the following state machine for the
bytes sent by the server.</p>
<p>Once a <a href=#websocket-connection-is-established>WebSocket connection is established</a>, the user
agent must run through the following state machine for the bytes
sent by the server. If at any point during these steps a read is
attempted but fails because the <a href=#websocket-connection-is-closed>WebSocket connection is
closed</a>, then abort.</p>

<ol><li>

<p>Try to read a byte from the server. Let <var title="">frame
type</var> be that byte.</p>

<p>If no byte could be read because the <a href=#websocket-connection-is-closed>WebSocket
connection is closed</a>, then abort.</p>
</li>

<li>

<p>Let <var title="">error</var> be false.</p>

</li>

Expand All @@ -68549,9 +68563,7 @@ <h6 id=handshake-0><span class=secno>10.3.4.3.1 </span>Handshake</h6>

<dd>

<p>Run these steps. If at any point during these steps a read is
attempted but fails because the <a href=#websocket-connection-is-closed>WebSocket connection is
closed</a>, then abort.</p>
<p>Run these steps:</p>

<ol><li><p>Let <var title="">length</var> be zero.</li>

Expand All @@ -68573,6 +68585,8 @@ <h6 id=handshake-0><span class=secno>10.3.4.3.1 </span>Handshake</h6>

<li><p>Discard the read bytes.</li>

<li><p>Let <var title="">error</var> be true.</li>

</ol></dd>

<dt>If the high-order bit of the <var title="">frame type</var>
Expand All @@ -68581,9 +68595,7 @@ <h6 id=handshake-0><span class=secno>10.3.4.3.1 </span>Handshake</h6>

<dd>

<p>Run these steps. If at any point during these steps a read is
attempted but fails because the <a href=#websocket-connection-is-closed>WebSocket connection is
closed</a>, then abort.</p>
<p>Run these steps:</p>

<ol><li><p>Let <var title="">raw data</var> be an empty byte array.</li>

Expand All @@ -68596,12 +68608,19 @@ <h6 id=handshake-0><span class=secno>10.3.4.3.1 </span>Handshake</h6>
string, and store that string in <var title="">data</var>.</p>

<li><p>If <var title="">frame type</var> is 0x00, then <dfn id=a-websocket-message-has-been-received>a
WebSocket message has been received</dfn> with text <var title="">data</var>. Otherwise, discard the data.</li>
WebSocket message has been received</dfn> with text <var title="">data</var>. Otherwise, discard the data and let <var title="">error</var> be true.</li>

</ol></dd>

</dl></li>

<li>

<p>If <var title="">error</var> is true, then <dfn id=a-websocket-error-has-been-detected>a WebSocket
error has been detected</dfn>.</li>



<li><p>Return to the first step to read the next byte.</li>

</ol><p>If the user agent is faced with content that is too large to be
Expand Down
46 changes: 34 additions & 12 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -75239,6 +75239,7 @@ interface <dfn>WebSocket</dfn> {
// networking
attribute <span>Function</span> <span title="handler-WebSocket-onopen">onopen</span>;
attribute <span>Function</span> <span title="handler-WebSocket-onmessage">onmessage</span>;
attribute <span>Function</span> <span title="handler-WebSocket-onmessageerror">onmessageerror</span>;
attribute <span>Function</span> <span title="handler-WebSocket-onclose">onclose</span>;
boolean <span title="dom-WebSocket-send">send</span>(in DOMString data);
void <span title="dom-WebSocket-close">close</span>();
Expand Down Expand Up @@ -75430,6 +75431,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-onmessageerror"><code>onmessageerror</code></dfn> <td> <code title="event-messageerror">messageerror</code>
<tr><td><dfn title="handler-WebSocket-onclose"><code>onclose</code></dfn> <td> <code title="event-close">close</code>
</table>

Expand Down Expand Up @@ -75457,6 +75459,15 @@ socket.onopen = function () {
(1), and if so, dispatch the event at the <code>WebSocket</code>
object.</p>

<p>When <i>a WebSocket error has been detected</i>, the user agent
must <span>queue a task</span> to set to <var title="">data</var>,
and <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), and if so,
<span>fire a simple event</span> named <code
title="event-messageerror">messageerror</code> at the <code>WebSocket</code>
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>
Expand Down Expand Up @@ -77061,9 +77072,11 @@ multi-origin semantics described in [ORIGIN] applying. (http-origin)

<h6>Data framing</h6>

<p>Once a <span>WebSocket connection is established</span>, the
user agent must run through the following state machine for the
bytes sent by the server.</p>
<p>Once a <span>WebSocket connection is established</span>, the user
agent must run through the following state machine for the bytes
sent by the server. If at any point during these steps a read is
attempted but fails because the <span>WebSocket connection is
closed</span>, then abort.</p>

<ol>

Expand All @@ -77072,8 +77085,11 @@ multi-origin semantics described in [ORIGIN] applying. (http-origin)
<p>Try to read a byte from the server. Let <var title="">frame
type</var> be that byte.</p>

<p>If no byte could be read because the <span>WebSocket
connection is closed</span>, then abort.</p>
</li>

<li>

<p>Let <var title="">error</var> be false.</p>

</li>

Expand All @@ -77089,9 +77105,7 @@ multi-origin semantics described in [ORIGIN] applying. (http-origin)

<dd>

<p>Run these steps. If at any point during these steps a read is
attempted but fails because the <span>WebSocket connection is
closed</span>, then abort.</p>
<p>Run these steps:</p>

<ol>

Expand All @@ -77118,6 +77132,8 @@ multi-origin semantics described in [ORIGIN] applying. (http-origin)

<li><p>Discard the read bytes.</p></li>

<li><p>Let <var title="">error</var> be true.</p></li>

</ol>

</dd>
Expand All @@ -77128,9 +77144,7 @@ multi-origin semantics described in [ORIGIN] applying. (http-origin)

<dd>

<p>Run these steps. If at any point during these steps a read is
attempted but fails because the <span>WebSocket connection is
closed</span>, then abort.</p>
<p>Run these steps:</p>

<ol>

Expand All @@ -77149,7 +77163,8 @@ multi-origin semantics described in [ORIGIN] applying. (http-origin)

<li><p>If <var title="">frame type</var> is 0x00, then <dfn>a
WebSocket message has been received</dfn> with text <var
title="">data</var>. Otherwise, discard the data.</p></li>
title="">data</var>. Otherwise, discard the data and let <var
title="">error</var> be true.</p></li>

</ol>

Expand All @@ -77159,6 +77174,13 @@ multi-origin semantics described in [ORIGIN] applying. (http-origin)

</li>

<li>

<p>If <var title="">error</var> is true, then <dfn>a WebSocket
error has been detected</dfn>.</p></li>

</li>

<li><p>Return to the first step to read the next byte.</p></li>

</ol>
Expand Down

0 comments on commit e0de2b9

Please sign in to comment.