mirror of
https://github.com/servo/servo.git
synced 2025-06-21 23:59:00 +01:00
Auto merge of #6094 - Nashenas88:websockets-USVString, r=Ms2ger
Fix #6063 Fix #6062 Fixed definition of Close and Send in WebSocket.webidl and updated implementation in websocket.rs. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6094) <!-- Reviewable:end -->
This commit is contained in:
commit
fe8760cce2
5 changed files with 17 additions and 8 deletions
|
@ -21,13 +21,13 @@ interface WebSocket : EventTarget {
|
||||||
attribute EventHandler onclose;
|
attribute EventHandler onclose;
|
||||||
//readonly attribute DOMString extensions;
|
//readonly attribute DOMString extensions;
|
||||||
//readonly attribute DOMString protocol;
|
//readonly attribute DOMString protocol;
|
||||||
//[Throws] void close([Clamp] optional unsigned short code, optional DOMString reason); //Clamp doesn't work
|
//[Throws] void close([Clamp] optional unsigned short code, optional USVString reason); //Clamp doesn't work
|
||||||
[Throws] void close(optional unsigned short code, optional DOMString reason); //No clamp version - works
|
[Throws] void close(optional unsigned short code, optional USVString reason); //No clamp version - works
|
||||||
|
|
||||||
//messaging
|
//messaging
|
||||||
//attribute EventHandler onmessage;
|
//attribute EventHandler onmessage;
|
||||||
//attribute BinaryType binaryType;
|
//attribute BinaryType binaryType;
|
||||||
[Throws] void send(optional DOMString data);
|
[Throws] void send(optional USVString data);
|
||||||
//void send(Blob data);
|
//void send(Blob data);
|
||||||
//void send(ArrayBuffer data);
|
//void send(ArrayBuffer data);
|
||||||
//void send(ArrayBufferView data);
|
//void send(ArrayBufferView data);
|
||||||
|
|
|
@ -14,6 +14,7 @@ use dom::bindings::error::Error::Syntax;
|
||||||
use dom::bindings::global::{GlobalField, GlobalRef};
|
use dom::bindings::global::{GlobalField, GlobalRef};
|
||||||
use dom::bindings::js::{Temporary, JSRef, Rootable};
|
use dom::bindings::js::{Temporary, JSRef, Rootable};
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
|
use dom::bindings::str::USVString;
|
||||||
use dom::bindings::trace::JSTraceable;
|
use dom::bindings::trace::JSTraceable;
|
||||||
use dom::bindings::utils::reflect_dom_object;
|
use dom::bindings::utils::reflect_dom_object;
|
||||||
use dom::closeevent::CloseEvent;
|
use dom::closeevent::CloseEvent;
|
||||||
|
@ -153,7 +154,7 @@ impl<'a> WebSocketMethods for JSRef<'a, WebSocket> {
|
||||||
self.ready_state.get() as u16
|
self.ready_state.get() as u16
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Send(self, data: Option<DOMString>)-> Fallible<()>{
|
fn Send(self, data: Option<USVString>)-> Fallible<()>{
|
||||||
/*TODO: This is not up to spec see http://html.spec.whatwg.org/multipage/comms.html search for "If argument is a string"
|
/*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
|
TODO: Need to buffer data
|
||||||
TODO: bufferedAmount attribute returns the size of the buffer in bytes -
|
TODO: bufferedAmount attribute returns the size of the buffer in bytes -
|
||||||
|
@ -168,11 +169,11 @@ impl<'a> WebSocketMethods for JSRef<'a, WebSocket> {
|
||||||
let _ = my_sender.send_message(Message::Close(None));
|
let _ = my_sender.send_message(Message::Close(None));
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let _ = my_sender.send_message(Message::Text(data.unwrap()));
|
let _ = my_sender.send_message(Message::Text(data.unwrap().0));
|
||||||
return Ok(())
|
return Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Close(self, code: Option<u16>, reason: Option<DOMString>) -> Fallible<()>{
|
fn Close(self, code: Option<u16>, reason: Option<USVString>) -> Fallible<()>{
|
||||||
if let Some(code) = code {
|
if let Some(code) = code {
|
||||||
//Check code is NOT 1000 NOR in the range of 3000-4999 (inclusive)
|
//Check code is NOT 1000 NOR in the range of 3000-4999 (inclusive)
|
||||||
if code != 1000 && (code < 3000 || code > 4999) {
|
if code != 1000 && (code < 3000 || code > 4999) {
|
||||||
|
@ -180,7 +181,7 @@ impl<'a> WebSocketMethods for JSRef<'a, WebSocket> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(ref reason) = reason {
|
if let Some(ref reason) = reason {
|
||||||
if reason.as_bytes().len() > 123 { //reason cannot be larger than 123 bytes
|
if reason.0.as_bytes().len() > 123 { //reason cannot be larger than 123 bytes
|
||||||
return Err(Error::Syntax);
|
return Err(Error::Syntax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,7 +206,7 @@ impl<'a> WebSocketMethods for JSRef<'a, WebSocket> {
|
||||||
self.code.set(code);
|
self.code.set(code);
|
||||||
}
|
}
|
||||||
if let Some(reason) = reason {
|
if let Some(reason) = reason {
|
||||||
*self.reason.borrow_mut() = reason;
|
*self.reason.borrow_mut() = reason.0;
|
||||||
}
|
}
|
||||||
self.ready_state.set(WebSocketRequestState::Closing);
|
self.ready_state.set(WebSocketRequestState::Closing);
|
||||||
self.sendCloseFrame.set(true);
|
self.sendCloseFrame.set(true);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
[Close-reason-unpaired-surrogates.htm]
|
[Close-reason-unpaired-surrogates.htm]
|
||||||
type: testharness
|
type: testharness
|
||||||
expected: TIMEOUT
|
expected: TIMEOUT
|
||||||
|
[W3C WebSocket API - Create WebSocket - Close the Connection - close(reason with unpaired surrogates) - connection should get closed]
|
||||||
|
expected: NOTRUN
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
[Send-Unpaired-Surrogates.htm]
|
[Send-Unpaired-Surrogates.htm]
|
||||||
type: testharness
|
type: testharness
|
||||||
expected: TIMEOUT
|
expected: TIMEOUT
|
||||||
|
[W3C WebSocket API - Send unpaired surrogates on a WebSocket - Message should be received]
|
||||||
|
expected: NOTRUN
|
||||||
|
[W3C WebSocket API - Send unpaired surrogates on a WebSocket - Connection should be closed]
|
||||||
|
expected: NOTRUN
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
[006.html]
|
[006.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
expected: TIMEOUT
|
expected: TIMEOUT
|
||||||
|
[WebSockets: send() with unpaired surrogate when readyState is OPEN]
|
||||||
|
expected: TIMEOUT
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue