[WebSocket]Reserved bits test case should cover both extension and no-extension scenarios
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Mar 2012 01:32:28 +0000 (01:32 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Mar 2012 01:32:28 +0000 (01:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=82100

Patch by Li Yin <li.yin@intel.com> on 2012-03-28
Reviewed by Kent Tamura.

The current reserved bits test case only support extension case,
Improve test case to cover both no-extension and extension scenarios.

* http/tests/websocket/tests/hybi/reserved-bits-expected.txt:
* http/tests/websocket/tests/hybi/reserved-bits.html:
* http/tests/websocket/tests/hybi/reserved-bits_wsh.py:
(web_socket_do_extra_handshake):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@112488 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/websocket/tests/hybi/reserved-bits-expected.txt
LayoutTests/http/tests/websocket/tests/hybi/reserved-bits.html
LayoutTests/http/tests/websocket/tests/hybi/reserved-bits_wsh.py

index a31b27c..6bc82f0 100644 (file)
@@ -1,3 +1,18 @@
+2012-03-28  Li Yin  <li.yin@intel.com>
+
+        [WebSocket]Reserved bits test case should cover both extension and no-extension scenarios
+        https://bugs.webkit.org/show_bug.cgi?id=82100
+
+        Reviewed by Kent Tamura.
+        
+        The current reserved bits test case only support extension case,
+        Improve test case to cover both no-extension and extension scenarios.
+
+        * http/tests/websocket/tests/hybi/reserved-bits-expected.txt:
+        * http/tests/websocket/tests/hybi/reserved-bits.html:
+        * http/tests/websocket/tests/hybi/reserved-bits_wsh.py:
+        (web_socket_do_extra_handshake):
+
 2012-03-28  Victor Carbune  <vcarbune@adobe.com>
 
         Added relevant test to support video controls display:none toggling.
index 63a8d61..8cf6a31 100644 (file)
@@ -1,14 +1,29 @@
+CONSOLE MESSAGE: Received unexpected compressed frame
+CONSOLE MESSAGE: One or more reserved bits are on: reserved2 = 1, reserved3 = 0
+CONSOLE MESSAGE: One or more reserved bits are on: reserved2 = 0, reserved3 = 1
 CONSOLE MESSAGE: One or more reserved bits are on: reserved2 = 1, reserved3 = 0
 CONSOLE MESSAGE: One or more reserved bits are on: reserved2 = 0, reserved3 = 1
 Test whether WebSocket rejects frames whose reserved bit is on.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
-Bit 2: Test started.
+Case compressed=false&bitNumber=1: Test started.
+onopen() was called.
+onclose() was called.
+PASS closeEvent.wasClean is false
+Case compressed=false&bitNumber=2: Test started.
+onopen() was called.
+onclose() was called.
+PASS closeEvent.wasClean is false
+Case compressed=false&bitNumber=3: Test started.
+onopen() was called.
+onclose() was called.
+PASS closeEvent.wasClean is false
+Case compressed=true&bitNumber=2: Test started.
 onopen() was called.
 onclose() was called.
 PASS closeEvent.wasClean is false
-Bit 3: Test started.
+Case compressed=true&bitNumber=3: Test started.
 onopen() was called.
 onclose() was called.
 PASS closeEvent.wasClean is false
index ec8dd33..a6973cf 100644 (file)
@@ -13,15 +13,20 @@ window.jsTestIsAsync = true;
 if (window.layoutTestController)
     layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 0);
 
+// "compressed=true&bitNumber=1" must not be included in compressedAndBitNumberParameters array.
+var compressedAndBitNumberParameters = ["compressed=false&bitNumber=1",
+                                        "compressed=false&bitNumber=2",
+                                        "compressed=false&bitNumber=3",
+                                        "compressed=true&bitNumber=2",
+                                        "compressed=true&bitNumber=3"];
 var closeEvent;
 
-// bitNumber must be 2 or 3.
-function doTest(bitNumber)
+function doTest(curTestIndex)
 {
-    var url = "ws://localhost:8880/websocket/tests/hybi/reserved-bits?bit=" + bitNumber;
+    var url = "ws://localhost:8880/websocket/tests/hybi/reserved-bits?" + compressedAndBitNumberParameters[curTestIndex];
     var ws = new WebSocket(url);
 
-    debug("Bit " + bitNumber + ": Test started.");
+    debug("Case " + compressedAndBitNumberParameters[curTestIndex] + ": Test started.");
 
     ws.onopen = function()
     {
@@ -39,14 +44,14 @@ function doTest(bitNumber)
         debug("onclose() was called.");
         closeEvent = event;
         shouldBeFalse("closeEvent.wasClean");
-        if (bitNumber === 3)
+        if (curTestIndex === compressedAndBitNumberParameters.length - 1)
             finishJSTest();
         else
-            doTest(bitNumber + 1);
+            doTest(curTestIndex + 1);
     };
 }
 
-doTest(2);
+doTest(0);
 
 </script>
 <script src="../../../../js-test-resources/js-test-post.js"></script>
index 4ad0dfd..99087be 100644 (file)
@@ -3,17 +3,22 @@ from mod_pywebsocket import common
 from mod_pywebsocket import stream
 
 
-def web_socket_do_extra_handshake(request):
-    pass
-
+bit = 0
 
-def web_socket_transfer_data(request):
-    match = re.search(r'\?bit=(\d+)$', request.ws_resource)
+def web_socket_do_extra_handshake(request):
+    match = re.search(r'\?compressed=(true|false)&bitNumber=(\d)$', request.ws_resource)
     if match is None:
         msgutil.send_message(request, 'FAIL: Query value is incorrect or missing')
         return
+    
+    global bit
+    compressed = match.group(1)
+    bit = int(match.group(2))
+    if compressed == "false":
+        request.ws_extension_processors = [] # using no extension response
+
 
-    bit = int(match.group(1))
+def web_socket_transfer_data(request):
     message = "This message should be ignored."
     if bit == 1:
         frame = stream.create_header(common.OPCODE_TEXT, len(message), 1, 1, 0, 0, 0) + message