Update CSS tests to revision 7d0ff6117ee51720c307ea24d413d13eb5abf3e6

This commit is contained in:
Ms2ger 2016-03-01 16:08:43 +01:00
parent 40c52d55e2
commit 349c75536d
7391 changed files with 304135 additions and 153491 deletions

View file

@ -3,4 +3,4 @@
*.sw[po]
*~
\#*
runner/MANIFEST.json

View file

@ -1,8 +1,12 @@
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 get_source_file(source_files, tests_root, manifest, path):
def make_new():
from sourcefile import SourceFile
@ -17,6 +21,7 @@ def get_source_file(source_files, tests_root, manifest, path):
return source_files[path]
class ManifestItem(object):
__metaclass__ = ABCMeta
@ -58,7 +63,7 @@ class ManifestItem(object):
return hash(self.key() + self.meta_key())
def to_json(self):
return {"path": self.path}
return {"path": from_os_path(self.path)}
@classmethod
def from_json(self, manifest, tests_root, obj, source_files=None):
@ -86,7 +91,8 @@ class URLManifestItem(ManifestItem):
@classmethod
def from_json(cls, manifest, tests_root, obj, source_files=None):
source_file = get_source_file(source_files, tests_root, manifest, obj["path"])
source_file = get_source_file(source_files, tests_root, manifest,
to_os_path(obj["path"]))
return cls(source_file,
obj["url"],
url_base=manifest.url_base,
@ -111,7 +117,8 @@ class TestharnessTest(URLManifestItem):
@classmethod
def from_json(cls, manifest, tests_root, obj, source_files=None):
source_file = get_source_file(source_files, tests_root, manifest, obj["path"])
source_file = get_source_file(source_files, tests_root, manifest,
to_os_path(obj["path"]))
return cls(source_file,
obj["url"],
url_base=manifest.url_base,
@ -153,7 +160,8 @@ class RefTest(URLManifestItem):
@classmethod
def from_json(cls, manifest, tests_root, obj, source_files=None):
source_file = get_source_file(source_files, tests_root, manifest, obj["path"])
source_file = get_source_file(source_files, tests_root, manifest,
to_os_path(obj["path"]))
return cls(source_file,
obj["url"],
obj["references"],
@ -179,5 +187,6 @@ class WebdriverSpecTest(ManifestItem):
@classmethod
def from_json(cls, manifest, tests_root, obj, source_files=None):
source_file = get_source_file(source_files, tests_root, manifest, obj["path"])
source_file = get_source_file(source_files, tests_root, manifest,
to_os_path(obj["path"]))
return cls(source_file, manifest=manifest)

View file

@ -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,25 +352,30 @@ 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
def load(tests_root, manifest_path):
def load(tests_root, manifest):
logger = get_logger()
if os.path.exists(manifest_path):
logger.debug("Opening manifest at %s" % manifest_path)
else:
logger.debug("Creating new manifest at %s" % manifest_path)
try:
with open(manifest_path) as f:
manifest = Manifest.from_json(tests_root, json.load(f))
except IOError:
manifest = Manifest(None)
# "manifest" is a path or file-like object.
if isinstance(manifest, basestring):
if os.path.exists(manifest):
logger.debug("Opening manifest at %s" % manifest)
else:
logger.debug("Creating new manifest at %s" % manifest)
try:
with open(manifest) as f:
rv = Manifest.from_json(tests_root, json.load(f))
except IOError:
rv = Manifest(None)
return rv
return Manifest.from_json(tests_root, json.load(manifest))
return manifest
def write(manifest, manifest_path):
with open(manifest_path, "w") as f:
with open(manifest_path, "wb") as f:
json.dump(manifest.to_json(), f, sort_keys=True, indent=2, separators=(',', ': '))
f.write("\n")

View file

@ -134,7 +134,7 @@ class SourceFile(object):
ext = ext[1:]
if ext in ["html", "htm"]:
return "html"
if ext in ["xhtml", "xht"]:
if ext in ["xhtml", "xht", "xml"]:
return "xhtml"
if ext == "svg":
return "svg"

View file

@ -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

View file

@ -285,6 +285,10 @@ VisualOutput.prototype = {
var json = this.runner.results.to_json();
if (document.getElementById("dumpit").checked) {
this.json_results_area = Array.prototype.slice.call(this.elem.querySelectorAll("textarea"));
for(var i = 0,t = this.json_results_area.length; i < t; i++){
this.elem.removeChild(this.json_results_area[i]);
}
this.json_results_area = document.createElement("textarea");
this.json_results_area.style.width = "100%";
this.json_results_area.setAttribute("rows", "50");

View file

@ -85,7 +85,7 @@ class WebDriver(searchcontext.SearchContext):
def get_window_size(self):
"""Get the dimensions of the current window."""
result = self._window_command('GET', '/size', 'getWindowSize')
return { 'height': result[height], 'width': result[width] }
return {'height': result['height'], 'width': result['width']}
def set_window_size(self, height, width):
"""Set the size of the current window."""

View file

@ -30,7 +30,7 @@ def filesystem_path(base_path, request, url_base="/"):
if base_path is None:
base_path = request.doc_root
path = request.url_parts.path
path = urllib.unquote(request.url_parts.path)
if path.startswith(url_base):
path = path[len(url_base):]
@ -70,7 +70,7 @@ class DirectoryHandler(object):
<h1>Directory listing for %(path)s</h1>
<ul>
%(items)s
</li>
</ul>
""" % {"path": cgi.escape(request.url_parts.path),
"items": "\n".join(self.list_items(request, path))}
@ -86,7 +86,7 @@ class DirectoryHandler(object):
base_path += "/"
if base_path != "/":
link = urlparse.urljoin(base_path, "..")
yield ("""<li class="dir"><a href="%(link)s">%(name)s</a>""" %
yield ("""<li class="dir"><a href="%(link)s">%(name)s</a></li>""" %
{"link": link, "name": ".."})
for item in sorted(os.listdir(path)):
link = cgi.escape(urllib.quote(item))
@ -95,7 +95,7 @@ class DirectoryHandler(object):
class_ = "dir"
else:
class_ = "file"
yield ("""<li class="%(class)s"><a href="%(link)s">%(name)s</a>""" %
yield ("""<li class="%(class)s"><a href="%(link)s">%(name)s</a></li>""" %
{"link": link, "name": cgi.escape(item), "class": class_})
@ -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]

View file

@ -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()
@ -406,6 +409,8 @@ def template(request, content):
"query": "?%s" % request.url_parts.query}
elif field == "uuid()":
value = str(uuid.uuid4())
elif field == "url_base":
value = request.url_base
else:
raise Exception("Undefined template variable %s" % field)
@ -417,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)).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)

View file

@ -179,6 +179,10 @@ class Request(object):
Request path as it appears in the HTTP request.
.. attribute:: url_base
The prefix part of the path; typically / unless the handler has a url_base set
.. attribute:: url
Absolute URL for the request.
@ -253,6 +257,7 @@ class Request(object):
host, port = host.split(":", 1)
self.request_path = request_handler.path
self.url_base = "/"
if self.request_path.startswith(scheme + "://"):
self.url = request_handler.path

View file

@ -209,7 +209,7 @@ class Response(object):
"message": message}
data = json.dumps({"error": err})
self.status = code
self.headers = [("Content-Type", "text/json"),
self.headers = [("Content-Type", "application/json"),
("Content-Length", len(data))]
self.content = data
if code == 500:

View file

@ -237,6 +237,8 @@ class WebTestRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
# set update the doc_root of the request to reflect this
if hasattr(handler, "base_path") and handler.base_path:
request.doc_root = handler.base_path
if hasattr(handler, "url_base") and handler.url_base != "/":
request.url_base = handler.url_base
if self.server.latency is not None:
if callable(self.server.latency):

View file

@ -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