Title: [148968] trunk
Revision
148968
Author
[email protected]
Date
2013-04-23 08:53:15 -0700 (Tue, 23 Apr 2013)

Log 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 <[email protected]> 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  <[email protected]>

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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (148967 => 148968)


--- trunk/LayoutTests/ChangeLog	2013-04-23 15:11:25 UTC (rev 148967)
+++ trunk/LayoutTests/ChangeLog	2013-04-23 15:53:15 UTC (rev 148968)
@@ -1,3 +1,20 @@
+2013-04-23  Lamarque V. Souza  <[email protected]>
+
+        WebSocket: Return type of send() should be void if hybi-10 protocol is chosen
+        https://bugs.webkit.org/show_bug.cgi?id=65850
+
+        Reviewed by Alexey Proskuryakov.
+
+        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:
+
 2013-04-23  Andreas Kling  <[email protected]>
 
         Clear StyleResolver state before returning from styleForElement().

Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-expected.txt (148967 => 148968)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-expected.txt	2013-04-23 15:11:25 UTC (rev 148967)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-expected.txt	2013-04-23 15:53:15 UTC (rev 148968)
@@ -7,45 +7,45 @@
 PASS ws.readyState is 3
 PASS ws.bufferedAmount is 0
 Testing send(string)...
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 27
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 6
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 7
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 131
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 134
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 65543
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 65550
 Testing send(ArrayBuffer)...
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 6
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 7
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 131
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 134
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 65543
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 65550
 Testing send(Blob)...
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 6
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 7
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 131
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 134
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 65543
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 65550
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy-expected.txt (148967 => 148968)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy-expected.txt	2013-04-23 15:11:25 UTC (rev 148967)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy-expected.txt	2013-04-23 15:53:15 UTC (rev 148968)
@@ -8,45 +8,45 @@
 PASS ws.readyState is 3
 PASS ws.bufferedAmount <= bufferedAmountAfterClose is true
 Testing send(string)...
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 27
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 6
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 7
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 131
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 134
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 65543
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 65550
 Testing send(ArrayBuffer)...
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 6
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 7
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 131
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 134
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 65543
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 65550
 Testing send(Blob)...
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 6
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 7
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 131
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 134
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 65543
-PASS ws.send(messageToSend) is false
+PASS ws.send(messageToSend) is undefined.
 PASS bufferedAmountDifference is 65550
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html (148967 => 148968)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html	2013-04-23 15:11:25 UTC (rev 148967)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html	2013-04-23 15:53:15 UTC (rev 148968)
@@ -96,7 +96,7 @@
     // (the number does not reset to zero once the connection closes).
     messageToSend = message;
     var bufferedAmountBeforeSend = ws.bufferedAmount;
-    shouldBeFalse("ws.send(messageToSend)");
+    shouldBeUndefined("ws.send(messageToSend)");
     var bufferedAmountAfterSend = ws.bufferedAmount;
     bufferedAmountDifference = bufferedAmountAfterSend - bufferedAmountBeforeSend;
     shouldEvaluateTo("bufferedAmountDifference", expectedBufferedAmountDifference);

Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html (148967 => 148968)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html	2013-04-23 15:11:25 UTC (rev 148967)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html	2013-04-23 15:53:15 UTC (rev 148968)
@@ -77,7 +77,7 @@
     // (the number does not reset to zero once the connection closes).
     messageToSend = message;
     var bufferedAmountBeforeSend = ws.bufferedAmount;
-    shouldBeFalse("ws.send(messageToSend)");
+    shouldBeUndefined("ws.send(messageToSend)");
     var bufferedAmountAfterSend = ws.bufferedAmount;
     bufferedAmountDifference = bufferedAmountAfterSend - bufferedAmountBeforeSend;
     shouldEvaluateTo("bufferedAmountDifference", expectedBufferedAmountDifference);

Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/send-after-close-on-unload-expected.txt (148967 => 148968)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/send-after-close-on-unload-expected.txt	2013-04-23 15:11:25 UTC (rev 148967)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/send-after-close-on-unload-expected.txt	2013-04-23 15:53:15 UTC (rev 148968)
@@ -6,7 +6,7 @@
 PASS insert a iframe, where open ws called 'socket1'
 PASS document.childWebSocket is non-null.
 PASS 'socket1' is sent to the server. unload the iframe. expect receiving 'socket1' on ws...
-PASS document.childWebSocket.send('send to closed socket') is false
+PASS document.childWebSocket.send('send to closed socket') is undefined.
 PASS closedSocket is "socket1"
 PASS document.childWebSocket.readyState is 3
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/send-after-close-on-unload.html (148967 => 148968)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/send-after-close-on-unload.html	2013-04-23 15:11:25 UTC (rev 148967)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/send-after-close-on-unload.html	2013-04-23 15:53:15 UTC (rev 148968)
@@ -41,7 +41,7 @@
     shouldBeNonNull("document.childWebSocket");
     debug("PASS 'socket1' is sent to the server. unload the iframe. expect receiving 'socket1' on ws...");
     document.body.removeChild(frameDiv);
-    shouldBeFalse("document.childWebSocket.send('send to closed socket')");
+    shouldBeUndefined("document.childWebSocket.send('send to closed socket')");
 };
 
 </script>

Modified: trunk/Source/WebCore/ChangeLog (148967 => 148968)


--- trunk/Source/WebCore/ChangeLog	2013-04-23 15:11:25 UTC (rev 148967)
+++ trunk/Source/WebCore/ChangeLog	2013-04-23 15:53:15 UTC (rev 148968)
@@ -1,3 +1,24 @@
+2013-04-23  Lamarque V. Souza  <[email protected]>
+
+        WebSocket: Return type of send() should be void if hybi-10 protocol is chosen
+        https://bugs.webkit.org/show_bug.cgi?id=65850
+
+        Reviewed by Alexey Proskuryakov.
+
+        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  <[email protected]>
+
+        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:
+
 2013-04-23  Carlos Garcia Campos  <[email protected]>
 
         ScrollbarThemeComposite depends on Page/FrameView/ChromeClient

Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.cpp (148967 => 148968)


--- trunk/Source/WebCore/Modules/websockets/WebSocket.cpp	2013-04-23 15:11:25 UTC (rev 148967)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.cpp	2013-04-23 15:53:15 UTC (rev 148968)
@@ -291,83 +291,82 @@
     ActiveDOMObject::setPendingActivity(this);
 }
 
-bool WebSocket::send(const String& message, ExceptionCode& ec)
+void WebSocket::send(const String& message, ExceptionCode& ec)
 {
     LOG(Network, "WebSocket %p send() Sending String '%s'", this, message.utf8().data());
     if (m_state == CONNECTING) {
         ec = INVALID_STATE_ERR;
-        return false;
+        return;
     }
     // No exception is raised if the connection was once established but has subsequently been closed.
     if (m_state == CLOSING || m_state == CLOSED) {
         size_t payloadSize = message.utf8().length();
         m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, payloadSize);
         m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, getFramingOverhead(payloadSize));
-        return false;
+        return;
     }
     ASSERT(m_channel);
     ThreadableWebSocketChannel::SendResult result = m_channel->send(message);
     if (result == ThreadableWebSocketChannel::InvalidMessage) {
         scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Websocket message contains invalid character(s).");
         ec = SYNTAX_ERR;
-        return false;
+        return;
     }
-    return result == ThreadableWebSocketChannel::SendSuccess;
 }
 
-bool WebSocket::send(ArrayBuffer* binaryData, ExceptionCode& ec)
+void WebSocket::send(ArrayBuffer* binaryData, ExceptionCode& ec)
 {
     LOG(Network, "WebSocket %p send() Sending ArrayBuffer %p", this, binaryData);
     ASSERT(binaryData);
     if (m_state == CONNECTING) {
         ec = INVALID_STATE_ERR;
-        return false;
+        return;
     }
     if (m_state == CLOSING || m_state == CLOSED) {
         unsigned payloadSize = binaryData->byteLength();
         m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, payloadSize);
         m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, getFramingOverhead(payloadSize));
-        return false;
+        return;
     }
     ASSERT(m_channel);
-    return m_channel->send(*binaryData, 0, binaryData->byteLength()) == ThreadableWebSocketChannel::SendSuccess;
+    m_channel->send(*binaryData, 0, binaryData->byteLength());
 }
 
-bool WebSocket::send(ArrayBufferView* arrayBufferView, ExceptionCode& ec)
+void WebSocket::send(ArrayBufferView* arrayBufferView, ExceptionCode& ec)
 {
     LOG(Network, "WebSocket %p send() Sending ArrayBufferView %p", this, arrayBufferView);
     ASSERT(arrayBufferView);
     if (m_state == CONNECTING) {
         ec = INVALID_STATE_ERR;
-        return false;
+        return;
     }
     if (m_state == CLOSING || m_state == CLOSED) {
         unsigned payloadSize = arrayBufferView->byteLength();
         m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, payloadSize);
         m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, getFramingOverhead(payloadSize));
-        return false;
+        return;
     }
     ASSERT(m_channel);
     RefPtr<ArrayBuffer> arrayBuffer(arrayBufferView->buffer());
-    return m_channel->send(*arrayBuffer, arrayBufferView->byteOffset(), arrayBufferView->byteLength()) == ThreadableWebSocketChannel::SendSuccess;
+    m_channel->send(*arrayBuffer, arrayBufferView->byteOffset(), arrayBufferView->byteLength());
 }
 
-bool WebSocket::send(Blob* binaryData, ExceptionCode& ec)
+void WebSocket::send(Blob* binaryData, ExceptionCode& ec)
 {
     LOG(Network, "WebSocket %p send() Sending Blob '%s'", this, binaryData->url().elidedString().utf8().data());
     ASSERT(binaryData);
     if (m_state == CONNECTING) {
         ec = INVALID_STATE_ERR;
-        return false;
+        return;
     }
     if (m_state == CLOSING || m_state == CLOSED) {
         unsigned long payloadSize = static_cast<unsigned long>(binaryData->size());
         m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, payloadSize);
         m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, getFramingOverhead(payloadSize));
-        return false;
+        return;
     }
     ASSERT(m_channel);
-    return m_channel->send(*binaryData) == ThreadableWebSocketChannel::SendSuccess;
+    m_channel->send(*binaryData);
 }
 
 void WebSocket::close(int code, const String& reason, ExceptionCode& ec)

Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.h (148967 => 148968)


--- trunk/Source/WebCore/Modules/websockets/WebSocket.h	2013-04-23 15:11:25 UTC (rev 148967)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.h	2013-04-23 15:53:15 UTC (rev 148968)
@@ -72,10 +72,10 @@
     void connect(const String& url, const String& protocol, ExceptionCode&);
     void connect(const String& url, const Vector<String>& protocols, ExceptionCode&);
 
-    bool send(const String& message, ExceptionCode&);
-    bool send(ArrayBuffer*, ExceptionCode&);
-    bool send(ArrayBufferView*, ExceptionCode&);
-    bool send(Blob*, ExceptionCode&);
+    void send(const String& message, ExceptionCode&);
+    void send(ArrayBuffer*, ExceptionCode&);
+    void send(ArrayBufferView*, ExceptionCode&);
+    void send(Blob*, ExceptionCode&);
 
     void close(int code, const String& reason, ExceptionCode&);
     void close(ExceptionCode& ec) { close(WebSocketChannel::CloseEventCodeNotSpecified, String(), ec); }

Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.idl (148967 => 148968)


--- trunk/Source/WebCore/Modules/websockets/WebSocket.idl	2013-04-23 15:11:25 UTC (rev 148967)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.idl	2013-04-23 15:53:15 UTC (rev 148968)
@@ -64,13 +64,13 @@
 
     attribute DOMString binaryType;
 
-    boolean send(in ArrayBuffer data)
+    void send(in ArrayBuffer data)
         raises(DOMException);
-    boolean send(in ArrayBufferView data)
+    void send(in ArrayBufferView data)
         raises(DOMException);
-    boolean send(in Blob data)
+    void send(in Blob data)
         raises(DOMException);
-    boolean send(in DOMString data)
+    void send(in DOMString data)
         raises(DOMException);
 
     void close(in [Clamp, Optional] unsigned short code, in [Optional] DOMString reason) raises(DOMException);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to