Skip to content
  • yutak@chromium.org's avatar
    WebSocket: Implement "protocol" attribute · 4d0c313f
    yutak@chromium.org authored
    https://bugs.webkit.org/show_bug.cgi?id=65248
    
    Reviewed by Kent Tamura.
    
    Source/WebCore:
    
    Tests: http/tests/websocket/tests/hybi/no-subprotocol.html (added)
           http/tests/websocket/tests/hybi/set-protocol.html (added)
           http/tests/websocket/tests/hybi/workers/no-subprotocol.html (added)
           http/tests/websocket/tests/hixie76/undefined-attributes.html (updated)
           http/tests/websocket/tests/hybi/multiple-subprotocols.html (updated)
           http/tests/websocket/tests/hybi/workers/multiple-subprotocols.html (updated)
    
    * websockets/ThreadableWebSocketChannel.h:
    Added subprotocol() function. This function is named differently from the counterpart of
    WebSocket class, because the name "protocol" can be confused with the WebSocket protocol.
    Added m_useHixie76Protocol and m_subprotocol, because these value may be used after
    m_channel has been released. Using bool should be fine, because boolean literals do not
    appear in ambiguous context.
    * websockets/ThreadableWebSocketChannelClientWrapper.cpp:
    (WebCore::ThreadableWebSocketChannelClientWrapper::ThreadableWebSocketChannelClientWrapper):
    (WebCore::ThreadableWebSocketChannelClientWrapper::subprotocol):
    (WebCore::ThreadableWebSocketChannelClientWrapper::setSubprotocol):
    * websockets/ThreadableWebSocketChannelClientWrapper.h:
    * websockets/WebSocket.cpp:
    (WebCore::WebSocket::WebSocket):
    (WebCore::WebSocket::connect):
    (WebCore::WebSocket::protocol):
    The "protocol" attribute is available only when the hybi-10 protocol is chosen.
    (WebCore::WebSocket::binaryType):
    (WebCore::WebSocket::setBinaryType):
    (WebCore::WebSocket::didConnect):
    * websockets/WebSocket.h:
    * websockets/WebSocket.idl:
    * websockets/WebSocketChannel.cpp:
    (WebCore::WebSocketChannel::subprotocol):
    * websockets/WebSocketChannel.h:
    * websockets/WorkerThreadableWebSocketChannel.cpp:
    (WebCore::WorkerThreadableWebSocketChannel::subprotocol):
    (WebCore::workerContextDidConnect):
    Subprotocol value is saved in the client wrapper object after the WebSocket connection is
    established.
    (WebCore::WorkerThreadableWebSocketChannel::Peer::didConnect):
    * websockets/WorkerThreadableWebSocketChannel.h:
    
    LayoutTests:
    
    * http/tests/websocket/tests/hixie76/undefined-attributes-expected.txt:
    * http/tests/websocket/tests/hixie76/undefined-attributes.html:
    Added a test to check "protocol" attribute.
    * http/tests/websocket/tests/hybi/multiple-subprotocols-expected.txt:
    * http/tests/websocket/tests/hybi/multiple-subprotocols.html:
    The attribute should return an empty string at first. After the connection is established,
    it should return the value of Sec-WebSocket-Protocol header in the server's handshake response.
    * http/tests/websocket/tests/hybi/no-subprotocol-expected.txt: Added.
    * http/tests/websocket/tests/hybi/no-subprotocol.html: Added.
    * http/tests/websocket/tests/hybi/set-protocol-expected.txt: Added.
    * http/tests/websocket/tests/hybi/set-protocol.html: Added.
    * http/tests/websocket/tests/hybi/workers/multiple-subprotocols-expected.txt:
    * http/tests/websocket/tests/hybi/workers/no-subprotocol-expected.txt: Added.
    * http/tests/websocket/tests/hybi/workers/no-subprotocol.html: Added.
    * http/tests/websocket/tests/hybi/workers/resources/multiple-subprotocols.js:
    (ws.onopen):
    (ws.onclose):
    (checkAfterOnClose):
    * http/tests/websocket/tests/hybi/workers/resources/no-subprotocol.js: Added.
    (ws.onopen):
    (ws.onclose):
    (checkAfterOnClose):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@92946 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    4d0c313f