mirror of
https://github.com/servo/servo.git
synced 2025-08-26 23:58:20 +01:00
Update web-platform-tests to 887399d3d0a85d0e27a6688ae384459376adf7ca
This commit is contained in:
parent
a900196b3f
commit
8ea56eabaa
44 changed files with 178 additions and 77 deletions
|
@ -2,17 +2,11 @@ import os
|
|||
import urlparse
|
||||
from abc import ABCMeta, abstractmethod, abstractproperty
|
||||
|
||||
from utils import from_os_path, to_os_path
|
||||
|
||||
item_types = ["testharness", "reftest", "manual", "stub", "wdspec"]
|
||||
|
||||
|
||||
def from_os_path(path):
|
||||
return path.replace(os.path.sep, "/")
|
||||
|
||||
|
||||
def to_os_path(path):
|
||||
return path.replace("/", os.path.sep)
|
||||
|
||||
|
||||
def get_source_file(source_files, tests_root, manifest, path):
|
||||
def make_new():
|
||||
from sourcefile import SourceFile
|
||||
|
|
|
@ -5,6 +5,7 @@ from collections import defaultdict
|
|||
from item import item_types, ManualTest, WebdriverSpecTest, Stub, RefTest, TestharnessTest
|
||||
from log import get_logger
|
||||
from sourcefile import SourceFile
|
||||
from utils import from_os_path, to_os_path
|
||||
|
||||
|
||||
CURRENT_VERSION = 2
|
||||
|
@ -207,7 +208,7 @@ class Manifest(object):
|
|||
for item_type, items in self._data.iteritems()
|
||||
}
|
||||
|
||||
reftest_nodes = {key:[v.to_json() for v in value]
|
||||
reftest_nodes = {from_os_path(key): [v.to_json() for v in value]
|
||||
for key, value in self.reftest_nodes.iteritems()}
|
||||
|
||||
rv = {"url_base": self.url_base,
|
||||
|
@ -246,6 +247,7 @@ class Manifest(object):
|
|||
self._add(manifest_item)
|
||||
|
||||
for path, values in obj["reftest_nodes"].iteritems():
|
||||
path = to_os_path(path)
|
||||
for v in values:
|
||||
item = RefTest.from_json(self, tests_root, v,
|
||||
source_files=source_files)
|
||||
|
@ -306,17 +308,16 @@ class LocalChanges(object):
|
|||
return self._data[item_type]
|
||||
|
||||
def to_json(self):
|
||||
reftest_nodes = {key:[v.to_json() for v in value]
|
||||
reftest_nodes = {from_os_path(key): [v.to_json() for v in value]
|
||||
for key, value in self.reftest_nodes.iteritems()}
|
||||
|
||||
rv = {"items": defaultdict(dict),
|
||||
"reftest_nodes": reftest_nodes,
|
||||
"deleted": []}
|
||||
|
||||
rv["deleted"].extend(self._deleted)
|
||||
"deleted": [from_os_path(path) for path in self._deleted]}
|
||||
|
||||
for test_type, paths in self._data.iteritems():
|
||||
for path, tests in paths.iteritems():
|
||||
path = from_os_path(path)
|
||||
rv["items"][test_type][path] = [test.to_json() for test in tests]
|
||||
|
||||
return rv
|
||||
|
@ -343,6 +344,7 @@ class LocalChanges(object):
|
|||
self.add(manifest_item)
|
||||
|
||||
for path, values in obj["reftest_nodes"].iteritems():
|
||||
path = to_os_path(path)
|
||||
for v in values:
|
||||
item = RefTest.from_json(self.manifest, tests_root, v,
|
||||
source_files=source_files)
|
||||
|
@ -350,7 +352,7 @@ class LocalChanges(object):
|
|||
self.reftest_nodes_by_url[item.url] = item
|
||||
|
||||
for item in obj["deleted"]:
|
||||
self.add_deleted(item)
|
||||
self.add_deleted(to_os_path(item))
|
||||
|
||||
return self
|
||||
|
||||
|
|
|
@ -21,6 +21,12 @@ def is_blacklisted(url):
|
|||
return True
|
||||
return False
|
||||
|
||||
def from_os_path(path):
|
||||
return path.replace(os.path.sep, "/")
|
||||
|
||||
def to_os_path(path):
|
||||
return path.replace("/", os.path.sep)
|
||||
|
||||
class ContextManagerStringIO(StringIO):
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
|
|
@ -137,7 +137,9 @@ class FileHandler(object):
|
|||
if "pipe" in query:
|
||||
pipeline = Pipeline(query["pipe"][-1])
|
||||
elif os.path.splitext(path)[0].endswith(".sub"):
|
||||
pipeline = Pipeline("sub")
|
||||
ml_extensions = {".html", ".htm", ".xht", ".xhtml", ".xml", ".svg"}
|
||||
escape_type = "html" if os.path.splitext(path)[1] in ml_extensions else "none"
|
||||
pipeline = Pipeline("sub(%s)" % escape_type)
|
||||
if pipeline is not None:
|
||||
response = pipeline(request, response)
|
||||
|
||||
|
@ -167,7 +169,7 @@ class FileHandler(object):
|
|||
return []
|
||||
else:
|
||||
if use_sub:
|
||||
data = template(request, data)
|
||||
data = template(request, data, escape_type="none")
|
||||
return [tuple(item.strip() for item in line.split(":", 1))
|
||||
for line in data.splitlines() if line]
|
||||
|
||||
|
|
|
@ -313,10 +313,13 @@ class FirstWrapper(object):
|
|||
return ""
|
||||
|
||||
|
||||
@pipe()
|
||||
def sub(request, response):
|
||||
@pipe(opt(nullable(str)))
|
||||
def sub(request, response, escape_type="html"):
|
||||
"""Substitute environment information about the server and request into the script.
|
||||
|
||||
:param escape_type: String detailing the type of escaping to use. Known values are
|
||||
"html" and "none", with "html" the default for historic reasons.
|
||||
|
||||
The format is a very limited template language. Substitutions are
|
||||
enclosed by {{ and }}. There are several avaliable substitutions:
|
||||
|
||||
|
@ -359,12 +362,12 @@ def sub(request, response):
|
|||
"""
|
||||
content = resolve_content(response)
|
||||
|
||||
new_content = template(request, content)
|
||||
new_content = template(request, content, escape_type=escape_type)
|
||||
|
||||
response.content = new_content
|
||||
return response
|
||||
|
||||
def template(request, content):
|
||||
def template(request, content, escape_type="html"):
|
||||
#TODO: There basically isn't any error handling here
|
||||
tokenizer = ReplacementTokenizer()
|
||||
|
||||
|
@ -419,9 +422,12 @@ def template(request, content):
|
|||
if variable is not None:
|
||||
variables[variable] = value
|
||||
|
||||
escape_func = {"html": lambda x:escape(x, quote=True),
|
||||
"none": lambda x:x}[escape_type]
|
||||
|
||||
#Should possibly support escaping for other contexts e.g. script
|
||||
#TODO: read the encoding of the response
|
||||
return escape(unicode(value), quote=True).encode("utf-8")
|
||||
return escape_func(unicode(value)).encode("utf-8")
|
||||
|
||||
template_regexp = re.compile(r"{{([^}]*)}}")
|
||||
new_content, count = template_regexp.subn(config_replacement, content)
|
||||
|
|
|
@ -119,7 +119,7 @@ class Stash(object):
|
|||
if internal_key in self.data:
|
||||
raise StashError("Tried to overwrite existing shared stash value "
|
||||
"for key %s (old value was %s, new value is %s)" %
|
||||
(internal_key, self[str(internal_key)], value))
|
||||
(internal_key, self.data[str(internal_key)], value))
|
||||
else:
|
||||
self.data[internal_key] = value
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue