Bug 137831

Summary: WebSocket readyState should not throw an exception ever.
Product: WebKit Reporter: Brandon Andrews <sirisian>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: ap
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   

Description Brandon Andrews 2014-10-17 12:48:31 PDT
Webkit currently throws an exception if a handshake fails and the user attempts to access the readyState member. The following exception can be seen with Webkit's implementation when a handshake is interrupted:

WebSocket connection to 'wss://example.com' failed: Connection closed before receiving a handshake response 

This should simply close the connection and set the readyState to CLOSED and call the onerror event. Having readyState throw an exception for this is unintuitive. (I don't think any other browser does this).
Comment 1 Alexey Proskuryakov 2014-10-18 23:33:24 PDT
Could you please provide a test case? Looking at the readState attribute implementation, there is no way it could possibly raise an exception on getting. It doesn't even have a way to return an exception code:

WebSocket::State WebSocket::readyState() const
{
    return m_state;
}
Comment 2 Alexey Proskuryakov 2014-10-21 19:23:06 PDT
Please feel free to re-open with a test case.