Update web-platform-tests and CSS tests.

- Update CSS tests to revision e05bfd5e30ed662c2f8a353577003f8eed230180.
- Update web-platform-tests to revision a052787dd5c069a340031011196b73affbd68cd9.
This commit is contained in:
Ms2ger 2017-02-06 11:06:12 +01:00
parent fb4f421c8b
commit 296fa2512b
21852 changed files with 2080936 additions and 892894 deletions

View file

@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
import argparse
import json
import os
import signal
import re
import socket
import sys
import threading
@ -13,34 +16,134 @@ import uuid
from collections import defaultdict, OrderedDict
from multiprocessing import Process, Event
from .. import localpaths
from ..localpaths import repo_root
import sslutils
from manifest.sourcefile import read_script_metadata
from wptserve import server as wptserve, handlers
from wptserve import stash
from wptserve.logger import set_logger
from wptserve.handlers import filesystem_path
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):
def __init__(self, base_path=None, url_base="/"):
self.base_path = base_path
self.url_base = url_base
self.handler = handlers.handler(self.handle_request)
def __call__(self, request, response):
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.html", ".worker.js")
meta = "\n".join(self._get_meta(request))
return """<!doctype html>
<meta charset=utf-8>
%(meta)s
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
fetch_tests_from_worker(new Worker("%s"));
fetch_tests_from_worker(new Worker("%(worker_path)s"));
</script>
""" % (worker_path,)
""" % {"meta": meta, "worker_path": worker_path}
def _get_meta(self, request):
path = filesystem_path(self.base_path, request, self.url_base)
path = path.replace(".any.worker.html", ".any.js")
path = path.replace(".worker.html", ".worker.js")
with open(path, "rb") as f:
for key, value in read_script_metadata(f):
if key == b"timeout":
if value == b"long":
yield '<meta name="timeout" content="long">'
class AnyHtmlHandler(object):
def __init__(self, base_path=None, url_base="/"):
self.base_path = base_path
self.url_base = url_base
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")
meta = "\n".join(self._get_meta(request))
return """\
<!doctype html>
<meta charset=utf-8>
%(meta)s
<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="%(test_path)s"></script>
""" % {"meta": meta, "test_path": test_path}
def _get_meta(self, request):
path = filesystem_path(self.base_path, request, self.url_base)
path = path.replace(".any.html", ".any.js")
with open(path, "rb") as f:
for key, value in read_script_metadata(f):
if key == b"timeout":
if value == b"long":
yield '<meta name="timeout" content="long">'
elif key == b"script":
attribute = value.decode('utf-8').replace('"', "&quot;").replace(">", "&gt;")
yield '<script src="%s"></script>' % attribute
class AnyWorkerHandler(object):
def __init__(self, base_path=None, url_base="/"):
self.base_path = base_path
self.url_base = url_base
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")
meta = "\n".join(self._get_meta(request))
return """\
%(meta)s
self.GLOBAL = {
isWindow: function() { return false; },
isWorker: function() { return true; },
};
importScripts("/resources/testharness.js");
importScripts("%(test_path)s");
done();
""" % {"meta": meta, "test_path": test_path}
def _get_meta(self, request):
path = filesystem_path(self.base_path, request, self.url_base)
path = path.replace(".any.worker.js", ".any.js")
with open(path, "rb") as f:
for key, value in read_script_metadata(f):
if key == b"timeout":
pass
elif key == b"script":
attribute = value.decode('utf-8').replace("\\", "\\\\").replace('"', '\\"')
yield 'importScripts("%s")' % attribute
rewrites = [("GET", "/resources/WebIDLParser.js", "/resources/webidl2/lib/webidl2.js")]
@ -61,7 +164,7 @@ class RoutesBuilder(object):
("*", "{spec}/tools/*", handlers.ErrorHandler(404)),
("*", "/serve.py", handlers.ErrorHandler(404))]
self.static = [("GET", "*.worker", WorkersHandler())]
self.static = []
self.mountpoint_routes = OrderedDict()
@ -85,9 +188,14 @@ class RoutesBuilder(object):
self.mountpoint_routes[url_base] = []
routes = [("GET", "*.asis", handlers.AsIsHandler),
("*", "*.py", handlers.PythonScriptHandler),
("GET", "*", handlers.FileHandler)]
routes = [
("GET", "*.worker.html", WorkersHandler),
("GET", "*.any.html", AnyHtmlHandler),
("GET", "*.any.worker.js", AnyWorkerHandler),
("GET", "*.asis", handlers.AsIsHandler),
("*", "*.py", handlers.PythonScriptHandler),
("GET", "*", handlers.FileHandler)
]
for (method, suffix, handler_cls) in routes:
self.mountpoint_routes[url_base].append(
@ -95,9 +203,25 @@ class RoutesBuilder(object):
b"%s%s" % (str(url_base) if url_base != "/" else "", str(suffix)),
handler_cls(base_path=path, url_base=url_base)))
def add_file_mount_point(self, file_url, base_path):
assert file_url.startswith("/")
url_base = file_url[0:file_url.rfind("/") + 1]
self.mountpoint_routes[file_url] = [("GET", file_url, handlers.FileHandler(base_path=base_path, url_base=url_base))]
def default_routes():
return RoutesBuilder().get_routes()
def build_routes(aliases):
builder = RoutesBuilder()
for alias in aliases:
url = alias["url-path"]
directory = alias["local-dir"]
if not url.startswith("/") or len(directory) == 0:
logger.error("\"url-path\" value must start with '/'.")
continue
if url.endswith("/"):
builder.add_mount_point(url, directory)
else:
builder.add_file_mount_point(url, directory)
return builder.get_routes()
def setup_logger(level):
@ -145,10 +269,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 +283,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):
@ -175,12 +299,12 @@ class ServerProc(object):
return self.proc.is_alive()
def check_subdomains(host, paths, bind_hostname, ssl_config):
def check_subdomains(host, paths, bind_hostname, ssl_config, aliases):
port = get_port()
subdomains = get_subdomains(host)
wrapper = ServerProc()
wrapper.start(start_http_server, host, port, paths, default_routes(), bind_hostname,
wrapper.start(start_http_server, host, port, paths, build_routes(aliases), bind_hostname,
None, ssl_config)
connected = False
@ -284,7 +408,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",
@ -409,7 +533,7 @@ def start(config, ssl_environment, routes, **kwargs):
ssl_config = get_ssl_config(config, external_config["domains"].values(), ssl_environment)
if config["check_subdomains"]:
check_subdomains(host, paths, bind_hostname, ssl_config)
check_subdomains(host, paths, bind_hostname, ssl_config, config["aliases"])
servers = start_servers(host, ports, paths, routes, bind_hostname, external_config,
ssl_config, **kwargs)
@ -439,6 +563,9 @@ def set_computed_defaults(config):
root = get_value_or_default(config, "doc_root", default=repo_root)
config["ws_doc_root"] = os.path.join(root, "websockets", "handlers")
if not value_set(config, "aliases"):
config["aliases"] = []
def merge_json(base_obj, override_obj):
rv = {}
@ -523,9 +650,13 @@ def main():
setup_logger(config["log_level"])
with stash.StashServer((config["host"], get_port()), authkey=str(uuid.uuid4())):
stash_address = None
if config["bind_hostname"]:
stash_address = (config["host"], get_port())
with stash.StashServer(stash_address, authkey=str(uuid.uuid4())):
with get_ssl_environment(config) as ssl_env:
config_, servers = start(config, ssl_env, default_routes(), **kwargs)
config_, servers = start(config, ssl_env, build_routes(config["aliases"]), **kwargs)
try:
while any(item.is_alive() for item in iter_procs(servers)):