Currently, the codes that report WebSocket errors to JavaScript console are scaterred among various places in WebCore. This sounds ad-hoc, and could be improved. We could add a function to WebSocketChannel (and ThreadableWebSocketChannel, WorkerThreadableWebSocketChannel) that corresponds to "fail the WebSocket connection" algorithm in the WebSocket protocol specification (*1), like: class WebSocketChannel { ... void fail(const String& errorMessage); // Log the error to JavaScript console, and do close(). ... }; ... and use it in places where we need to "fail the WebSocket connection". I think this change will make the code more readable and easier to track. (*1) In the WebSocket protocol specification, an algorithm called "fail the WebSocket connection" is defined: http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-00#section-6.1 Certain algorithms require the user agent to *fail the WebSocket connection*. To do so, the user agent must close the WebSocket connection, and may report the problem to the user (which would be especially useful for developers).
This is done!