Changeset 148968 in webkit


Ignore:
Timestamp:
Apr 23, 2013 8:53:15 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

WebSocket: Return type of send() should be void if hybi-10 protocol is chosen
https://bugs.webkit.org/show_bug.cgi?id=65850

Patch by Lamarque V. Souza <Lamarque.Souza@basyskom.com> on 2013-04-23
Reviewed by Alexey Proskuryakov.

Source/WebCore:

WebSocket API draft changed the return type of send() from boolean to void based on Simon
Pieters' post to WHATWG. Firefox 8 and IE 10 already follow the specification, hence it should
make sense for us to do the same when hybi protocol is used.

Original patch by Yuta Kitamura <yutak@chromium.org>

Tests: http/tests/websocket/tests/hybi/bufferedAmount-after-close.html (updated)

http/tests/websocket/tests/hybi/send-after-close-on-unload.html (updated)

  • Modules/websockets/WebSocket.cpp:

(WebCore::WebSocket::send):

  • Modules/websockets/WebSocket.h:
  • Modules/websockets/WebSocket.idl:

LayoutTests:

Update tests and test results because WebSocket.send() now returns undefined when
the hybi WebSocket protocol is used.

  • http/tests/websocket/tests/hybi/bufferedAmount-after-close-expected.txt:
  • http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy-expected.txt:
  • http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html:
  • http/tests/websocket/tests/hybi/bufferedAmount-after-close.html:
  • http/tests/websocket/tests/hybi/send-after-close-on-unload-expected.txt:
  • http/tests/websocket/tests/hybi/send-after-close-on-unload.html:
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r148965 r148968  
     12013-04-23  Lamarque V. Souza  <Lamarque.Souza@basyskom.com>
     2
     3        WebSocket: Return type of send() should be void if hybi-10 protocol is chosen
     4        https://bugs.webkit.org/show_bug.cgi?id=65850
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        Update tests and test results because WebSocket.send() now returns undefined when
     9        the hybi WebSocket protocol is used.
     10
     11        * http/tests/websocket/tests/hybi/bufferedAmount-after-close-expected.txt:
     12        * http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy-expected.txt:
     13        * http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html:
     14        * http/tests/websocket/tests/hybi/bufferedAmount-after-close.html:
     15        * http/tests/websocket/tests/hybi/send-after-close-on-unload-expected.txt:
     16        * http/tests/websocket/tests/hybi/send-after-close-on-unload.html:
     17
    1182013-04-23  Andreas Kling  <akling@apple.com>
    219
  • trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-expected.txt

    r94482 r148968  
    88PASS ws.bufferedAmount is 0
    99Testing send(string)...
    10 PASS ws.send(messageToSend) is false
     10PASS ws.send(messageToSend) is undefined.
    1111PASS bufferedAmountDifference is 27
    12 PASS ws.send(messageToSend) is false
     12PASS ws.send(messageToSend) is undefined.
    1313PASS bufferedAmountDifference is 6
    14 PASS ws.send(messageToSend) is false
     14PASS ws.send(messageToSend) is undefined.
    1515PASS bufferedAmountDifference is 7
    16 PASS ws.send(messageToSend) is false
     16PASS ws.send(messageToSend) is undefined.
    1717PASS bufferedAmountDifference is 131
    18 PASS ws.send(messageToSend) is false
     18PASS ws.send(messageToSend) is undefined.
    1919PASS bufferedAmountDifference is 134
    20 PASS ws.send(messageToSend) is false
     20PASS ws.send(messageToSend) is undefined.
    2121PASS bufferedAmountDifference is 65543
    22 PASS ws.send(messageToSend) is false
     22PASS ws.send(messageToSend) is undefined.
    2323PASS bufferedAmountDifference is 65550
    2424Testing send(ArrayBuffer)...
    25 PASS ws.send(messageToSend) is false
     25PASS ws.send(messageToSend) is undefined.
    2626PASS bufferedAmountDifference is 6
    27 PASS ws.send(messageToSend) is false
     27PASS ws.send(messageToSend) is undefined.
    2828PASS bufferedAmountDifference is 7
    29 PASS ws.send(messageToSend) is false
     29PASS ws.send(messageToSend) is undefined.
    3030PASS bufferedAmountDifference is 131
    31 PASS ws.send(messageToSend) is false
     31PASS ws.send(messageToSend) is undefined.
    3232PASS bufferedAmountDifference is 134
    33 PASS ws.send(messageToSend) is false
     33PASS ws.send(messageToSend) is undefined.
    3434PASS bufferedAmountDifference is 65543
    35 PASS ws.send(messageToSend) is false
     35PASS ws.send(messageToSend) is undefined.
    3636PASS bufferedAmountDifference is 65550
    3737Testing send(Blob)...
    38 PASS ws.send(messageToSend) is false
     38PASS ws.send(messageToSend) is undefined.
    3939PASS bufferedAmountDifference is 6
    40 PASS ws.send(messageToSend) is false
     40PASS ws.send(messageToSend) is undefined.
    4141PASS bufferedAmountDifference is 7
    42 PASS ws.send(messageToSend) is false
     42PASS ws.send(messageToSend) is undefined.
    4343PASS bufferedAmountDifference is 131
    44 PASS ws.send(messageToSend) is false
     44PASS ws.send(messageToSend) is undefined.
    4545PASS bufferedAmountDifference is 134
    46 PASS ws.send(messageToSend) is false
     46PASS ws.send(messageToSend) is undefined.
    4747PASS bufferedAmountDifference is 65543
    48 PASS ws.send(messageToSend) is false
     48PASS ws.send(messageToSend) is undefined.
    4949PASS bufferedAmountDifference is 65550
    5050PASS successfullyParsed is true
  • trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy-expected.txt

    r101730 r148968  
    99PASS ws.bufferedAmount <= bufferedAmountAfterClose is true
    1010Testing send(string)...
    11 PASS ws.send(messageToSend) is false
     11PASS ws.send(messageToSend) is undefined.
    1212PASS bufferedAmountDifference is 27
    13 PASS ws.send(messageToSend) is false
     13PASS ws.send(messageToSend) is undefined.
    1414PASS bufferedAmountDifference is 6
    15 PASS ws.send(messageToSend) is false
     15PASS ws.send(messageToSend) is undefined.
    1616PASS bufferedAmountDifference is 7
    17 PASS ws.send(messageToSend) is false
     17PASS ws.send(messageToSend) is undefined.
    1818PASS bufferedAmountDifference is 131
    19 PASS ws.send(messageToSend) is false
     19PASS ws.send(messageToSend) is undefined.
    2020PASS bufferedAmountDifference is 134
    21 PASS ws.send(messageToSend) is false
     21PASS ws.send(messageToSend) is undefined.
    2222PASS bufferedAmountDifference is 65543
    23 PASS ws.send(messageToSend) is false
     23PASS ws.send(messageToSend) is undefined.
    2424PASS bufferedAmountDifference is 65550
    2525Testing send(ArrayBuffer)...
    26 PASS ws.send(messageToSend) is false
     26PASS ws.send(messageToSend) is undefined.
    2727PASS bufferedAmountDifference is 6
    28 PASS ws.send(messageToSend) is false
     28PASS ws.send(messageToSend) is undefined.
    2929PASS bufferedAmountDifference is 7
    30 PASS ws.send(messageToSend) is false
     30PASS ws.send(messageToSend) is undefined.
    3131PASS bufferedAmountDifference is 131
    32 PASS ws.send(messageToSend) is false
     32PASS ws.send(messageToSend) is undefined.
    3333PASS bufferedAmountDifference is 134
    34 PASS ws.send(messageToSend) is false
     34PASS ws.send(messageToSend) is undefined.
    3535PASS bufferedAmountDifference is 65543
    36 PASS ws.send(messageToSend) is false
     36PASS ws.send(messageToSend) is undefined.
    3737PASS bufferedAmountDifference is 65550
    3838Testing send(Blob)...
    39 PASS ws.send(messageToSend) is false
     39PASS ws.send(messageToSend) is undefined.
    4040PASS bufferedAmountDifference is 6
    41 PASS ws.send(messageToSend) is false
     41PASS ws.send(messageToSend) is undefined.
    4242PASS bufferedAmountDifference is 7
    43 PASS ws.send(messageToSend) is false
     43PASS ws.send(messageToSend) is undefined.
    4444PASS bufferedAmountDifference is 131
    45 PASS ws.send(messageToSend) is false
     45PASS ws.send(messageToSend) is undefined.
    4646PASS bufferedAmountDifference is 134
    47 PASS ws.send(messageToSend) is false
     47PASS ws.send(messageToSend) is undefined.
    4848PASS bufferedAmountDifference is 65543
    49 PASS ws.send(messageToSend) is false
     49PASS ws.send(messageToSend) is undefined.
    5050PASS bufferedAmountDifference is 65550
    5151PASS successfullyParsed is true
  • trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html

    r122256 r148968  
    9797    messageToSend = message;
    9898    var bufferedAmountBeforeSend = ws.bufferedAmount;
    99     shouldBeFalse("ws.send(messageToSend)");
     99    shouldBeUndefined("ws.send(messageToSend)");
    100100    var bufferedAmountAfterSend = ws.bufferedAmount;
    101101    bufferedAmountDifference = bufferedAmountAfterSend - bufferedAmountBeforeSend;
  • trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html

    r122256 r148968  
    7878    messageToSend = message;
    7979    var bufferedAmountBeforeSend = ws.bufferedAmount;
    80     shouldBeFalse("ws.send(messageToSend)");
     80    shouldBeUndefined("ws.send(messageToSend)");
    8181    var bufferedAmountAfterSend = ws.bufferedAmount;
    8282    bufferedAmountDifference = bufferedAmountAfterSend - bufferedAmountBeforeSend;
  • trunk/LayoutTests/http/tests/websocket/tests/hybi/send-after-close-on-unload-expected.txt

    r90726 r148968  
    77PASS document.childWebSocket is non-null.
    88PASS 'socket1' is sent to the server. unload the iframe. expect receiving 'socket1' on ws...
    9 PASS document.childWebSocket.send('send to closed socket') is false
     9PASS document.childWebSocket.send('send to closed socket') is undefined.
    1010PASS closedSocket is "socket1"
    1111PASS document.childWebSocket.readyState is 3
  • trunk/LayoutTests/http/tests/websocket/tests/hybi/send-after-close-on-unload.html

    r122256 r148968  
    4242    debug("PASS 'socket1' is sent to the server. unload the iframe. expect receiving 'socket1' on ws...");
    4343    document.body.removeChild(frameDiv);
    44     shouldBeFalse("document.childWebSocket.send('send to closed socket')");
     44    shouldBeUndefined("document.childWebSocket.send('send to closed socket')");
    4545};
    4646
  • trunk/Source/WebCore/ChangeLog

    r148967 r148968  
     12013-04-23  Lamarque V. Souza  <Lamarque.Souza@basyskom.com>
     2
     3        WebSocket: Return type of send() should be void if hybi-10 protocol is chosen
     4        https://bugs.webkit.org/show_bug.cgi?id=65850
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        WebSocket API draft changed the return type of send() from boolean to void based on Simon
     9        Pieters' post to WHATWG. Firefox 8 and IE 10 already follow the specification, hence it should
     10        make sense for us to do the same when hybi protocol is used.
     11
     12        Original patch by Yuta Kitamura  <yutak@chromium.org>
     13
     14        Tests: http/tests/websocket/tests/hybi/bufferedAmount-after-close.html (updated)
     15               http/tests/websocket/tests/hybi/send-after-close-on-unload.html (updated)
     16
     17        * Modules/websockets/WebSocket.cpp:
     18        (WebCore::WebSocket::send):
     19        * Modules/websockets/WebSocket.h:
     20        * Modules/websockets/WebSocket.idl:
     21
    1222013-04-23  Carlos Garcia Campos  <cgarcia@igalia.com>
    223
  • trunk/Source/WebCore/Modules/websockets/WebSocket.cpp

    r148373 r148968  
    292292}
    293293
    294 bool WebSocket::send(const String& message, ExceptionCode& ec)
     294void WebSocket::send(const String& message, ExceptionCode& ec)
    295295{
    296296    LOG(Network, "WebSocket %p send() Sending String '%s'", this, message.utf8().data());
    297297    if (m_state == CONNECTING) {
    298298        ec = INVALID_STATE_ERR;
    299         return false;
     299        return;
    300300    }
    301301    // No exception is raised if the connection was once established but has subsequently been closed.
     
    304304        m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, payloadSize);
    305305        m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, getFramingOverhead(payloadSize));
    306         return false;
     306        return;
    307307    }
    308308    ASSERT(m_channel);
     
    311311        scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Websocket message contains invalid character(s).");
    312312        ec = SYNTAX_ERR;
    313         return false;
    314     }
    315     return result == ThreadableWebSocketChannel::SendSuccess;
    316 }
    317 
    318 bool WebSocket::send(ArrayBuffer* binaryData, ExceptionCode& ec)
     313        return;
     314    }
     315}
     316
     317void WebSocket::send(ArrayBuffer* binaryData, ExceptionCode& ec)
    319318{
    320319    LOG(Network, "WebSocket %p send() Sending ArrayBuffer %p", this, binaryData);
     
    322321    if (m_state == CONNECTING) {
    323322        ec = INVALID_STATE_ERR;
    324         return false;
     323        return;
    325324    }
    326325    if (m_state == CLOSING || m_state == CLOSED) {
     
    328327        m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, payloadSize);
    329328        m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, getFramingOverhead(payloadSize));
    330         return false;
     329        return;
    331330    }
    332331    ASSERT(m_channel);
    333     return m_channel->send(*binaryData, 0, binaryData->byteLength()) == ThreadableWebSocketChannel::SendSuccess;
    334 }
    335 
    336 bool WebSocket::send(ArrayBufferView* arrayBufferView, ExceptionCode& ec)
     332    m_channel->send(*binaryData, 0, binaryData->byteLength());
     333}
     334
     335void WebSocket::send(ArrayBufferView* arrayBufferView, ExceptionCode& ec)
    337336{
    338337    LOG(Network, "WebSocket %p send() Sending ArrayBufferView %p", this, arrayBufferView);
     
    340339    if (m_state == CONNECTING) {
    341340        ec = INVALID_STATE_ERR;
    342         return false;
     341        return;
    343342    }
    344343    if (m_state == CLOSING || m_state == CLOSED) {
     
    346345        m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, payloadSize);
    347346        m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, getFramingOverhead(payloadSize));
    348         return false;
     347        return;
    349348    }
    350349    ASSERT(m_channel);
    351350    RefPtr<ArrayBuffer> arrayBuffer(arrayBufferView->buffer());
    352     return m_channel->send(*arrayBuffer, arrayBufferView->byteOffset(), arrayBufferView->byteLength()) == ThreadableWebSocketChannel::SendSuccess;
    353 }
    354 
    355 bool WebSocket::send(Blob* binaryData, ExceptionCode& ec)
     351    m_channel->send(*arrayBuffer, arrayBufferView->byteOffset(), arrayBufferView->byteLength());
     352}
     353
     354void WebSocket::send(Blob* binaryData, ExceptionCode& ec)
    356355{
    357356    LOG(Network, "WebSocket %p send() Sending Blob '%s'", this, binaryData->url().elidedString().utf8().data());
     
    359358    if (m_state == CONNECTING) {
    360359        ec = INVALID_STATE_ERR;
    361         return false;
     360        return;
    362361    }
    363362    if (m_state == CLOSING || m_state == CLOSED) {
     
    365364        m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, payloadSize);
    366365        m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, getFramingOverhead(payloadSize));
    367         return false;
     366        return;
    368367    }
    369368    ASSERT(m_channel);
    370     return m_channel->send(*binaryData) == ThreadableWebSocketChannel::SendSuccess;
     369    m_channel->send(*binaryData);
    371370}
    372371
  • trunk/Source/WebCore/Modules/websockets/WebSocket.h

    r134221 r148968  
    7373    void connect(const String& url, const Vector<String>& protocols, ExceptionCode&);
    7474
    75     bool send(const String& message, ExceptionCode&);
    76     bool send(ArrayBuffer*, ExceptionCode&);
    77     bool send(ArrayBufferView*, ExceptionCode&);
    78     bool send(Blob*, ExceptionCode&);
     75    void send(const String& message, ExceptionCode&);
     76    void send(ArrayBuffer*, ExceptionCode&);
     77    void send(ArrayBufferView*, ExceptionCode&);
     78    void send(Blob*, ExceptionCode&);
    7979
    8080    void close(int code, const String& reason, ExceptionCode&);
  • trunk/Source/WebCore/Modules/websockets/WebSocket.idl

    r138138 r148968  
    6565    attribute DOMString binaryType;
    6666
    67     boolean send(in ArrayBuffer data)
     67    void send(in ArrayBuffer data)
    6868        raises(DOMException);
    69     boolean send(in ArrayBufferView data)
     69    void send(in ArrayBufferView data)
    7070        raises(DOMException);
    71     boolean send(in Blob data)
     71    void send(in Blob data)
    7272        raises(DOMException);
    73     boolean send(in DOMString data)
     73    void send(in DOMString data)
    7474        raises(DOMException);
    7575
Note: See TracChangeset for help on using the changeset viewer.