[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.22-985-g3c00f00
ukai at chromium.org
ukai at chromium.org
Wed Mar 17 18:29:32 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 5dbe42d860f54ccb524e06dfa2a0e2fffeb3db1b
Author: ukai at chromium.org <ukai at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Mar 9 10:40:49 2010 +0000
2010-03-03 Fumitoshi Ukai <ukai at chromium.org>
Reviewed by Alexey Proskuryakov.
pywebsocket should support html and cgi in the same directory.
https://bugs.webkit.org/show_bug.cgi?id=34879
* websocket/tests/cookies: Removed.
* websocket/tests/cookies/echo-cookie_wsh.py: Removed.
* websocket/tests/cookies/httponly-cookie-expected.txt: Removed.
* websocket/tests/cookies/httponly-cookie.pl: Removed.
* websocket/tests/echo-cookie_wsh.py: Copied from LayoutTests/websocket/tests/cookies/echo-cookie_wsh.py.
* websocket/tests/httponly-cookie-expected.txt: Copied from LayoutTests/websocket/tests/cookies/httponly-cookie-expected.txt.
* websocket/tests/httponly-cookie.pl: Copied from LayoutTests/websocket/tests/cookies/httponly-cookie.pl.
2010-03-03 Fumitoshi Ukai <ukai at chromium.org>
Reviewed by Alexey Proskuryakov.
pywebsocket should support html and cgi in the same directory.
https://bugs.webkit.org/show_bug.cgi?id=34879
Import pywebsocket 0.4.9.2
Specify --server-host 127.0.0.1, so that it only binds listening socket
to 127.0.0.1 to prevent access from non-localhost.
Change --cgi-paths from /websocket/tests/cookies to /websocket/tests,
because pywebsocket 0.4.9.2 supports html and cgi in the same directory
and only executable (httponly-cookies.pl) will be handled as cgi
script.
* Scripts/run-webkit-tests:
* Scripts/run-webkit-websocketserver:
* Scripts/webkitpy/layout_tests/port/websocket_server.py:
* Scripts/webkitpy/thirdparty/pywebsocket/README.webkit:
* Scripts/webkitpy/thirdparty/pywebsocket/example/echo_client.py:
* Scripts/webkitpy/thirdparty/pywebsocket/example/handler_map.txt: Added.
* Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/standalone.py:
* Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/util.py:
* Scripts/webkitpy/thirdparty/pywebsocket/setup.py:
* Scripts/webkitpy/thirdparty/pywebsocket/test/test_util.py:
* Scripts/webkitpy/thirdparty/pywebsocket/test/testdata/README: Added.
* Scripts/webkitpy/thirdparty/pywebsocket/test/testdata/hello.pl: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55719 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index baa34d5..02349f6 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,18 @@
+2010-03-03 Fumitoshi Ukai <ukai at chromium.org>
+
+ Reviewed by Alexey Proskuryakov.
+
+ pywebsocket should support html and cgi in the same directory.
+ https://bugs.webkit.org/show_bug.cgi?id=34879
+
+ * websocket/tests/cookies: Removed.
+ * websocket/tests/cookies/echo-cookie_wsh.py: Removed.
+ * websocket/tests/cookies/httponly-cookie-expected.txt: Removed.
+ * websocket/tests/cookies/httponly-cookie.pl: Removed.
+ * websocket/tests/echo-cookie_wsh.py: Copied from LayoutTests/websocket/tests/cookies/echo-cookie_wsh.py.
+ * websocket/tests/httponly-cookie-expected.txt: Copied from LayoutTests/websocket/tests/cookies/httponly-cookie-expected.txt.
+ * websocket/tests/httponly-cookie.pl: Copied from LayoutTests/websocket/tests/cookies/httponly-cookie.pl.
+
2010-03-08 Kent Tamura <tkent at chromium.org>
Reviewed by Adam Barth.
diff --git a/LayoutTests/websocket/tests/cookies/httponly-cookie.pl b/LayoutTests/websocket/tests/cookies/httponly-cookie.pl
deleted file mode 100755
index ed07f1a..0000000
--- a/LayoutTests/websocket/tests/cookies/httponly-cookie.pl
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/perl -wT
-use strict;
-
-print "Content-Type: text/html\r\n";
-print "Set-Cookie: WK-websocket-test=1\r\n";
-print "Set-Cookie: WK-websocket-test-httponly=1; HttpOnly\r\n";
-print "\r\n";
-print <<HTML
-<html>
-<head>
-<script src="../../../fast/js/resources/js-test-pre.js"></script>
-<script src="../../../fast/js/resources/js-test-post-function.js"></script>
-</head>
-<body>
-<p>Test WebSocket sends HttpOnly cookies.</p>
-<p>On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".</p>
-<div id="console"></div>
-<script>
-if (window.layoutTestController) {
- layoutTestController.dumpAsText();
- layoutTestController.waitUntilDone();
-}
-
-var cookie;
-
-function endTest()
-{
- shouldBe("cookie", '"WK-websocket-test=1; WK-websocket-test-httponly=1"');
- isSuccessfullyParsed();
- if (window.layoutTestController)
- layoutTestController.notifyDone();
-}
-
-var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/cookies/echo-cookie");
-ws.onopen = function() {
- debug("WebSocket open");
-};
-ws.onmessage = function(evt) {
- cookie = evt.data;
- ws.close();
-};
-ws.onclose = function() {
- debug("WebSocket closed");
- endTest();
-};
-
-var successfullyParsed = true;
-</script>
-</body>
-</html>
-HTML
diff --git a/LayoutTests/websocket/tests/cookies/echo-cookie_wsh.py b/LayoutTests/websocket/tests/echo-cookie_wsh.py
similarity index 100%
rename from LayoutTests/websocket/tests/cookies/echo-cookie_wsh.py
rename to LayoutTests/websocket/tests/echo-cookie_wsh.py
diff --git a/LayoutTests/websocket/tests/cookies/httponly-cookie-expected.txt b/LayoutTests/websocket/tests/httponly-cookie-expected.txt
similarity index 100%
rename from LayoutTests/websocket/tests/cookies/httponly-cookie-expected.txt
rename to LayoutTests/websocket/tests/httponly-cookie-expected.txt
diff --git a/LayoutTests/websocket/tests/httponly-cookie.pl b/LayoutTests/websocket/tests/httponly-cookie.pl
new file mode 100755
index 0000000..066d0c8
--- /dev/null
+++ b/LayoutTests/websocket/tests/httponly-cookie.pl
@@ -0,0 +1,51 @@
+#!/usr/bin/perl -wT
+use strict;
+
+print "Content-Type: text/html\r\n";
+print "Set-Cookie: WK-websocket-test=1\r\n";
+print "Set-Cookie: WK-websocket-test-httponly=1; HttpOnly\r\n";
+print "\r\n";
+print <<HTML
+<html>
+<head>
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+</head>
+<body>
+<p>Test WebSocket sends HttpOnly cookies.</p>
+<p>On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".</p>
+<div id="console"></div>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+var cookie;
+
+function endTest()
+{
+ shouldBe("cookie", '"WK-websocket-test=1; WK-websocket-test-httponly=1"');
+ isSuccessfullyParsed();
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/echo-cookie");
+ws.onopen = function() {
+ debug("WebSocket open");
+};
+ws.onmessage = function(evt) {
+ cookie = evt.data;
+ ws.close();
+};
+ws.onclose = function() {
+ debug("WebSocket closed");
+ endTest();
+};
+
+var successfullyParsed = true;
+</script>
+</body>
+</html>
+HTML
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 4456894..1577037 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,31 @@
+2010-03-03 Fumitoshi Ukai <ukai at chromium.org>
+
+ Reviewed by Alexey Proskuryakov.
+
+ pywebsocket should support html and cgi in the same directory.
+ https://bugs.webkit.org/show_bug.cgi?id=34879
+
+ Import pywebsocket 0.4.9.2
+ Specify --server-host 127.0.0.1, so that it only binds listening socket
+ to 127.0.0.1 to prevent access from non-localhost.
+ Change --cgi-paths from /websocket/tests/cookies to /websocket/tests,
+ because pywebsocket 0.4.9.2 supports html and cgi in the same directory
+ and only executable (httponly-cookies.pl) will be handled as cgi
+ script.
+
+ * Scripts/run-webkit-tests:
+ * Scripts/run-webkit-websocketserver:
+ * Scripts/webkitpy/layout_tests/port/websocket_server.py:
+ * Scripts/webkitpy/thirdparty/pywebsocket/README.webkit:
+ * Scripts/webkitpy/thirdparty/pywebsocket/example/echo_client.py:
+ * Scripts/webkitpy/thirdparty/pywebsocket/example/handler_map.txt: Added.
+ * Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/standalone.py:
+ * Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/util.py:
+ * Scripts/webkitpy/thirdparty/pywebsocket/setup.py:
+ * Scripts/webkitpy/thirdparty/pywebsocket/test/test_util.py:
+ * Scripts/webkitpy/thirdparty/pywebsocket/test/testdata/README: Added.
+ * Scripts/webkitpy/thirdparty/pywebsocket/test/testdata/hello.pl: Added.
+
2010-03-09 Chris Jerdonek <cjerdonek at webkit.org>
Reviewed by Shinichiro Hamaji.
diff --git a/WebKitTools/Scripts/run-webkit-tests b/WebKitTools/Scripts/run-webkit-tests
index 2e41489..50701f6 100755
--- a/WebKitTools/Scripts/run-webkit-tests
+++ b/WebKitTools/Scripts/run-webkit-tests
@@ -1426,12 +1426,13 @@ sub openWebSocketServerIfNeeded()
my @args = (
"WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/standalone.py",
- "-p", "$webSocketPort",
- "-d", "$webSocketHandlerDir",
- "-s", "$webSocketHandlerScanDir",
- "-m", "$webSocketHandlerMapFile",
- "-x", "/websocket/tests/cookies",
- "-l", "$logFile",
+ "--server-host", "127.0.0.1",
+ "--port", "$webSocketPort",
+ "--document-root", "$webSocketHandlerDir",
+ "--scan-dir", "$webSocketHandlerScanDir",
+ "--websock-handlers-map-file", "$webSocketHandlerMapFile",
+ "--cgi-paths", "/websocket/tests",
+ "--log-file", "$logFile",
"--strict",
);
# wss is disabled until all platforms support pyOpenSSL.
diff --git a/WebKitTools/Scripts/run-webkit-websocketserver b/WebKitTools/Scripts/run-webkit-websocketserver
index 5b32371..f0c6704 100755
--- a/WebKitTools/Scripts/run-webkit-websocketserver
+++ b/WebKitTools/Scripts/run-webkit-websocketserver
@@ -71,11 +71,12 @@ sub openWebSocketServer()
my @args = (
"$srcDir/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/standalone.py",
- "-p", "$webSocketPort",
- "-d", "$webSocketHandlerDir",
- "-s", "$webSocketHandlerScanDir",
- "-m", "$webSocketHandlerMapFile",
- "-x", "/websocket/tests/cookies",
+ "--server-host", "127.0.0.1",
+ "--port", "$webSocketPort",
+ "--document-root", "$webSocketHandlerDir",
+ "--scan-dir", "$webSocketHandlerScanDir",
+ "--websock-handlers-map-file", "$webSocketHandlerMapFile",
+ "--cgi-paths", "/websocket/tests/cookies",
);
$ENV{"PYTHONPATH"} = $webSocketPythonPath;
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/websocket_server.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/websocket_server.py
index b4b3d97..fee1abc 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/port/websocket_server.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/websocket_server.py
@@ -158,18 +158,19 @@ class PyWebSocket(http_server.Lighttpd):
'standalone.py')
start_cmd = [
python_interp, pywebsocket_script,
- '-p', str(self._port),
- '-d', self._layout_tests,
- '-s', self._web_socket_tests,
- '-x', '/websocket/tests/cookies',
- '-l', error_log,
+ '--server-host', '127.0.0.1',
+ '--port', str(self._port),
+ '--document-root', self._layout_tests,
+ '--scan-dir', self._web_socket_tests,
+ '--cgi-paths', '/websocket/tests/cookies',
+ '--log-file', error_log,
]
handler_map_file = os.path.join(self._web_socket_tests,
'handler_map.txt')
if os.path.exists(handler_map_file):
_log.debug('Using handler_map_file: %s' % handler_map_file)
- start_cmd.append('-m')
+ start_cmd.append('--websock-handlers-map-file')
start_cmd.append(handler_map_file)
else:
_log.warning('No handler_map_file found')
diff --git a/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/README.webkit b/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/README.webkit
index bd6d93d..83e3cee 100644
--- a/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/README.webkit
+++ b/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/README.webkit
@@ -4,10 +4,10 @@ from the following location:
http://code.google.com/p/pywebsocket/
This directory currently contains the following version:
-FIXME: Fill in the current version here.
+0.4.9.2
The following modifications have been made to this local version:
-FIXME: Fill in local modifications.
+minor updates in WebSocketRequestHandler.is_cgi
More information on these local modifications can be found here:
diff --git a/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/example/echo_client.py b/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/example/echo_client.py
index 3262a6d..2b976e1 100644
--- a/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/example/echo_client.py
+++ b/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/example/echo_client.py
@@ -163,9 +163,11 @@ def main():
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
parser = OptionParser()
- parser.add_option('-s', '--server_host', dest='server_host', type='string',
+ parser.add_option('-s', '--server-host', '--server_host',
+ dest='server_host', type='string',
default='localhost', help='server host')
- parser.add_option('-p', '--server_port', dest='server_port', type='int',
+ parser.add_option('-p', '--server-port', '--server_port',
+ dest='server_port', type='int',
default=_UNDEFINED_PORT, help='server port')
parser.add_option('-o', '--origin', dest='origin', type='string',
default='http://localhost/', help='origin')
@@ -179,8 +181,8 @@ def main():
default=True, help='suppress messages')
parser.add_option('-t', '--tls', dest='use_tls', action='store_true',
default=False, help='use TLS (wss://)')
- parser.add_option('-k', '--socket_timeout', dest='socket_timeout',
- type='int', default=_TIMEOUT_SEC,
+ parser.add_option('-k', '--socket-timeout', '--socket_timeout',
+ dest='socket_timeout', type='int', default=_TIMEOUT_SEC,
help='Timeout(sec) for sockets')
(options, unused_args) = parser.parse_args()
diff --git a/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/example/handler_map.txt b/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/example/handler_map.txt
new file mode 100644
index 0000000..21c4c09
--- /dev/null
+++ b/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/example/handler_map.txt
@@ -0,0 +1,11 @@
+# websocket handler map file, used by standalone.py -m option.
+# A line starting with '#' is a comment line.
+# Each line consists of 'alias_resource_path' and 'existing_resource_path'
+# separated by spaces.
+# Aliasing is processed from the top to the bottom of the line, and
+# 'existing_resource_path' must exist before it is aliased.
+# For example,
+# / /echo
+# means that a request to '/' will be handled by handlers for '/echo'.
+/ /echo
+
diff --git a/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/standalone.py b/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/standalone.py
index 8628ff9..f411910 100644
--- a/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/standalone.py
+++ b/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/standalone.py
@@ -272,10 +272,22 @@ class WebSocketRequestHandler(CGIHTTPServer.CGIHTTPRequestHandler):
def is_cgi(self):
"""Test whether self.path corresponds to a CGI script.
- Add extra check that self.path doesn't contains .."""
+ Add extra check that self.path doesn't contains ..
+ Also check if the file is a executable file or not.
+ If the file is not executable, it is handled as static file or dir
+ rather than a CGI script.
+ """
if CGIHTTPServer.CGIHTTPRequestHandler.is_cgi(self):
if '..' in self.path:
return False
+ # strip query parameter from request path
+ resource_name = self.path.split('?', 2)[0]
+ # convert resource_name into real path name in filesystem.
+ scriptfile = self.translate_path(resource_name)
+ if not os.path.isfile(scriptfile):
+ return False
+ if not self.is_executable(scriptfile):
+ return False
return True
return False
@@ -321,26 +333,32 @@ def _alias_handlers(dispatcher, websock_handlers_map_file):
def _main():
parser = optparse.OptionParser()
+ parser.add_option('-H', '--server-host', '--server_host',
+ dest='server_host',
+ default='',
+ help='server hostname to listen to')
parser.add_option('-p', '--port', dest='port', type='int',
default=handshake._DEFAULT_WEB_SOCKET_PORT,
help='port to listen to')
- parser.add_option('-w', '--websock_handlers', dest='websock_handlers',
+ parser.add_option('-w', '--websock-handlers', '--websock_handlers',
+ dest='websock_handlers',
default='.',
help='Web Socket handlers root directory.')
- parser.add_option('-m', '--websock_handlers_map_file',
+ parser.add_option('-m', '--websock-handlers-map-file',
+ '--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',
+ parser.add_option('-s', '--scan-dir', '--scan_dir', dest='scan_dir',
default=None,
help=('Web Socket handlers scan directory. '
'Must be a directory under websock_handlers.'))
- parser.add_option('-d', '--document_root', dest='document_root',
- default='.',
+ parser.add_option('-d', '--document-root', '--document_root',
+ dest='document_root', default='.',
help='Document root directory.')
- parser.add_option('-x', '--cgi_paths', dest='cgi_paths',
+ parser.add_option('-x', '--cgi-paths', '--cgi_paths', dest='cgi_paths',
default=None,
help=('CGI paths relative to document_root.'
'Comma-separated. (e.g -x /cgi,/htbin) '
@@ -348,21 +366,22 @@ def _main():
'as CGI programs. Must be executable.'))
parser.add_option('-t', '--tls', dest='use_tls', action='store_true',
default=False, help='use TLS (wss://)')
- parser.add_option('-k', '--private_key', dest='private_key',
+ parser.add_option('-k', '--private-key', '--private_key',
+ dest='private_key',
default='', help='TLS private key file.')
parser.add_option('-c', '--certificate', dest='certificate',
default='', help='TLS certificate file.')
- parser.add_option('-l', '--log_file', dest='log_file',
+ parser.add_option('-l', '--log-file', '--log_file', dest='log_file',
default='', help='Log file.')
- parser.add_option('--log_level', type='choice', dest='log_level',
- default='warn',
+ parser.add_option('--log-level', '--log_level', type='choice',
+ dest='log_level', default='warn',
choices=['debug', 'info', 'warn', 'error', 'critical'],
help='Log level.')
- parser.add_option('--log_max', dest='log_max', type='int',
+ parser.add_option('--log-max', '--log_max', dest='log_max', type='int',
default=_DEFAULT_LOG_MAX_BYTES,
help='Log maximum bytes')
- parser.add_option('--log_count', dest='log_count', type='int',
- default=_DEFAULT_LOG_BACKUP_COUNT,
+ parser.add_option('--log-count', '--log_count', dest='log_count',
+ type='int', default=_DEFAULT_LOG_BACKUP_COUNT,
help='Log backup count')
parser.add_option('--strict', dest='strict', action='store_true',
default=False, help='Strictly check handshake request')
@@ -381,6 +400,18 @@ def _main():
if options.cgi_paths:
CGIHTTPServer.CGIHTTPRequestHandler.cgi_directories = \
options.cgi_paths.split(',')
+ if sys.platform in ('cygwin', 'win32'):
+ cygwin_path = None
+ # For Win32 Python, it is expected that CYGWIN_PATH
+ # is set to a directory of cygwin binaries.
+ # For example, websocket_server.py in Chromium sets CYGWIN_PATH to
+ # full path of third_party/cygwin/bin.
+ if 'CYGWIN_PATH' in os.environ:
+ cygwin_path = os.environ['CYGWIN_PATH']
+ util.wrap_popen3_for_win(cygwin_path)
+ def __check_script(scriptpath):
+ return util.get_script_interp(scriptpath, cygwin_path)
+ CGIHTTPServer.executable = __check_script
if options.use_tls:
if not _HAS_OPEN_SSL:
@@ -407,7 +438,8 @@ def _main():
WebSocketRequestHandler.options = options
WebSocketServer.options = options
- server = WebSocketServer(('', options.port), WebSocketRequestHandler)
+ server = WebSocketServer((options.server_host, options.port),
+ WebSocketRequestHandler)
server.serve_forever()
except Exception, e:
logging.critical(str(e))
diff --git a/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/util.py b/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/util.py
index 0ea8053..8ec9dca 100644
--- a/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/util.py
+++ b/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/util.py
@@ -33,6 +33,8 @@
import StringIO
+import os
+import re
import traceback
@@ -56,4 +58,64 @@ def prepend_message_to_exception(message, exc):
return
+def __translate_interp(interp, cygwin_path):
+ """Translate interp program path for Win32 python to run cygwin program
+ (e.g. perl). Note that it doesn't support path that contains space,
+ which is typically true for Unix, where #!-script is written.
+ For Win32 python, cygwin_path is a directory of cygwin binaries.
+
+ Args:
+ interp: interp command line
+ cygwin_path: directory name of cygwin binary, or None
+ Returns:
+ translated interp command line.
+ """
+ if not cygwin_path:
+ return interp
+ m = re.match("^[^ ]*/([^ ]+)( .*)?", interp)
+ if m:
+ cmd = os.path.join(cygwin_path, m.group(1))
+ return cmd + m.group(2)
+ return interp
+
+
+def get_script_interp(script_path, cygwin_path=None):
+ """Gets #!-interpreter command line from the script.
+
+ It also fixes command path. When Cygwin Python is used, e.g. in WebKit,
+ it could run "/usr/bin/perl -wT hello.pl".
+ When Win32 Python is used, e.g. in Chromium, it couldn't. So, fix
+ "/usr/bin/perl" to "<cygwin_path>\perl.exe".
+
+ Args:
+ script_path: pathname of the script
+ cygwin_path: directory name of cygwin binary, or None
+ Returns:
+ #!-interpreter command line, or None if it is not #!-script.
+ """
+ fp = open(script_path)
+ line = fp.readline()
+ fp.close()
+ m = re.match("^#!(.*)", line)
+ if m:
+ return __translate_interp(m.group(1), cygwin_path)
+ return None
+
+def wrap_popen3_for_win(cygwin_path):
+ """Wrap popen3 to support #!-script on Windows.
+
+ Args:
+ cygwin_path: path for cygwin binary if command path is needed to be
+ translated. None if no translation required.
+ """
+ __orig_popen3 = os.popen3
+ def __wrap_popen3(cmd, mode='t', bufsize=-1):
+ cmdline = cmd.split(' ')
+ interp = get_script_interp(cmdline[0], cygwin_path)
+ if interp:
+ cmd = interp + " " + cmd
+ return __orig_popen3(cmd, mode, bufsize)
+ os.popen3 = __wrap_popen3
+
+
# vi:sts=4 sw=4 et
diff --git a/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/setup.py b/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/setup.py
index 9729322..a34a83b 100644
--- a/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/setup.py
+++ b/WebKitTools/Scripts/webkitpy/thirdparty/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.8',
+ version='0.4.9.2',
)
diff --git a/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/test/test_util.py b/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/test/test_util.py
index 83e2635..61f0db5 100644
--- a/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/test/test_util.py
+++ b/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/test/test_util.py
@@ -33,11 +33,14 @@
"""Tests for util module."""
+import os
+import sys
import unittest
import config # This must be imported before mod_pywebsocket.
from mod_pywebsocket import util
+_TEST_DATA_DIR = os.path.join(os.path.split(__file__)[0], 'testdata')
class UtilTest(unittest.TestCase):
def test_get_stack_trace(self):
@@ -55,6 +58,18 @@ class UtilTest(unittest.TestCase):
util.prepend_message_to_exception('Hello ', exc)
self.assertEqual('Hello World', str(exc))
+ def test_get_script_interp(self):
+ cygwin_path = 'c:\\cygwin\\bin'
+ cygwin_perl = os.path.join(cygwin_path, 'perl')
+ self.assertEqual(None, util.get_script_interp(
+ os.path.join(_TEST_DATA_DIR, 'README')))
+ self.assertEqual(None, util.get_script_interp(
+ os.path.join(_TEST_DATA_DIR, 'README'), cygwin_path))
+ self.assertEqual('/usr/bin/perl -wT', util.get_script_interp(
+ os.path.join(_TEST_DATA_DIR, 'hello.pl')))
+ self.assertEqual(cygwin_perl + ' -wT', util.get_script_interp(
+ os.path.join(_TEST_DATA_DIR, 'hello.pl'), cygwin_path))
+
if __name__ == '__main__':
unittest.main()
diff --git a/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/test/testdata/README b/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/test/testdata/README
new file mode 100644
index 0000000..c001aa5
--- /dev/null
+++ b/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/test/testdata/README
@@ -0,0 +1 @@
+Test data directory
diff --git a/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/test/testdata/hello.pl b/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/test/testdata/hello.pl
new file mode 100644
index 0000000..9dd01b4
--- /dev/null
+++ b/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/test/testdata/hello.pl
@@ -0,0 +1,2 @@
+#!/usr/bin/perl -wT
+print "Hello\n";
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list