Title: [266068] trunk/LayoutTests
Revision
266068
Author
you...@apple.com
Date
2020-08-24 10:17:55 -0700 (Mon, 24 Aug 2020)

Log Message

Add a test showing the difference of behavior when closing a WebSocket connection between legacy WebSocket and NSURLSession WebSocket code paths
https://bugs.webkit.org/show_bug.cgi?id=215766

Reviewed by Alex Christensen.

Add a test showing the difference of behavior at connection close time in python websocket script.
This behavior was previously covered in http/tests/websocket/tests/hybi/close-on-* tests.
The test is written so that Chrome, Firefox and NSURLSession WebSocket code path generate all PASS.
Legacy WebSocket code path generates one FAIL.

* http/tests/websocket/tests/hybi/close-and-exceptions_wsh.py: Added.
* http/tests/websocket/tests/hybi/close-and-server-script-exception-expected.txt: Added.
* http/tests/websocket/tests/hybi/close-and-server-script-exception.html: Added.
* http/tests/websocket/tests/hybi/resources/close-and-server-script-exception-iframe.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (266067 => 266068)


--- trunk/LayoutTests/ChangeLog	2020-08-24 17:13:04 UTC (rev 266067)
+++ trunk/LayoutTests/ChangeLog	2020-08-24 17:17:55 UTC (rev 266068)
@@ -1,3 +1,20 @@
+2020-08-24  Youenn Fablet  <you...@apple.com>
+
+        Add a test showing the difference of behavior when closing a WebSocket connection between legacy WebSocket and NSURLSession WebSocket code paths
+        https://bugs.webkit.org/show_bug.cgi?id=215766
+
+        Reviewed by Alex Christensen.
+
+        Add a test showing the difference of behavior at connection close time in python websocket script.
+        This behavior was previously covered in http/tests/websocket/tests/hybi/close-on-* tests.
+        The test is written so that Chrome, Firefox and NSURLSession WebSocket code path generate all PASS.
+        Legacy WebSocket code path generates one FAIL.
+
+        * http/tests/websocket/tests/hybi/close-and-exceptions_wsh.py: Added.
+        * http/tests/websocket/tests/hybi/close-and-server-script-exception-expected.txt: Added.
+        * http/tests/websocket/tests/hybi/close-and-server-script-exception.html: Added.
+        * http/tests/websocket/tests/hybi/resources/close-and-server-script-exception-iframe.html: Added.
+
 2020-08-24  Hector Lopez  <hector_i_lo...@apple.com>
 
         [ iOS wk2 ] http/tests/websocket/tests/hybi/client-close-2.html is a flaky failure

Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/close-and-exceptions_wsh.py (0 => 266068)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/close-and-exceptions_wsh.py	                        (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/close-and-exceptions_wsh.py	2020-08-24 17:17:55 UTC (rev 266068)
@@ -0,0 +1,55 @@
+# Copyright 2009, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+from mod_pywebsocket import msgutil
+
+
+connections = {}
+
+
+def web_socket_do_extra_handshake(request):
+    pass  # Always accept.
+
+
+def web_socket_transfer_data(request):
+    global connections
+    connections[request] = True
+    socketName = None
+    receivedException = True
+    try:
+        socketName = msgutil.receive_message(request)
+        msgutil.send_message(request, socketName)
+        msgutil.receive_message(request)  # wait, and exception by close.
+        receivedException = False
+    finally:
+        # We keep track of whether we have an exception.
+        del connections[request]
+        for ws in connections.keys():
+            msgutil.send_message(ws, "Closed by exception" if receivedException else "Closed without exception")

Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/close-and-server-script-exception-expected.txt (0 => 266068)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/close-and-server-script-exception-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/close-and-server-script-exception-expected.txt	2020-08-24 17:17:55 UTC (rev 266068)
@@ -0,0 +1,12 @@
+Test how closing a connection triggers an exception in the python web socket server script or not
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS ws on master document is ready.
+PASS insert a iframe, where open ws called 'socket1'
+PASS 'socket1' is sent to the server. unload the iframe. expect receiving 'socket1' on ws...
+FAIL closedSocket should be Closed without exception. Was Closed by exception.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/close-and-server-script-exception.html (0 => 266068)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/close-and-server-script-exception.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/close-and-server-script-exception.html	2020-08-24 17:17:55 UTC (rev 266068)
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script type="text/_javascript_">
+description("Test how closing a connection triggers an exception in the python web socket server script or not");
+
+window.jsTestIsAsync = true;
+
+var frameDiv;
+var closedSocket;
+
+var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/close-and-exceptions");
+ws._onopen_ = function()
+{
+    debug("PASS ws on master document is ready.");
+    frameDiv = document.createElement("iframe");
+    frameDiv.src = ""
+    document.body.appendChild(frameDiv);
+    debug("PASS insert a iframe, where open ws called 'socket1'");
+};
+ws._onmessage_ = function(evt)
+{
+    closedSocket = evt.data;
+    ws.close();
+};
+ws._onclose_ = function()
+{
+    shouldBe("closedSocket", '"Closed without exception"');
+    finishJSTest();
+};
+
+document.iframeReady = function(data)
+{
+    debug("PASS '" + data + "' is sent to the server. unload the iframe. expect receiving 'socket1' on ws...");
+    document.body.removeChild(frameDiv);
+}; 
+
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/resources/close-and-server-script-exception-iframe.html (0 => 266068)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/resources/close-and-server-script-exception-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/resources/close-and-server-script-exception-iframe.html	2020-08-24 17:17:55 UTC (rev 266068)
@@ -0,0 +1,22 @@
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script type="text/_javascript_">
+var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/close-and-exceptions");
+ws._onopen_ = function()
+{
+    // send "socket1" to server, so that "socket1" will be broadcasted to web sockets connected to close-on-unload when this web socket is closed.
+    ws.send("socket1");
+};
+ws._onmessage_ = function(evt)
+{
+    // "socket1" is received by server, so ready to unload this document.
+    parent.document.iframeReady(evt.data);
+}
+</script>
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to