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
}
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
"If argument is a string"
TODO: Need to buffer data