Update web-platform-tests to revision 5084587f6b05bf99ad09e7844be66dcc61070cdf

This commit is contained in:
WPT Sync Bot 2018-04-25 21:10:30 -04:00 committed by Anthony Ramine
parent 6d42d2f1e8
commit 7d1071a6a4
408 changed files with 8968 additions and 2608 deletions

View file

@ -18,7 +18,7 @@ from .. import localpaths
from ..gitignore.gitignore import PathFilter
from ..wpt import testfiles
from manifest.sourcefile import SourceFile, js_meta_re, python_meta_re, space_chars
from manifest.sourcefile import SourceFile, js_meta_re, python_meta_re, space_chars, get_any_variants, get_default_any_variants
from six import binary_type, iteritems, itervalues
from six.moves import range
from six.moves.urllib.parse import urlsplit, urljoin
@ -616,6 +616,31 @@ broken_js_metadata = re.compile(b"//\s*META:")
broken_python_metadata = re.compile(b"#\s*META:")
def check_global_metadata(value):
global_values = {item.strip() for item in value.split(b",") if item.strip()}
included_variants = set.union(get_default_any_variants(),
*(get_any_variants(v) for v in global_values if not v.startswith(b"!")))
for global_value in global_values:
if global_value.startswith(b"!"):
excluded_value = global_value[1:]
if not get_any_variants(excluded_value):
yield ("UNKNOWN-GLOBAL-METADATA", "Unexpected value for global metadata")
elif excluded_value in global_values:
yield ("BROKEN-GLOBAL-METADATA", "Cannot specify both %s and %s" % (global_value, excluded_value))
else:
excluded_variants = get_any_variants(excluded_value)
if not (excluded_variants & included_variants):
yield ("BROKEN-GLOBAL-METADATA", "Cannot exclude %s if it is not included" % (excluded_value,))
else:
if not get_any_variants(global_value):
yield ("UNKNOWN-GLOBAL-METADATA", "Unexpected value for global metadata")
def check_script_metadata(repo_root, path, f):
if path.endswith((".worker.js", ".any.js")):
meta_re = js_meta_re
@ -634,7 +659,9 @@ def check_script_metadata(repo_root, path, f):
m = meta_re.match(line)
if m:
key, value = m.groups()
if key == b"timeout":
if key == b"global":
errors.extend((kind, message, path, idx + 1) for (kind, message) in check_global_metadata(value))
elif key == b"timeout":
if value != b"long":
errors.append(("UNKNOWN-TIMEOUT-METADATA", "Unexpected value for timeout metadata", path, idx + 1))
elif key == b"script":

View file

@ -559,6 +559,39 @@ def test_script_metadata(filename, input, error):
assert errors == []
@pytest.mark.parametrize("globals,error", [
(b"", None),
(b"default", None),
(b"!default", None),
(b"window", None),
(b"!window", None),
(b"!dedicatedworker", None),
(b"window, !window", "BROKEN-GLOBAL-METADATA"),
(b"!serviceworker", "BROKEN-GLOBAL-METADATA"),
(b"serviceworker, !serviceworker", "BROKEN-GLOBAL-METADATA"),
(b"worker, !dedicatedworker", None),
(b"worker, !serviceworker", None),
(b"!worker", None),
(b"foo", "UNKNOWN-GLOBAL-METADATA"),
(b"!foo", "UNKNOWN-GLOBAL-METADATA"),
])
def test_script_globals_metadata(globals, error):
filename = "foo.any.js"
input = b"""// META: global=%s\n""" % globals
errors = check_file_contents("", filename, six.BytesIO(input))
check_errors(errors)
if error is not None:
errors = [(k, f, l) for (k, _, f, l) in errors]
assert errors == [
(error,
filename,
1),
]
else:
assert errors == []
@pytest.mark.parametrize("input,error", [
(b"""#META: timeout=long\n""", None),
(b"""# META: timeout=long\n""", None),