mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Update web-platform-tests to revision dc5cbf088edcdb266541d4e5a76149a2c6e716a0
This commit is contained in:
parent
1d40075f03
commit
079092dfea
2381 changed files with 90360 additions and 17722 deletions
|
@ -1,4 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
|
@ -23,6 +26,15 @@ from mod_pywebsocket import standalone as pywebsocket
|
|||
|
||||
repo_root = localpaths.repo_root
|
||||
|
||||
def replace_end(s, old, new):
|
||||
"""
|
||||
Given a string `s` that ends with `old`, replace that occurrence of `old`
|
||||
with `new`.
|
||||
"""
|
||||
assert s.endswith(old)
|
||||
return s[:-len(old)] + new
|
||||
|
||||
|
||||
class WorkersHandler(object):
|
||||
def __init__(self):
|
||||
self.handler = handlers.handler(self.handle_request)
|
||||
|
@ -31,7 +43,7 @@ class WorkersHandler(object):
|
|||
return self.handler(request, response)
|
||||
|
||||
def handle_request(self, request, response):
|
||||
worker_path = request.url_parts.path.replace(".worker", ".worker.js")
|
||||
worker_path = replace_end(request.url_parts.path, ".worker", ".worker.js")
|
||||
return """<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
|
@ -42,6 +54,52 @@ fetch_tests_from_worker(new Worker("%s"));
|
|||
</script>
|
||||
""" % (worker_path,)
|
||||
|
||||
|
||||
class AnyHtmlHandler(object):
|
||||
def __init__(self):
|
||||
self.handler = handlers.handler(self.handle_request)
|
||||
|
||||
def __call__(self, request, response):
|
||||
return self.handler(request, response)
|
||||
|
||||
def handle_request(self, request, response):
|
||||
test_path = replace_end(request.url_parts.path, ".any.html", ".any.js")
|
||||
return """\
|
||||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<script>
|
||||
self.GLOBAL = {
|
||||
isWindow: function() { return true; },
|
||||
isWorker: function() { return false; },
|
||||
};
|
||||
</script>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script src="%s"></script>
|
||||
""" % (test_path,)
|
||||
|
||||
|
||||
class AnyWorkerHandler(object):
|
||||
def __init__(self):
|
||||
self.handler = handlers.handler(self.handle_request)
|
||||
|
||||
def __call__(self, request, response):
|
||||
return self.handler(request, response)
|
||||
|
||||
def handle_request(self, request, response):
|
||||
test_path = replace_end(request.url_parts.path, ".any.worker.js", ".any.js")
|
||||
return """\
|
||||
self.GLOBAL = {
|
||||
isWindow: function() { return false; },
|
||||
isWorker: function() { return true; },
|
||||
};
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("%s");
|
||||
done();
|
||||
""" % (test_path,)
|
||||
|
||||
|
||||
rewrites = [("GET", "/resources/WebIDLParser.js", "/resources/webidl2/lib/webidl2.js")]
|
||||
|
||||
subdomains = [u"www",
|
||||
|
@ -61,7 +119,11 @@ class RoutesBuilder(object):
|
|||
("*", "{spec}/tools/*", handlers.ErrorHandler(404)),
|
||||
("*", "/serve.py", handlers.ErrorHandler(404))]
|
||||
|
||||
self.static = [("GET", "*.worker", WorkersHandler())]
|
||||
self.static = [
|
||||
("GET", "*.worker", WorkersHandler()),
|
||||
("GET", "*.any.html", AnyHtmlHandler()),
|
||||
("GET", "*.any.worker.js", AnyWorkerHandler()),
|
||||
]
|
||||
|
||||
self.mountpoint_routes = OrderedDict()
|
||||
|
||||
|
@ -145,10 +207,10 @@ class ServerProc(object):
|
|||
self.daemon = init_func(host, port, paths, routes, bind_hostname, external_config,
|
||||
ssl_config, **kwargs)
|
||||
except socket.error:
|
||||
print >> sys.stderr, "Socket error on port %s" % port
|
||||
print("Socket error on port %s" % port, file=sys.stderr)
|
||||
raise
|
||||
except:
|
||||
print >> sys.stderr, traceback.format_exc()
|
||||
print(traceback.format_exc(), file=sys.stderr)
|
||||
raise
|
||||
|
||||
if self.daemon:
|
||||
|
@ -159,7 +221,7 @@ class ServerProc(object):
|
|||
except KeyboardInterrupt:
|
||||
pass
|
||||
except:
|
||||
print >> sys.stderr, traceback.format_exc()
|
||||
print(traceback.format_exc(), file=sys.stderr)
|
||||
raise
|
||||
|
||||
def wait(self):
|
||||
|
@ -284,7 +346,7 @@ class WebSocketDaemon(object):
|
|||
elif pywebsocket._import_pyopenssl():
|
||||
tls_module = pywebsocket._TLS_BY_PYOPENSSL
|
||||
else:
|
||||
print "No SSL module available"
|
||||
print("No SSL module available")
|
||||
sys.exit(1)
|
||||
|
||||
cmd_args += ["--tls",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue