Title: [148019] trunk
Revision
148019
Author
[email protected]
Date
2013-04-09 06:45:14 -0700 (Tue, 09 Apr 2013)

Log Message

[WebSocket] Ignore incoming message in CLOSING state
https://bugs.webkit.org/show_bug.cgi?id=85934

Patch by Lamarque V. Souza <[email protected]> on 2013-04-09
Reviewed by Kent Tamura.

Source/WebCore:

Change WebSocket implementation to suit the new WebSocket API, which
states that we should ignore messages in CLOSING state.

No new tests, updating existing tests.

* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::didReceiveMessage):

LayoutTests:

* http/tests/websocket/tests/hybi/client-close-expected.txt: Rebaseline.
* http/tests/websocket/tests/hybi/client-close.html: Change expected results.
* http/tests/websocket/tests/hybi/client-close_wsh.py: Embed message in close frame
instead of using regular message sending call.
* http/tests/websocket/tests/hybi/fragmented-frames.html: Call WebSocket.close()
only after receiving all messages from server.
* http/tests/websocket/tests/hybi/unmasked-frames.html: Remove extra
WebSocket.close() call that caused regression.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (148018 => 148019)


--- trunk/LayoutTests/ChangeLog	2013-04-09 13:26:06 UTC (rev 148018)
+++ trunk/LayoutTests/ChangeLog	2013-04-09 13:45:14 UTC (rev 148019)
@@ -1,3 +1,19 @@
+2013-04-09  Lamarque V. Souza  <[email protected]>
+
+        [WebSocket] Ignore incoming message in CLOSING state
+        https://bugs.webkit.org/show_bug.cgi?id=85934
+
+        Reviewed by Kent Tamura.
+
+        * http/tests/websocket/tests/hybi/client-close-expected.txt: Rebaseline.
+        * http/tests/websocket/tests/hybi/client-close.html: Change expected results.
+        * http/tests/websocket/tests/hybi/client-close_wsh.py: Embed message in close frame
+        instead of using regular message sending call.
+        * http/tests/websocket/tests/hybi/fragmented-frames.html: Call WebSocket.close()
+        only after receiving all messages from server.
+        * http/tests/websocket/tests/hybi/unmasked-frames.html: Remove extra
+        WebSocket.close() call that caused regression.
+
 2013-04-09  Raphael Kubo da Costa  <[email protected]>
 
         [EFL] Move tables/mozilla_expected_failures/bugs/bug89315.html's expectations to efl/.

Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/client-close-expected.txt (148018 => 148019)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/client-close-expected.txt	2013-04-09 13:26:06 UTC (rev 148018)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/client-close-expected.txt	2013-04-09 13:45:14 UTC (rev 148019)
@@ -1,11 +1,11 @@
-WebSocket: Test client-initiated close.
+WebSocket: Test client-initiated close. After WebSocket.close() any message from server must be discarded by WebSocket stack according to the new WebSocket API. See http://webkit.org/b/85934.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 Connected
-Received: close_frame[:2]='\x88\x80'
 Closed
-PASS receivedMessage is "close_frame[:2]='\\x88\\x80'"
+PASS receivedMessage is undefined.
+PASS closeEvent.reason is "close_frame[:2]='\\x88\\x80'"
 PASS closeEvent.wasClean is true
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/client-close.html (148018 => 148019)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/client-close.html	2013-04-09 13:26:06 UTC (rev 148018)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/client-close.html	2013-04-09 13:45:14 UTC (rev 148019)
@@ -1,13 +1,13 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<!DOCTYPE HTML>
 <html>
 <head>
-<script src=""
+<script src=""
 </head>
 <body>
 <div id="description"></div>
 <div id="console"></div>
 <script type="text/_javascript_">
-description("WebSocket: Test client-initiated close.");
+description("WebSocket: Test client-initiated close. After WebSocket.close() any message from server must be discarded by WebSocket stack according to the new WebSocket API. See http://webkit.org/b/85934.");
 
 window.jsTestIsAsync = true;
 
@@ -23,7 +23,7 @@
 
 ws._onmessage_ = function(messageEvent)
 {
-    debug("Received: " + messageEvent.data);
+    debug("Message should have been ignored: " + messageEvent.data);
     receivedMessage = messageEvent.data;
 };
 
@@ -31,7 +31,8 @@
 {
     debug("Closed");
     closeEvent = event;
-    shouldBeEqualToString("receivedMessage", "close_frame[:2]='\\x88\\x80'");
+    shouldBeUndefined("receivedMessage");
+    shouldBeEqualToString("closeEvent.reason", "close_frame[:2]='\\x88\\x80'");
     shouldBeTrue("closeEvent.wasClean");
     finishJSTest();
 };

Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/client-close_wsh.py (148018 => 148019)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/client-close_wsh.py	2013-04-09 13:26:06 UTC (rev 148018)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/client-close_wsh.py	2013-04-09 13:45:14 UTC (rev 148019)
@@ -1,6 +1,8 @@
+import struct
+
 from mod_pywebsocket import msgutil
+from mod_pywebsocket import stream
 
-
 def web_socket_do_extra_handshake(request):
     pass
 
@@ -9,9 +11,12 @@
     # Wait for a close frame sent from the client.
     close_frame = request.ws_stream.receive_bytes(6)
 
+    msgutil.send_message(request, 'Client should ignore this message')
+
     # Send only first two bytes of the received frame. The remaining four bytes are
     # "masking key", which changes every time the test runs.
-    msgutil.send_message(request, 'close_frame[:2]=%r' % close_frame[:2])
+    data = "" 1000) + 'close_frame[:2]=%r' % close_frame[:2]
+    request.connection.write(stream.create_close_frame(data))
 
     # If the following assertion fails, AssertionError will be raised,
     # which will prevent pywebsocket from sending a close frame.

Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/fragmented-frames.html (148018 => 148019)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/fragmented-frames.html	2013-04-09 13:26:06 UTC (rev 148018)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/fragmented-frames.html	2013-04-09 13:45:14 UTC (rev 148019)
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML>
 <html>
 <head>
-<script src=""
+<script src=""
 </head>
 <body>
 <div id="description"></div>
@@ -20,7 +20,6 @@
 ws._onopen_ = function()
 {
     debug("onopen() was called.");
-    ws.close();
 };
 
 ws._onmessage_ = function(event)
@@ -28,6 +27,9 @@
     var message = event.data;
     debug("onmessage() was called. (message = \"" + message + "\")");
     actualMessages.push(message);
+
+    if (actualMessages.length == 3)
+        ws.close();
 };
 
 ws._onclose_ = function(event)

Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/unmasked-frames.html (148018 => 148019)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/unmasked-frames.html	2013-04-09 13:26:06 UTC (rev 148018)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/unmasked-frames.html	2013-04-09 13:45:14 UTC (rev 148019)
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML>
 <html>
 <head>
-<script src=""
+<script src=""
 </head>
 <body>
 <div id="description"></div>
@@ -20,7 +20,6 @@
 ws._onopen_ = function()
 {
     debug("onopen() was called.");
-    ws.close();
 };
 
 ws._onmessage_ = function(event)

Modified: trunk/Source/WebCore/ChangeLog (148018 => 148019)


--- trunk/Source/WebCore/ChangeLog	2013-04-09 13:26:06 UTC (rev 148018)
+++ trunk/Source/WebCore/ChangeLog	2013-04-09 13:45:14 UTC (rev 148019)
@@ -1,3 +1,18 @@
+2013-04-09  Lamarque V. Souza  <[email protected]>
+
+        [WebSocket] Ignore incoming message in CLOSING state
+        https://bugs.webkit.org/show_bug.cgi?id=85934
+
+        Reviewed by Kent Tamura.
+
+        Change WebSocket implementation to suit the new WebSocket API, which
+        states that we should ignore messages in CLOSING state.
+
+        No new tests, updating existing tests.
+
+        * Modules/websockets/WebSocket.cpp:
+        (WebCore::WebSocket::didReceiveMessage):
+
 2013-04-09  Seokju Kwon  <[email protected]>
 
         Web Inspector: Add Localized strings after r144154 and r135127

Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.cpp (148018 => 148019)


--- trunk/Source/WebCore/Modules/websockets/WebSocket.cpp	2013-04-09 13:26:06 UTC (rev 148018)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.cpp	2013-04-09 13:45:14 UTC (rev 148019)
@@ -513,7 +513,7 @@
 void WebSocket::didReceiveMessage(const String& msg)
 {
     LOG(Network, "WebSocket %p didReceiveMessage() Text message '%s'", this, msg.utf8().data());
-    if (m_state != OPEN && m_state != CLOSING)
+    if (m_state != OPEN)
         return;
     ASSERT(scriptExecutionContext());
     dispatchEvent(MessageEvent::create(msg, SecurityOrigin::create(m_url)->toString()));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to