WebSocket: Accept multiple subprotocols
https://bugs.webkit.org/show_bug.cgi?id=65247
Reviewed by Kent Tamura.
Source/WebCore:
WebSocket constructor should accept an array of subprotocols if hybi-10 protocol is chosen.
Tests: http/tests/websocket/tests/hybi/invalid-subprotocol-characters.html
http/tests/websocket/tests/hybi/invalid-subprotocols.html
http/tests/websocket/tests/hybi/multiple-subprotocols.html
http/tests/websocket/tests/hybi/workers/multiple-subprotocols.html
* bindings/js/JSWebSocketCustom.cpp:
(WebCore::JSWebSocketConstructor::constructJSWebSocket):
If the second argument of WebSocket constructor is an array, build a Vector<String> and
pass it to WebSocket::connect().
* bindings/v8/custom/V8WebSocketCustom.cpp:
(WebCore::V8WebSocket::constructorCallback):
Ditto.
* websockets/WebSocket.cpp:
(WebCore::isValidProtocolCharacter): Added.
(WebCore::isValidProtocolString): Added.
(WebCore::isValidProtocolStringHixie76): Renamed from isValidProtocolString.
(WebCore::joinStrings):
(WebCore::WebSocket::connect):
If an array is provided as a subprotocol, and if hixie-76 is used for this connection, it
must be converted to a string in the same manner as JavaScript's Array.toString() in order
to keep compatibility.
* websockets/WebSocket.h:
Removed m_protocol because it was not used at all.
* websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::disconnect):
WebSocketChannel may be released before connect() is called, thus m_handshake may be null.
LayoutTests:
Add tests to check whether WebSocket accepts multiple subprotocols in constructor.
* http/tests/websocket/tests/hybi/accept-first-subprotocol_wsh.py: Added.
* http/tests/websocket/tests/hybi/invalid-subprotocol-characters-expected.txt: Added.
* http/tests/websocket/tests/hybi/invalid-subprotocol-characters.html: Added.
* http/tests/websocket/tests/hybi/invalid-subprotocols-expected.txt: Added.
* http/tests/websocket/tests/hybi/invalid-subprotocols.html: Added.
* http/tests/websocket/tests/hybi/multiple-subprotocols-expected.txt: Renamed from LayoutTests/http/tests/websocket/tests/hybi/sub-protocol-with-space-expected.txt.
* http/tests/websocket/tests/hybi/multiple-subprotocols.html: Added.
* http/tests/websocket/tests/hybi/sub-protocol-with-space-expected.txt: Removed.
* http/tests/websocket/tests/hybi/sub-protocol-with-space.html:
Removed because hybi-10 does not allow subprotocols containing a space.
* http/tests/websocket/tests/hybi/workers/multiple-subprotocols-expected.txt: Added.
* http/tests/websocket/tests/hybi/workers/multiple-subprotocols.html: Added.
* http/tests/websocket/tests/hybi/workers/resources/multiple-subprotocols.js: Added.
(ws.onopen):
(ws.onmessage):
(ws.onclose):
* http/tests/websocket/tests/hybi/workers/resources/protocol-test_wsh.py: Copied from http/tests/websocket/tests/hybi/protocol-test_wsh.py.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@92757
268f45cc-cd09-0410-ab3c-
d52691b4dbfc