[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>
Mon, 2 Apr 2012 02:53:32 +0000 (02:53 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Apr 2012 02:53:32 +0000 (02:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=82100

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

Source/WebCore:

When it had no negotiated deflate-frame extension, if browser received the frame with
setting compressed bit, it should fail the connection, and it should cover both
enabling ZLIB port and disabling ZLIB port.

Test:  http/tests/websocket/tests/hybi/reserved-bits.html

* Modules/websockets/WebSocketDeflateFramer.cpp:
(WebCore::WebSocketDeflateFramer::inflate):

LayoutTests:

Solve the problem that Qt Webkit failed when runing the reserved-bits.html
Support both enabled ZLIB and disabled ZLIB scenarios.

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

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@112826 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_wsh.py
Source/WebCore/ChangeLog
Source/WebCore/Modules/websockets/WebSocketDeflateFramer.cpp

index 2e117b8..4d959a6 100644 (file)
@@ -1,3 +1,18 @@
+2012-04-01  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.
+
+        Solve the problem that Qt Webkit failed when runing the reserved-bits.html
+        Support both enabled ZLIB and disabled ZLIB scenarios.
+
+        * http/tests/websocket/tests/hybi/reserved-bits-expected.txt:
+        * http/tests/websocket/tests/hybi/reserved-bits_wsh.py:
+        (_get_deflate_frame_extension_processor):
+        (web_socket_do_extra_handshake):
+
 2012-04-01  Adam Barth  <abarth@webkit.org>
 
         Clean up Document::canNavigate
index 8cf6a31..df275b2 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: Received unexpected compressed frame
+CONSOLE MESSAGE: Compressed bit must be 0 if no negotiated deflate-frame extension
 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
index 99087be..d19d1f7 100644 (file)
@@ -1,10 +1,17 @@
 import re
 from mod_pywebsocket import common
 from mod_pywebsocket import stream
-
+from mod_pywebsocket.extensions import DeflateFrameExtensionProcessor
 
 bit = 0
 
+def _get_deflate_frame_extension_processor(request):
+    for extension_processor in request.ws_extension_processors:
+        if isinstance(extension_processor, DeflateFrameExtensionProcessor):
+            return extension_processor
+    return None
+
+
 def web_socket_do_extra_handshake(request):
     match = re.search(r'\?compressed=(true|false)&bitNumber=(\d)$', request.ws_resource)
     if match is None:
@@ -16,6 +23,10 @@ def web_socket_do_extra_handshake(request):
     bit = int(match.group(2))
     if compressed == "false":
         request.ws_extension_processors = [] # using no extension response
+    else:
+        processor = _get_deflate_frame_extension_processor(request)
+        if not processor:
+            request.ws_extension_processors = [] # using no extension response
 
 
 def web_socket_transfer_data(request):
index ee6b7e5..c7639d9 100644 (file)
@@ -1,3 +1,19 @@
+2012-04-01  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.
+
+        When it had no negotiated deflate-frame extension, if browser received the frame with
+        setting compressed bit, it should fail the connection, and it should cover both
+        enabling ZLIB port and disabling ZLIB port.
+
+        Test:  http/tests/websocket/tests/hybi/reserved-bits.html 
+
+        * Modules/websockets/WebSocketDeflateFramer.cpp:
+        (WebCore::WebSocketDeflateFramer::inflate):
+
 2012-04-01  Adam Barth  <abarth@webkit.org>
 
         Clean up Document::canNavigate
index 67f9533..76c040d 100644 (file)
@@ -217,11 +217,15 @@ void WebSocketDeflateFramer::resetDeflateContext()
 
 PassOwnPtr<InflateResultHolder> WebSocketDeflateFramer::inflate(WebSocketFrame& frame)
 {
-#if USE(ZLIB)
     OwnPtr<InflateResultHolder> result = InflateResultHolder::create(this);
+    if (!enabled() && frame.compress) {
+        result->fail("Compressed bit must be 0 if no negotiated deflate-frame extension");
+        return result.release();
+    }
+#if USE(ZLIB)
     if (!frame.compress)
         return result.release();
-    if (!enabled() || !WebSocketFrame::isNonControlOpCode(frame.opCode)) {
+    if (!WebSocketFrame::isNonControlOpCode(frame.opCode)) {
         result->fail("Received unexpected compressed frame");
         return result.release();
     }
@@ -234,7 +238,7 @@ PassOwnPtr<InflateResultHolder> WebSocketDeflateFramer::inflate(WebSocketFrame&
     frame.payloadLength = m_inflater->size();
     return result.release();
 #else
-    return InflateResultHolder::create(this);
+    return result.release();
 #endif
 }