Update web-platform-tests to revision 1e4fe87a7f01c0b5c614c8f601ffa68b4a00662a

This commit is contained in:
WPT Sync Bot 2018-02-13 20:15:58 -05:00
parent 4c3f1756da
commit 432648745e
164 changed files with 8354 additions and 595 deletions

View file

@ -2,5 +2,6 @@
"test-jobs": {"path": "jobs.py", "script": "run", "parser": "create_parser", "help": "List test jobs that should run for a set of commits",
"virtualenv": false},
"check-stability": {"path": "check_stability.py", "script": "run", "parser": "get_parser", "parse_known": true, "help": "Check test stability",
"virtualenv": true, "install": ["requests"], "requirements": ["../wptrunner/requirements.txt"]}
"virtualenv": true, "install": ["requests"], "requirements": ["../wptrunner/requirements.txt"]},
"make-hosts-file": {"path": "make_hosts_file.py", "script": "run", "parser": "create_parser", "help": "Output a hosts file to stdout", "virtualenv": false}
}

View file

@ -6,15 +6,7 @@ hosts_fixup() {
echo "## /etc/hosts ##"
cat /etc/hosts
sudo sed -i 's/^::1\s*localhost/::1/' /etc/hosts
sudo sh -c 'echo "
127.0.0.1 web-platform.test
127.0.0.1 www.web-platform.test
127.0.0.1 www1.web-platform.test
127.0.0.1 www2.web-platform.test
127.0.0.1 xn--n8j6ds53lwwkrqhv28a.web-platform.test
127.0.0.1 xn--lve-6lad.web-platform.test
0.0.0.0 nonexistent-origin.web-platform.test
" >> /etc/hosts'
./wpt make-hosts-file | sudo tee -a /etc/hosts
echo "== /etc/hosts =="
cat /etc/hosts
echo "----------------"

View file

@ -0,0 +1,19 @@
import argparse
import os
from ..localpaths import repo_root
from ..serve.serve import load_config, normalise_config, make_hosts_file
def create_parser():
parser = argparse.ArgumentParser()
parser.add_argument("address", default="127.0.0.1", nargs="?", help="Address that hosts should point at")
return parser
def run(**kwargs):
config = load_config(os.path.join(repo_root, "config.default.json"),
os.path.join(repo_root, "config.json"))
config = normalise_config(config, {})
print(make_hosts_file(config, kwargs["address"]))

View file

@ -1,5 +1,6 @@
import platform
import os
import sys
from hypothesis import settings, HealthCheck
@ -11,3 +12,11 @@ settings.register_profile("pypy", settings(suppress_health_check=[HealthCheck.to
settings.load_profile(os.getenv("HYPOTHESIS_PROFILE",
"default" if impl != "PyPy" else "pypy"))
# serve can't even be imported on Py3, so totally ignore it even from collection
collect_ignore = []
if sys.version_info[0] >= 3:
serve = os.path.join(os.path.dirname(__file__), "serve")
collect_ignore.extend([os.path.join(root, f)
for root, _, files in os.walk(serve)
for f in files])

View file

@ -203,6 +203,8 @@ subdomains = [u"www",
u"天気の良い日",
u"élève"]
not_subdomains = [u"nonexistent-origin"]
class RoutesBuilder(object):
def __init__(self):
self.forbidden_override = [("GET", "/tools/runner/*", handlers.file_handler),
@ -468,6 +470,24 @@ def get_subdomains(host):
for subdomain in subdomains}
def get_not_subdomains(host):
#This assumes that the tld is ascii-only or already in punycode
return {subdomain: (subdomain.encode("idna"), host)
for subdomain in not_subdomains}
def make_hosts_file(config, host):
rv = []
for domain in config["domains"].values():
rv.append("%s\t%s\n" % (host, domain))
for not_domain in config.get("not_domains", {}).values():
rv.append("0.0.0.0\t%s\n" % not_domain)
return "".join(rv)
def start_servers(host, ports, paths, routes, bind_hostname, config, ssl_config,
**kwargs):
servers = defaultdict(list)
@ -626,6 +646,7 @@ def get_ports(config, ssl_environment):
def normalise_config(config, ports):
host = config["external_host"] if config["external_host"] else config["host"]
domains = get_subdomains(host)
not_domains = get_not_subdomains(host)
ports_ = {}
for scheme, ports_used in ports.iteritems():
ports_[scheme] = ports_used
@ -633,6 +654,9 @@ def normalise_config(config, ports):
for key, value in domains.iteritems():
domains[key] = ".".join(value)
for key, value in not_domains.iteritems():
not_domains[key] = ".".join(value)
domains[""] = host
ports_ = {}
@ -644,6 +668,7 @@ def normalise_config(config, ports):
config_ = config.copy()
config_["host"] = host
config_["domains"] = domains
config_["not_domains"] = not_domains
config_["ports"] = ports_
return config_

View file

@ -0,0 +1,12 @@
from . import serve
def test_make_hosts_file():
hosts = serve.make_hosts_file({
"domains": {"www": "www.foo.bar.test", "www1": "www1.foo.bar.test"},
"not_domains": {"aaa": "aaa.foo.bar.test", "bbb": "bbb.foo.bar.test"}
}, "127.1.1.1")
lines = hosts.split("\n")
assert "127.1.1.1\twww.foo.bar.test" in lines
assert "127.1.1.1\twww1.foo.bar.test" in lines
assert "0.0.0.0\taaa.foo.bar.test" in lines
assert "0.0.0.0\tbbb.foo.bar.test" in lines

View file

@ -11,6 +11,8 @@ wpt_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os
sys.path.insert(0, os.path.abspath(os.path.join(wpt_root, "tools")))
from . import browser, utils, virtualenv
from ..serve import serve
logger = None
@ -94,13 +96,10 @@ otherwise install OpenSSL and ensure that it's on your $PATH.""")
def check_environ(product):
if product not in ("firefox", "servo"):
expected_hosts = ["web-platform.test",
"www.web-platform.test",
"www1.web-platform.test",
"www2.web-platform.test",
"xn--n8j6ds53lwwkrqhv28a.web-platform.test",
"xn--lve-6lad.web-platform.test",
"nonexistent-origin.web-platform.test"]
expected_hosts = {".".join(x)
for x in serve.get_subdomains("web-platform.test").values()}
expected_hosts |= {".".join(x)
for x in serve.get_not_subdomains("web-platform.test").values()}
missing_hosts = set(expected_hosts)
if platform.uname()[0] != "Windows":
hosts_path = "/etc/hosts"
@ -114,13 +113,17 @@ def check_environ(product):
for host in hosts:
missing_hosts.discard(host)
if missing_hosts:
raise WptrunError("""Missing hosts file configuration. Expected entries like:
if platform.uname()[0] != "Windows":
message = """Missing hosts file configuration. Run
%s
python wpt make-hosts-file >> %s
See README.md for more details.""" % "\n".join("%s\t%s" %
("127.0.0.1" if "nonexistent" not in host else "0.0.0.0", host)
for host in expected_hosts))
from a shell with Administrator privileges.""" % hosts_path
else:
message = """Missing hosts file configuration. Run
./wpt make-hosts-file | sudo tee -a %s""" % hosts_path
raise WptrunError(message)
class BrowserSetup(object):

View file

@ -5,4 +5,3 @@ include wptrunner/testharness_runner.html
include wptrunner/*.js
include wptrunner/executors/*.js
include wptrunner/config.json
include wptrunner/browsers/server-locations.txt

View file

@ -52,7 +52,6 @@ setup(name=PACKAGE_NAME,
"testharness_runner.html",
"config.json",
"wptrunner.default.ini",
"browsers/server-locations.txt",
"browsers/sauce_setup/*",
"prefs/*"]},
include_package_data=True,

View file

@ -60,8 +60,7 @@ def env_extras(**kwargs):
def env_options():
return {"host": "web-platform.test",
"bind_hostname": "true"}
return {"bind_hostname": "true"}
class ChromeBrowser(Browser):

View file

@ -68,8 +68,7 @@ def env_extras(**kwargs):
def env_options():
return {"host": "web-platform.test",
"bind_hostname": "true"}
return {"bind_hostname": "true"}
class ChromeAndroidBrowser(Browser):

View file

@ -38,8 +38,7 @@ def env_extras(**kwargs):
return []
def env_options():
return {"host": "web-platform.test",
"bind_hostname": "true",
return {"bind_hostname": "true",
"supports_debugger": False}
class EdgeBrowser(Browser):

View file

@ -3,12 +3,12 @@ import platform
import signal
import subprocess
import sys
import tempfile
import mozinfo
import mozleak
from mozprocess import ProcessHandler
from mozprofile import FirefoxProfile, Preferences
from mozprofile.permissions import ServerLocations
from mozrunner import FirefoxRunner
from mozrunner.utils import get_stack_fixer_function
from mozcrash import mozcrash
@ -23,7 +23,6 @@ from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executormarionette import (MarionetteTestharnessExecutor,
MarionetteRefTestExecutor,
MarionetteWdspecExecutor)
from ..environment import hostnames
here = os.path.join(os.path.split(__file__)[0])
@ -80,7 +79,8 @@ def browser_kwargs(test_type, run_info_data, **kwargs):
**kwargs),
"leak_check": kwargs["leak_check"],
"stylo_threads": kwargs["stylo_threads"],
"chaos_mode_flags": kwargs["chaos_mode_flags"]}
"chaos_mode_flags": kwargs["chaos_mode_flags"],
"config": kwargs["config"]}
def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
@ -102,7 +102,7 @@ def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
if kwargs["binary_args"]:
options["args"] = kwargs["binary_args"]
options["prefs"] = {
"network.dns.localDomains": ",".join(hostnames)
"network.dns.localDomains": ",".join(server_config['domains'].values())
}
capabilities["moz:firefoxOptions"] = options
if kwargs["certutil_binary"] is None:
@ -143,7 +143,7 @@ class FirefoxBrowser(Browser):
symbols_path=None, stackwalk_binary=None, certutil_binary=None,
ca_certificate_path=None, e10s=False, stackfix_dir=None,
binary_args=None, timeout_multiplier=None, leak_check=False, stylo_threads=1,
chaos_mode_flags=None):
chaos_mode_flags=None, config=None):
Browser.__init__(self, logger)
self.binary = binary
self.prefs_root = prefs_root
@ -159,6 +159,7 @@ class FirefoxBrowser(Browser):
self.certutil_binary = certutil_binary
self.e10s = e10s
self.binary_args = binary_args
self.config = config
if stackfix_dir:
self.stack_fixer = get_stack_fixer_function(stackfix_dir,
self.symbols_path)
@ -189,15 +190,12 @@ class FirefoxBrowser(Browser):
if self.chaos_mode_flags is not None:
env["MOZ_CHAOSMODE"] = str(self.chaos_mode_flags)
locations = ServerLocations(filename=os.path.join(here, "server-locations.txt"))
preferences = self.load_prefs()
self.profile = FirefoxProfile(locations=locations,
preferences=preferences)
self.profile = FirefoxProfile(preferences=preferences)
self.profile.set_preferences({"marionette.port": self.marionette_port,
"dom.disable_open_during_load": False,
"network.dns.localDomains": ",".join(hostnames),
"network.dns.localDomains": ",".join(self.config['domains'].values()),
"network.proxy.type": 0,
"places.history.enabled": False,
"dom.send_after_paint_to_content": True,

View file

@ -42,8 +42,7 @@ def env_extras(**kwargs):
return []
def env_options():
return {"host": "web-platform.test",
"bind_hostname": "true",
return {"bind_hostname": "true",
"supports_debugger": False}
class InternetExplorerBrowser(Browser):

View file

@ -60,8 +60,7 @@ def env_extras(**kwargs):
def env_options():
return {"host": "web-platform.test",
"bind_hostname": "true"}
return {"bind_hostname": "true"}
class OperaBrowser(Browser):

View file

@ -113,8 +113,7 @@ def env_extras(**kwargs):
def env_options():
return {"host": "web-platform.test",
"bind_hostname": "true",
return {"bind_hostname": "true",
"supports_debugger": False}
@ -128,6 +127,7 @@ def get_tar(url, dest):
class SauceConnect():
def __init__(self, **kwargs):
self.config = kwargs["config"]
self.sauce_user = kwargs["sauce_user"]
self.sauce_key = kwargs["sauce_key"]
self.sauce_tunnel_id = kwargs["sauce_tunnel_id"]
@ -153,8 +153,7 @@ class SauceConnect():
"--metrics-address=0.0.0.0:9876",
"--readyfile=./sauce_is_ready",
"--tunnel-domains",
"web-platform.test",
"*.web-platform.test"
",".join(self.config['domains'].values())
])
# Timeout config vars

View file

@ -1,31 +0,0 @@
http://localhost:8000 primary
http://web-platform.test:8000
http://www.web-platform.test:8000
http://www1.web-platform.test:8000
http://www2.web-platform.test:8000
http://xn--n8j6ds53lwwkrqhv28a.web-platform.test:8000
http://xn--lve-6lad.web-platform.test:8000
http://web-platform.test:8001
http://www.web-platform.test:8001
http://www1.web-platform.test:8001
http://www2.web-platform.test:8001
http://xn--n8j6ds53lwwkrqhv28a.web-platform.test:8001
http://xn--lve-6lad.web-platform.test:8001
https://web-platform.test:8443
https://www.web-platform.test:8443
https://www1.web-platform.test:8443
https://www2.web-platform.test:8443
https://xn--n8j6ds53lwwkrqhv28a.web-platform.test:8443
https://xn--lve-6lad.web-platform.test:8443
# These are actually ws servers, but until mozprofile is
# fixed we have to pretend that they are http servers
http://web-platform.test:8888
http://www.web-platform.test:8888
http://www1.web-platform.test:8888
http://www2.web-platform.test:8888
http://xn--n8j6ds53lwwkrqhv28a.web-platform.test:8888
http://xn--lve-6lad.web-platform.test:8888

View file

@ -1,9 +1,12 @@
import os
import shutil
import subprocess
import tempfile
from mozprocess import ProcessHandler
from tools.serve.serve import make_hosts_file
from .base import Browser, require_arg, get_free_port, browser_command, ExecutorBrowser
from ..executors import executor_kwargs as base_executor_kwargs
from ..executors.executorservodriver import (ServoWebDriverTestharnessExecutor,
@ -26,14 +29,6 @@ __wptrunner__ = {
"update_properties": "update_properties",
}
hosts_text = """127.0.0.1 web-platform.test
127.0.0.1 www.web-platform.test
127.0.0.1 www1.web-platform.test
127.0.0.1 www2.web-platform.test
127.0.0.1 xn--n8j6ds53lwwkrqhv28a.web-platform.test
127.0.0.1 xn--lve-6lad.web-platform.test
"""
def check_args(**kwargs):
require_arg(kwargs, "binary")
@ -69,10 +64,10 @@ def update_properties():
return ["debug", "os", "version", "processor", "bits"], None
def make_hosts_file():
def write_hosts_file(config):
hosts_fd, hosts_path = tempfile.mkstemp()
with os.fdopen(hosts_fd, "w") as f:
f.write(hosts_text)
f.write(make_hosts_file(config, "127.0.0.1"))
return hosts_path
@ -87,7 +82,7 @@ class ServoWebDriverBrowser(Browser):
self.webdriver_port = None
self.proc = None
self.debug_info = debug_info
self.hosts_path = make_hosts_file()
self.hosts_path = write_hosts_file()
self.command = None
self.user_stylesheets = user_stylesheets if user_stylesheets else []
@ -158,6 +153,7 @@ class ServoWebDriverBrowser(Browser):
def cleanup(self):
self.stop()
shutil.rmtree(os.path.dirname(self.hosts_file))
def executor_browser(self):
assert self.webdriver_port is not None

View file

@ -18,14 +18,6 @@ serve = None
sslutils = None
hostnames = ["web-platform.test",
"www.web-platform.test",
"www1.web-platform.test",
"www2.web-platform.test",
"xn--n8j6ds53lwwkrqhv28a.web-platform.test",
"xn--lve-6lad.web-platform.test"]
def do_delayed_imports(logger, test_paths):
global serve, sslutils

View file

@ -13,6 +13,8 @@ from collections import defaultdict
from mozprocess import ProcessHandler
from tools.serve.serve import make_hosts_file
from .base import (ExecutorException,
Protocol,
RefTestImplementation,
@ -30,18 +32,10 @@ webdriver = None
extra_timeout = 5 # seconds
hosts_text = """127.0.0.1 web-platform.test
127.0.0.1 www.web-platform.test
127.0.0.1 www1.web-platform.test
127.0.0.1 www2.web-platform.test
127.0.0.1 xn--n8j6ds53lwwkrqhv28a.web-platform.test
127.0.0.1 xn--lve-6lad.web-platform.test
"""
def make_hosts_file():
def write_hosts_file(config):
hosts_fd, hosts_path = tempfile.mkstemp()
with os.fdopen(hosts_fd, "w") as f:
f.write(hosts_text)
f.write(make_hosts_file(config, "127.0.0.1"))
return hosts_path
@ -57,7 +51,7 @@ class ServoTestharnessExecutor(ProcessTestExecutor):
self.result_data = None
self.result_flag = None
self.protocol = Protocol(self, browser)
self.hosts_path = make_hosts_file()
self.hosts_path = write_hosts_file(server_config)
def teardown(self):
try:

View file

@ -1,100 +0,0 @@
from __future__ import unicode_literals
class HostsLine(object):
def __init__(self, ip_address, canonical_hostname, aliases=None, comment=None):
self.ip_address = ip_address
self.canonical_hostname = canonical_hostname
self.aliases = aliases if aliases is not None else []
self.comment = comment
if self.ip_address is None:
assert self.canonical_hostname is None
assert not self.aliases
assert self.comment is not None
@classmethod
def from_string(cls, line):
if not line.strip():
return
line = line.strip()
ip_address = None
canonical_hostname = None
aliases = []
comment = None
comment_parts = line.split("#", 1)
if len(comment_parts) > 1:
comment = comment_parts[1]
data = comment_parts[0].strip()
if data:
fields = data.split()
if len(fields) < 2:
raise ValueError("Invalid hosts line")
ip_address = fields[0]
canonical_hostname = fields[1]
aliases = fields[2:]
return cls(ip_address, canonical_hostname, aliases, comment)
class HostsFile(object):
def __init__(self):
self.data = []
self.by_hostname = {}
def set_host(self, host):
if host.canonical_hostname is None:
self.data.append(host)
elif host.canonical_hostname in self.by_hostname:
old_host = self.by_hostname[host.canonical_hostname]
old_host.ip_address = host.ip_address
old_host.aliases = host.aliases
old_host.comment = host.comment
else:
self.data.append(host)
self.by_hostname[host.canonical_hostname] = host
@classmethod
def from_file(cls, f):
rv = cls()
for line in f:
host = HostsLine.from_string(line)
if host is not None:
rv.set_host(host)
return rv
def to_string(self):
field_widths = [0, 0]
for line in self.data:
if line.ip_address is not None:
field_widths[0] = max(field_widths[0], len(line.ip_address))
field_widths[1] = max(field_widths[1], len(line.canonical_hostname))
lines = []
for host in self.data:
line = ""
if host.ip_address is not None:
ip_string = host.ip_address.ljust(field_widths[0])
hostname_str = host.canonical_hostname
if host.aliases:
hostname_str = "%s %s" % (hostname_str.ljust(field_widths[1]),
" ".join(host.aliases))
line = "%s %s" % (ip_string, hostname_str)
if host.comment:
if line:
line += " "
line += "#%s" % host.comment
lines.append(line)
lines.append("")
return "\n".join(lines)
def to_file(self, f):
f.write(self.to_string().encode("utf8"))

View file

@ -20,6 +20,9 @@ def test_sauceconnect_success():
exists.return_value = True
sauce_connect = sauce.SauceConnect(
config={
"domains": {"": "example.net"}
},
sauce_user="aaa",
sauce_key="bbb",
sauce_tunnel_id="ccc",
@ -46,6 +49,9 @@ def test_sauceconnect_failure_exit(readyfile, returncode):
exists.return_value = readyfile
sauce_connect = sauce.SauceConnect(
config={
"domains": {"": "example.net"}
},
sauce_user="aaa",
sauce_key="bbb",
sauce_tunnel_id="ccc",
@ -68,6 +74,9 @@ def test_sauceconnect_failure_never_ready():
exists.return_value = False
sauce_connect = sauce.SauceConnect(
config={
"domains": {"": "example.net"}
},
sauce_user="aaa",
sauce_key="bbb",
sauce_tunnel_id="ccc",
@ -82,3 +91,34 @@ def test_sauceconnect_failure_never_ready():
# Check we actually kill it after termination fails
Popen.return_value.terminate.assert_called()
Popen.return_value.kill.assert_called()
def test_sauceconnect_tunnel_domains():
with mock.patch.object(sauce.SauceConnect, "upload_prerun_exec"),\
mock.patch.object(sauce.subprocess, "Popen") as Popen,\
mock.patch.object(sauce.os.path, "exists") as exists:
Popen.return_value.poll.return_value = None
Popen.return_value.returncode = None
exists.return_value = True
sauce_connect = sauce.SauceConnect(
config={
"domains": {"foo": "foo.bar.example.com", "": "example.net"}
},
sauce_user="aaa",
sauce_key="bbb",
sauce_tunnel_id="ccc",
sauce_connect_binary="ddd")
sauce_connect.__enter__(None)
Popen.assert_called_once()
args, kwargs = Popen.call_args
cmd = args[0]
assert "--tunnel-domains" in cmd
i = cmd.index("--tunnel-domains")
rest = cmd[i+1:]
assert len(rest) >= 1
if len(rest) > 1:
assert rest[1].startswith("-"), "--tunnel-domains takes a comma separated list (not a space separated list)"
assert set(rest[0].split(",")) == {"foo.bar.example.com", "example.net"}

View file

@ -1,54 +0,0 @@
import unittest
import sys
from os.path import join, dirname
from cStringIO import StringIO
sys.path.insert(0, join(dirname(__file__), "..", ".."))
from wptrunner import hosts
class HostsTest(unittest.TestCase):
def do_test(self, input, expected):
host_file = hosts.HostsFile.from_file(StringIO(input))
self.assertEquals(host_file.to_string(), expected)
def test_simple(self):
self.do_test("""127.0.0.1 \tlocalhost alias # comment
# Another comment""",
"""127.0.0.1 localhost alias # comment
# Another comment
""")
def test_blank_lines(self):
self.do_test("""127.0.0.1 \tlocalhost alias # comment
\r
\t
# Another comment""",
"""127.0.0.1 localhost alias # comment
# Another comment
""")
def test_whitespace(self):
self.do_test(""" \t127.0.0.1 \tlocalhost alias # comment \r
\t# Another comment""",
"""127.0.0.1 localhost alias # comment
# Another comment
""")
def test_alignment(self):
self.do_test("""127.0.0.1 \tlocalhost alias
192.168.1.1 another_host another_alias
""","""127.0.0.1 localhost alias
192.168.1.1 another_host another_alias
""")
def test_multiple_same_name(self):
# The semantics are that we overwrite earlier entries with the same name
self.do_test("""127.0.0.1 \tlocalhost alias
192.168.1.1 localhost another_alias""","""192.168.1.1 localhost another_alias
""")
if __name__ == "__main__":
unittest.main()

View file

@ -218,6 +218,7 @@ def run_tests(config, test_paths, product, **kwargs):
browser_kwargs = get_browser_kwargs(test_type,
run_info,
ssl_env=ssl_env,
config=test_environment.config,
**kwargs)
executor_cls = executor_classes.get(test_type)

View file

@ -392,6 +392,12 @@ def template(request, content, escape_type="html"):
value = request.headers
elif field == "GET":
value = FirstWrapper(request.GET)
elif field == "domains":
if ('not_domains' in request.server.config and
tokens[1][1] in request.server.config['not_domains']):
value = request.server.config['not_domains']
else:
value = request.server.config['domains']
elif field in request.server.config:
value = request.server.config[tokens[0][1]]
elif field == "location":