Skip to content

Commit

Permalink
Auto merge of #6338 - servo:ws-connect, r=Ms2ger
Browse files Browse the repository at this point in the history
Make an early return when the WebSocket connection fails in the constructor.
Also let the WebSockect connection to be closed when the connection could
not be established.

Fixes #6082.
Fixes #6086.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6338)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Jun 11, 2015
2 parents 74ef31c + 877c369 commit a3eb253
Show file tree
Hide file tree
Showing 25 changed files with 557 additions and 41 deletions.
11 changes: 10 additions & 1 deletion components/script/dom/websocket.rs
Expand Up @@ -141,7 +141,16 @@ impl WebSocket {

// TODO Client::connect does not conform to RFC 6455
// see https://github.com/cyderize/rust-websocket/issues/38
let request = Client::connect(parsed_url).unwrap();
let request = match Client::connect(parsed_url) {
Ok(request) => request,
Err(_) => {
let global_root = ws_root.global.root();
let address = Trusted::new(global_root.r().get_cx(), ws_root, global_root.r().script_chan().clone());
let task = box WebSocketTaskHandler::new(address, WebSocketTask::Close);
global_root.r().script_chan().send(ScriptMsg::RunnableMsg(task)).unwrap();
return Ok(Temporary::from_rooted(ws_root));
}
};
let response = request.send().unwrap();
response.validate().unwrap();
ws_root.ready_state.set(WebSocketRequestState::Open);
Expand Down
3 changes: 3 additions & 0 deletions tests/wpt/metadata/FileAPI/progress.html.ini
@@ -1,3 +1,6 @@
[progress.html]
type: testharness
expected: TIMEOUT
[W3C WebSocket API - Create WebSocket - Pass a URL with a non ws/wss scheme - SYNTAX_ERR is thrown]
expected: FAIL

@@ -1,3 +1,5 @@
[Create-Secure-blocked-port.htm]
type: testharness
expected: TIMEOUT
[W3C WebSocket API - Create Secure WebSocket - Pass a URL with a blocked port - SECURITY_ERR should be thrown]
expected: FAIL

0 comments on commit a3eb253

Please sign in to comment.