Auto merge of #6622 - Ms2ger:send-invalid-state, r=metajack

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



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6622)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-07-14 03:34:47 -06:00
commit a2903091e4
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