diff --git a/tests/wpt/web-platform-tests/resources/docs/api.md b/tests/wpt/web-platform-tests/resources/docs/api.md
index accd18b8a42..1405cfdfecf 100644
--- a/tests/wpt/web-platform-tests/resources/docs/api.md
+++ b/tests/wpt/web-platform-tests/resources/docs/api.md
@@ -60,7 +60,7 @@ metadata, as described in the [metadata](#metadata) section below.
Testing asynchronous features is somewhat more complex since the result of
a test may depend on one or more events or other callbacks. The API provided
-for testing these features is indended to be rather low-level but hopefully
+for testing these features is intended to be rather low-level but hopefully
applicable to many situations.
To create a test, one starts by getting a Test object using async_test:
@@ -225,7 +225,7 @@ wrapping everything in functions for isolation becomes
burdensome. For these cases `testharness.js` support "single page
tests".
-In order for a test to be interpreted as a single page test, the
+In order for a test to be interpreted as a single page test, then
it must simply not call `test()` or `async_test()` anywhere on the page, and
must call the `done()` function to indicate that the test is complete. All
the `assert_*` functions are avaliable as normal, but are called without
@@ -243,7 +243,7 @@ the normal step function wrapper. For example:
```
-The test title for sinple page tests is always taken from `document.title`.
+The test title for single page tests is always taken from `document.title`.
## Making assertions ##
@@ -424,8 +424,8 @@ The framework provides callbacks corresponding to 4 events:
* `start` - triggered when the first Test is created
* `test_state` - triggered when a test state changes
- * `result` - triggered when a test result is recieved
- * `complete` - triggered when all results are recieved
+ * `result` - triggered when a test result is received
+ * `complete` - triggered when all results are received
The page defining the tests may add callbacks for these events by calling
the following methods:
diff --git a/tests/wpt/web-platform-tests/tools/manifest/item.py b/tests/wpt/web-platform-tests/tools/manifest/item.py
index 3dee3173bd0..58ff22a3b0e 100644
--- a/tests/wpt/web-platform-tests/tools/manifest/item.py
+++ b/tests/wpt/web-platform-tests/tools/manifest/item.py
@@ -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
diff --git a/tests/wpt/web-platform-tests/tools/manifest/manifest.py b/tests/wpt/web-platform-tests/tools/manifest/manifest.py
index 75a7aef0298..1128f416ddb 100644
--- a/tests/wpt/web-platform-tests/tools/manifest/manifest.py
+++ b/tests/wpt/web-platform-tests/tools/manifest/manifest.py
@@ -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
diff --git a/tests/wpt/web-platform-tests/tools/manifest/utils.py b/tests/wpt/web-platform-tests/tools/manifest/utils.py
index 60e00ee74d3..668b14c05ba 100644
--- a/tests/wpt/web-platform-tests/tools/manifest/utils.py
+++ b/tests/wpt/web-platform-tests/tools/manifest/utils.py
@@ -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
diff --git a/tests/wpt/web-platform-tests/tools/wptserve/wptserve/handlers.py b/tests/wpt/web-platform-tests/tools/wptserve/wptserve/handlers.py
index be95c7245e1..77060193140 100644
--- a/tests/wpt/web-platform-tests/tools/wptserve/wptserve/handlers.py
+++ b/tests/wpt/web-platform-tests/tools/wptserve/wptserve/handlers.py
@@ -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]
diff --git a/tests/wpt/web-platform-tests/tools/wptserve/wptserve/pipes.py b/tests/wpt/web-platform-tests/tools/wptserve/wptserve/pipes.py
index d629449f5d2..80d7944d26b 100644
--- a/tests/wpt/web-platform-tests/tools/wptserve/wptserve/pipes.py
+++ b/tests/wpt/web-platform-tests/tools/wptserve/wptserve/pipes.py
@@ -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)
diff --git a/tests/wpt/web-platform-tests/tools/wptserve/wptserve/stash.py b/tests/wpt/web-platform-tests/tools/wptserve/wptserve/stash.py
index 410ddf06436..56476176e82 100644
--- a/tests/wpt/web-platform-tests/tools/wptserve/wptserve/stash.py
+++ b/tests/wpt/web-platform-tests/tools/wptserve/wptserve/stash.py
@@ -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