Throw an InvalidStateError from WebSocket#send when it is called too early.

This commit is contained in:
Ms2ger 2015-07-14 17:27:10 +02:00
parent d91a6f3834
commit 48b94ec02b
6 changed files with 77 additions and 14 deletions

View file

@ -208,7 +208,11 @@ impl<'a> WebSocketMethods for &'a WebSocket {
self.ready_state.get() as u16 self.ready_state.get() as u16
} }
fn Send(self, data: Option<USVString>)-> Fallible<()>{ fn Send(self, data: Option<USVString>) -> Fallible<()> {
if self.ready_state.get() == WebSocketRequestState::Connecting {
return Err(Error::InvalidState);
}
/*TODO: This is not up to spec see http://html.spec.whatwg.org/multipage/comms.html search for /*TODO: This is not up to spec see http://html.spec.whatwg.org/multipage/comms.html search for
"If argument is a string" "If argument is a string"
TODO: Need to buffer data TODO: Need to buffer data

View file

@ -1,5 +0,0 @@
[Send-before-open.htm]
type: testharness
[W3C WebSocket API - Send data on a WebSocket before connection is opened - INVALID_STATE_ERR is returned]
expected: FAIL

View file

@ -1,3 +1,71 @@
[interfaces.html] [interfaces.html]
type: testharness type: testharness
expected: CRASH [WebSocket interface: existence and properties of interface object]
expected: FAIL
[WebSocket interface: existence and properties of interface prototype object]
expected: FAIL
[WebSocket interface: attribute bufferedAmount]
expected: FAIL
[WebSocket interface: attribute extensions]
expected: FAIL
[WebSocket interface: attribute protocol]
expected: FAIL
[WebSocket interface: attribute onmessage]
expected: FAIL
[WebSocket interface: attribute binaryType]
expected: FAIL
[WebSocket interface: operation send(DOMString)]
expected: FAIL
[WebSocket interface: operation send(Blob)]
expected: FAIL
[WebSocket interface: operation send(ArrayBuffer)]
expected: FAIL
[WebSocket interface: operation send(ArrayBufferView)]
expected: FAIL
[Stringification of new WebSocket("ws://foo")]
expected: FAIL
[WebSocket interface: new WebSocket("ws://foo") must inherit property "bufferedAmount" with the proper type (6)]
expected: FAIL
[WebSocket interface: new WebSocket("ws://foo") must inherit property "extensions" with the proper type (10)]
expected: FAIL
[WebSocket interface: new WebSocket("ws://foo") must inherit property "protocol" with the proper type (11)]
expected: FAIL
[WebSocket interface: new WebSocket("ws://foo") must inherit property "onmessage" with the proper type (13)]
expected: FAIL
[WebSocket interface: new WebSocket("ws://foo") must inherit property "binaryType" with the proper type (14)]
expected: FAIL
[WebSocket interface: calling send(DOMString) on new WebSocket("ws://foo") with too few arguments must throw TypeError]
expected: FAIL
[WebSocket interface: calling send(Blob) on new WebSocket("ws://foo") with too few arguments must throw TypeError]
expected: FAIL
[WebSocket interface: calling send(ArrayBuffer) on new WebSocket("ws://foo") with too few arguments must throw TypeError]
expected: FAIL
[WebSocket interface: calling send(ArrayBufferView) on new WebSocket("ws://foo") with too few arguments must throw TypeError]
expected: FAIL
[CloseEvent interface: existence and properties of interface object]
expected: FAIL
[CloseEvent interface: existence and properties of interface prototype object]
expected: FAIL

View file

@ -1,3 +1,5 @@
[001.html] [001.html]
type: testharness type: testharness
expected: CRASH [WebSockets: send() with no args]
expected: FAIL

View file

@ -1,3 +0,0 @@
[003.html]
type: testharness
expected: CRASH

View file

@ -1,3 +0,0 @@
[004.html]
type: testharness
expected: CRASH