[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9

ukai at chromium.org ukai at chromium.org
Thu Feb 4 21:22:35 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit a7e762baae4c2ded651d7d51ac4b05577b5d4356
Author: ukai at chromium.org <ukai at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jan 21 02:41:20 2010 +0000

    2010-01-20  Fumitoshi Ukai  <ukai at chromium.org>
    
            Reviewed by Alexey Proskuryakov.
    
            WebSocket: Request-URI should not be empty when no tralling slash in host
            https://bugs.webkit.org/show_bug.cgi?id=33689
    
            * websocket/tests/handler_map.txt: Added.
              use websocket/tests/echo-location_wsh.py to handle request for
              ws://127.0.0.1:8880
            * websocket/tests/script-tests/url-no-trailing-slash.js: Added.
            * websocket/tests/url-no-trailing-slash-expected.txt: Added.
            * websocket/tests/url-no-trailing-slash.html: Added.
    2010-01-20  Fumitoshi Ukai  <ukai at chromium.org>
    
            Reviewed by Alexey Proskuryakov.
    
            WebSocket: Request-URI should not be empty when no tralling slash in host
            https://bugs.webkit.org/show_bug.cgi?id=33689
    
            Test: websocket/tests/url-no-trailing-slash.html
    
            * websockets/WebSocketHandshake.cpp:
            (WebCore::resourceName):
    2010-01-20  Fumitoshi Ukai  <ukai at chromium.org>
    
            Reviewed by Alexey Proskuryakov.
    
            WebSocket: Missing Request-URI, when no tralling slash in host
            https://bugs.webkit.org/show_bug.cgi?id=33689
    
            Update pywebsocket to 0.4.7.1, which supports alias for resource
            name, so that we could test for ws://127.0.0.1:8880
    
            * Scripts/run-webkit-tests:
            * Scripts/run-webkit-websocketserver:
            * pywebsocket/mod_pywebsocket/dispatch.py:
            * pywebsocket/mod_pywebsocket/handshake.py:
            * pywebsocket/mod_pywebsocket/standalone.py:
            * pywebsocket/setup.py:
            * pywebsocket/test/test_dispatch.py:
            * pywebsocket/test/test_handshake.py:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53592 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 881a97c..12c8844 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2010-01-20  Fumitoshi Ukai  <ukai at chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        WebSocket: Request-URI should not be empty when no tralling slash in host
+        https://bugs.webkit.org/show_bug.cgi?id=33689
+
+        * websocket/tests/handler_map.txt: Added.
+          use websocket/tests/echo-location_wsh.py to handle request for
+          ws://127.0.0.1:8880
+        * websocket/tests/script-tests/url-no-trailing-slash.js: Added.
+        * websocket/tests/url-no-trailing-slash-expected.txt: Added.
+        * websocket/tests/url-no-trailing-slash.html: Added.
+
 2010-01-20  Daniel Bates  <dbates at webkit.org>
 
         Reviewed by Tor Arne Vestbø.
diff --git a/LayoutTests/websocket/tests/handler_map.txt b/LayoutTests/websocket/tests/handler_map.txt
new file mode 100644
index 0000000..6649dc8
--- /dev/null
+++ b/LayoutTests/websocket/tests/handler_map.txt
@@ -0,0 +1,3 @@
+# websocket handler map file.
+# request to '/' will be handled by echo-location_wsh.py
+/ /websocket/tests/echo-location
diff --git a/LayoutTests/websocket/tests/script-tests/url-no-trailing-slash.js b/LayoutTests/websocket/tests/script-tests/url-no-trailing-slash.js
new file mode 100644
index 0000000..4e8d920
--- /dev/null
+++ b/LayoutTests/websocket/tests/script-tests/url-no-trailing-slash.js
@@ -0,0 +1,35 @@
+description("URL that doesn't have trailing slash should not emit empty Request-URI.");
+
+if (window.layoutTestController)
+    layoutTestController.waitUntilDone();
+
+var url = "ws://127.0.0.1:8880";
+var handshake_success = false;
+var ws_location;
+
+function endTest()
+{
+    shouldBeTrue("handshake_success");
+    shouldBe("ws_location", '"ws://127.0.0.1:8880/"');
+    isSuccessfullyParsed();
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+
+var ws = new WebSocket(url);
+ws.onopen = function () {
+    debug("WebSocket is open");
+    handshake_success = true;
+};
+ws.onmessage = function (evt) {
+    ws_location = evt.data;
+    debug("received:" + ws_location);
+    ws.close();
+};
+ws.onclose = function () {
+    debug("WebSocket is closed");
+    endTest();
+};
+
+var successfullyParsed = true;
diff --git a/LayoutTests/websocket/tests/url-no-trailing-slash-expected.txt b/LayoutTests/websocket/tests/url-no-trailing-slash-expected.txt
new file mode 100644
index 0000000..75c90cf
--- /dev/null
+++ b/LayoutTests/websocket/tests/url-no-trailing-slash-expected.txt
@@ -0,0 +1,13 @@
+URL that doesn't have trailing slash should not emit empty Request-URI.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+WebSocket is open
+received:ws://127.0.0.1:8880/
+WebSocket is closed
+PASS handshake_success is true
+PASS ws_location is "ws://127.0.0.1:8880/"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/websocket/tests/url-no-trailing-slash.html b/LayoutTests/websocket/tests/url-no-trailing-slash.html
new file mode 100644
index 0000000..a493a67
--- /dev/null
+++ b/LayoutTests/websocket/tests/url-no-trailing-slash.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script src="script-tests/url-no-trailing-slash.js"></script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 759e18c..47f3eb2 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,15 @@
+2010-01-20  Fumitoshi Ukai  <ukai at chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        WebSocket: Request-URI should not be empty when no tralling slash in host
+        https://bugs.webkit.org/show_bug.cgi?id=33689
+
+        Test: websocket/tests/url-no-trailing-slash.html
+
+        * websockets/WebSocketHandshake.cpp:
+        (WebCore::resourceName):
+
 2010-01-20  Daniel Bates  <dbates at webkit.org>
 
         Reviewed by Tor Arne Vestbø.
diff --git a/WebCore/websockets/WebSocketHandshake.cpp b/WebCore/websockets/WebSocketHandshake.cpp
index a568c2b..f2d6436 100644
--- a/WebCore/websockets/WebSocketHandshake.cpp
+++ b/WebCore/websockets/WebSocketHandshake.cpp
@@ -76,9 +76,14 @@ static String extractResponseCode(const char* header, int len)
 
 static String resourceName(const KURL& url)
 {
-    if (url.query().isNull())
-        return url.path();
-    return url.path() + "?" + url.query();
+    String name = url.path();
+    if (name.isEmpty())
+        name = "/";
+    if (!url.query().isNull())
+        name += "?" + url.query();
+    ASSERT(!name.isEmpty());
+    ASSERT(!name.contains(' '));
+    return name;
 }
 
 WebSocketHandshake::WebSocketHandshake(const KURL& url, const String& protocol, ScriptExecutionContext* context)
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 2c42df6..79b0d4a 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,22 @@
+2010-01-20  Fumitoshi Ukai  <ukai at chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        WebSocket: Missing Request-URI, when no tralling slash in host
+        https://bugs.webkit.org/show_bug.cgi?id=33689
+
+        Update pywebsocket to 0.4.7.1, which supports alias for resource
+        name, so that we could test for ws://127.0.0.1:8880
+
+        * Scripts/run-webkit-tests:
+        * Scripts/run-webkit-websocketserver:
+        * pywebsocket/mod_pywebsocket/dispatch.py:
+        * pywebsocket/mod_pywebsocket/handshake.py:
+        * pywebsocket/mod_pywebsocket/standalone.py:
+        * pywebsocket/setup.py:
+        * pywebsocket/test/test_dispatch.py:
+        * pywebsocket/test/test_handshake.py:
+
 2010-01-20  Eric Seidel  <eric at webkit.org>
 
         No review, rolling out r53537.
diff --git a/WebKitTools/Scripts/run-webkit-tests b/WebKitTools/Scripts/run-webkit-tests
index be2f847..bb4fb34 100755
--- a/WebKitTools/Scripts/run-webkit-tests
+++ b/WebKitTools/Scripts/run-webkit-tests
@@ -1373,6 +1373,7 @@ sub openWebSocketServerIfNeeded()
     my $webSocketPythonPath = "WebKitTools/pywebsocket";
     my $webSocketHandlerDir = "$testDirectory";
     my $webSocketHandlerScanDir = "$testDirectory/websocket/tests";
+    my $webSocketHandlerMapFile = "$webSocketHandlerScanDir/handler_map.txt";
     my $sslCertificate = "$testDirectory/http/conf/webkit-httpd.pem";
     my $absTestResultsDirectory = resolveAndMakeTestResultsDirectory();
     my $logFile = "$absTestResultsDirectory/pywebsocket_log.txt";
@@ -1382,6 +1383,7 @@ sub openWebSocketServerIfNeeded()
         "-p", "$webSocketPort",
         "-d", "$webSocketHandlerDir",
         "-s", "$webSocketHandlerScanDir",
+        "-m", "$webSocketHandlerMapFile",
         "-l", "$logFile",
         "--strict",
     );
diff --git a/WebKitTools/Scripts/run-webkit-websocketserver b/WebKitTools/Scripts/run-webkit-websocketserver
index e05303a..bbc5af6 100755
--- a/WebKitTools/Scripts/run-webkit-websocketserver
+++ b/WebKitTools/Scripts/run-webkit-websocketserver
@@ -67,12 +67,14 @@ sub openWebSocketServer()
     my $webSocketPythonPath = "$srcDir/WebKitTools/pywebsocket";
     my $webSocketHandlerDir = "$testDirectory";
     my $webSocketHandlerScanDir = "$testDirectory/websocket/tests";
+    my $webSocketHandlerMapFile = "$webSocketHandlerScanDir/handler_map.txt";
 
     my @args = (
         "$srcDir/WebKitTools/pywebsocket/mod_pywebsocket/standalone.py",
         "-p", "$webSocketPort",
         "-d", "$webSocketHandlerDir",
         "-s", "$webSocketHandlerScanDir",
+        "-m", "$webSocketHandlerMapFile",
     );
 
     $ENV{"PYTHONPATH"} = $webSocketPythonPath;
diff --git a/WebKitTools/pywebsocket/mod_pywebsocket/dispatch.py b/WebKitTools/pywebsocket/mod_pywebsocket/dispatch.py
index bf9a856..c52e9eb 100644
--- a/WebKitTools/pywebsocket/mod_pywebsocket/dispatch.py
+++ b/WebKitTools/pywebsocket/mod_pywebsocket/dispatch.py
@@ -142,6 +142,23 @@ class Dispatcher(object):
                                 'root_dir:%s.' % (scan_dir, root_dir))
         self._source_files_in_dir(root_dir, scan_dir)
 
+    def add_resource_path_alias(self,
+                                alias_resource_path, existing_resource_path):
+        """Add resource path alias.
+
+        Once added, request to alias_resource_path would be handled by
+        handler registered for existing_resource_path.
+
+        Args:
+            alias_resource_path: alias resource path
+            existing_resource_path: existing resource path
+        """
+        try:
+            handler = self._handlers[existing_resource_path]
+            self._handlers[alias_resource_path] = handler
+        except KeyError:
+            raise DispatchError('No handler for: %r' % existing_resource_path)
+
     def source_warnings(self):
         """Return warnings in sourcing handlers."""
 
diff --git a/WebKitTools/pywebsocket/mod_pywebsocket/handshake.py b/WebKitTools/pywebsocket/mod_pywebsocket/handshake.py
index 50d8c80..b86278e 100644
--- a/WebKitTools/pywebsocket/mod_pywebsocket/handshake.py
+++ b/WebKitTools/pywebsocket/mod_pywebsocket/handshake.py
@@ -56,7 +56,7 @@ _MANDATORY_HEADERS = [
 ]
 
 _FIRST_FIVE_LINES = map(re.compile, [
-    r'^GET /[\S]+ HTTP/1.1\r\n$',
+    r'^GET /[\S]* HTTP/1.1\r\n$',
     r'^Upgrade: WebSocket\r\n$',
     r'^Connection: Upgrade\r\n$',
     r'^Host: [\S]+\r\n$',
diff --git a/WebKitTools/pywebsocket/mod_pywebsocket/standalone.py b/WebKitTools/pywebsocket/mod_pywebsocket/standalone.py
index 9822a75..0e6a349 100644
--- a/WebKitTools/pywebsocket/mod_pywebsocket/standalone.py
+++ b/WebKitTools/pywebsocket/mod_pywebsocket/standalone.py
@@ -38,6 +38,7 @@ Usage:
     python standalone.py [-p <ws_port>] [-w <websock_handlers>]
                          [-s <scan_dir>]
                          [-d <document_root>]
+                         [-m <websock_handlers_map_file>]
                          ... for other options, see _main below ...
 
 <ws_port> is the port number to use for ws:// connection.
@@ -63,6 +64,7 @@ import logging
 import logging.handlers
 import optparse
 import os
+import re
 import socket
 import sys
 
@@ -280,6 +282,31 @@ def _configure_logging(options):
     handler.setFormatter(formatter)
     logger.addHandler(handler)
 
+def _alias_handlers(dispatcher, websock_handlers_map_file):
+    """Set aliases specified in websock_handler_map_file in dispatcher.
+
+    Args:
+        dispatcher: dispatch.Dispatcher instance
+        websock_handler_map_file: alias map file
+    """
+    fp = open(websock_handlers_map_file)
+    try:
+        for line in fp:
+            if line[0] == '#' or line.isspace():
+                continue
+            m = re.match('(\S+)\s+(\S+)', line)
+            if not m:
+                logging.warning('Wrong format in map file:' + line)
+                continue
+            try:
+                dispatcher.add_resource_path_alias(
+                    m.group(1), m.group(2))
+            except dispatch.DispatchError, e:
+                logging.error(str(e))
+    finally:
+        fp.close()
+
+
 
 def _main():
     parser = optparse.OptionParser()
@@ -289,6 +316,12 @@ def _main():
     parser.add_option('-w', '--websock_handlers', dest='websock_handlers',
                       default='.',
                       help='Web Socket handlers root directory.')
+    parser.add_option('-m', '--websock_handlers_map_file',
+                      dest='websock_handlers_map_file',
+                      default=None,
+                      help=('Web Socket handlers map file. '
+                            'Each line consists of alias_resource_path and '
+                            'existing_resource_path, separated by spaces.'))
     parser.add_option('-s', '--scan_dir', dest='scan_dir',
                       default=None,
                       help=('Web Socket handlers scan directory. '
@@ -344,6 +377,9 @@ def _main():
         # instantiation.  Dispatcher can be shared because it is thread-safe.
         options.dispatcher = dispatch.Dispatcher(options.websock_handlers,
                                                  options.scan_dir)
+        if options.websock_handlers_map_file:
+            _alias_handlers(options.dispatcher,
+                            options.websock_handlers_map_file)
         _print_warnings_if_any(options.dispatcher)
 
         WebSocketRequestHandler.options = options
diff --git a/WebKitTools/pywebsocket/setup.py b/WebKitTools/pywebsocket/setup.py
index 6f6acc6..a49c943 100644
--- a/WebKitTools/pywebsocket/setup.py
+++ b/WebKitTools/pywebsocket/setup.py
@@ -56,7 +56,7 @@ setup(author='Yuzo Fujishima',
       name=_PACKAGE_NAME,
       packages=[_PACKAGE_NAME],
       url='http://code.google.com/p/pywebsocket/',
-      version='0.4.6',
+      version='0.4.7.1',
       )
 
 
diff --git a/WebKitTools/pywebsocket/test/test_dispatch.py b/WebKitTools/pywebsocket/test/test_dispatch.py
index b19d706..5403228 100644
--- a/WebKitTools/pywebsocket/test/test_dispatch.py
+++ b/WebKitTools/pywebsocket/test/test_dispatch.py
@@ -225,6 +225,17 @@ class DispatcherTest(unittest.TestCase):
         self.assertRaises(dispatch.DispatchError,
                           dispatch.Dispatcher, 'a/b/c', 'a/b')
 
+    def test_resource_path_alias(self):
+        disp = dispatch.Dispatcher(_TEST_HANDLERS_DIR, None)
+        disp.add_resource_path_alias('/', '/origin_check')
+        self.assertEqual(4, len(disp._handlers))
+        self.failUnless(disp._handlers.has_key('/origin_check'))
+        self.failUnless(disp._handlers.has_key('/sub/exception_in_transfer'))
+        self.failUnless(disp._handlers.has_key('/sub/plain'))
+        self.failUnless(disp._handlers.has_key('/'))
+        self.assertRaises(dispatch.DispatchError,
+                          disp.add_resource_path_alias, '/alias', '/not-exist')
+
 
 if __name__ == '__main__':
     unittest.main()
diff --git a/WebKitTools/pywebsocket/test/test_handshake.py b/WebKitTools/pywebsocket/test/test_handshake.py
index 1d69b2d..8bf07be 100644
--- a/WebKitTools/pywebsocket/test/test_handshake.py
+++ b/WebKitTools/pywebsocket/test/test_handshake.py
@@ -258,6 +258,14 @@ _STRICTLY_GOOD_REQUESTS = (
         'Cookie: abc\r\n'
         '\r\n',
     ),
+    (
+        'GET / HTTP/1.1\r\n',
+        'Upgrade: WebSocket\r\n',
+        'Connection: Upgrade\r\n',
+        'Host: example.com\r\n',
+        'Origin: http://example.com\r\n',
+        '\r\n',
+    ),
 )
 
 _NOT_STRICTLY_GOOD_REQUESTS = (

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list