Skip to content
  • yutak@chromium.org's avatar
    WebSocket: Send Blob as WebSocket binary message · 729efea7
    yutak@chromium.org authored
    https://bugs.webkit.org/show_bug.cgi?id=67465
    
    Reviewed by Kent Tamura.
    
    Source/WebCore:
    
    Tests: http/tests/websocket/tests/hixie76/send-empty.html
           http/tests/websocket/tests/hixie76/send-object.html
           http/tests/websocket/tests/hybi/send-blob.html
           http/tests/websocket/tests/hybi/send-empty.html
           http/tests/websocket/tests/hybi/send-file-blob-fail.html
           http/tests/websocket/tests/hybi/send-file-blob.html
           http/tests/websocket/tests/hybi/workers/send-blob.html
           http/tests/websocket/tests/hybi/bufferedAmount-after-close.html (updated)
    
    * bindings/js/JSWebSocketCustom.cpp:
    (WebCore::JSWebSocket::send):
    * bindings/v8/custom/V8WebSocketCustom.cpp:
    (WebCore::V8WebSocket::sendCallback):
    * websockets/ThreadableWebSocketChannel.h:
    * websockets/WebSocket.cpp:
    (WebCore::WebSocket::send):
    * websockets/WebSocket.h:
    * websockets/WebSocket.idl:
    Fixing code generator did not sound easy, because there are some classes depending on
    broken behavior of current code generator (one such example is CanvasRenderingContext2D).
    As a temporary workaround, new custom handlers for send() are added.
    * websockets/WebSocketChannel.cpp:
    (WebCore::WebSocketChannel::send):
    * websockets/WebSocketChannel.h:
    * websockets/WorkerThreadableWebSocketChannel.cpp:
    (WebCore::WorkerThreadableWebSocketChannel::send):
    (WebCore::WorkerThreadableWebSocketChannel::Peer::send):
    (WebCore::WorkerThreadableWebSocketChannel::mainThreadSendBlob):
    A Blob can be deserialized from url, type and size.
    (WebCore::WorkerThreadableWebSocketChannel::Bridge::send):
    KURL, String and long long (corresponding to url, type and size, respectively) can be passed
    safely across threads.
    * websockets/WorkerThreadableWebSocketChannel.h:
    
    LayoutTests:
    
    * http/tests/websocket/tests/hixie76/send-empty-expected.txt: Added.
    * http/tests/websocket/tests/hixie76/send-empty.html: Added.
    * http/tests/websocket/tests/hixie76/send-object-expected.txt: Added.
    * http/tests/websocket/tests/hixie76/send-object.html: Added.
    * http/tests/websocket/tests/hybi/bufferedAmount-after-close-expected.txt:
    * http/tests/websocket/tests/hybi/bufferedAmount-after-close.html:
    Updated. Added tests to send Blobs.
    * http/tests/websocket/tests/hybi/send-blob-expected.txt: Added.
    * http/tests/websocket/tests/hybi/send-blob.html:
    Added. Send three Blobs each of which contains a small binary message.
    * http/tests/websocket/tests/hybi/send-blob_wsh.py:
    Added. receive_message() returns a unicode value if the received message was text, or
    a str value if the message was binary.
    * http/tests/websocket/tests/hybi/send-empty-expected.txt: Added.
    * http/tests/websocket/tests/hybi/send-empty.html: Added.
    * http/tests/websocket/tests/hybi/send-file-blob-expected.txt: Added.
    * http/tests/websocket/tests/hybi/send-file-blob-fail-expected.txt: Added.
    * http/tests/websocket/tests/hybi/send-file-blob-fail.html:
    Added. If we delete a file before reading it, FileReaderLoader reliably fails.
    * http/tests/websocket/tests/hybi/send-file-blob.html:
    Added. Create a File and try to send it as a Blob.
    * http/tests/websocket/tests/hybi/send-file-blob_wsh.py: Added.
    * http/tests/websocket/tests/hybi/workers/resources/send-blob.js:
    Added. Same as send-blob.html above.
    * http/tests/websocket/tests/hybi/workers/resources/send-blob_wsh.py:
    Added. Same as send-blob_wsh.py above.
    * http/tests/websocket/tests/hybi/workers/send-blob-expected.txt: Added.
    * http/tests/websocket/tests/hybi/workers/send-blob.html: Added.
    * platform/gtk/Skipped:
    send-file-blob.html and send-file-blob-fail.html depend on availability of File API.
    * platform/mac/Skipped: Ditto.
    * platform/qt/Skipped: Ditto.
    * platform/win/Skipped: Ditto.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@94399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    729efea7