aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-01-13 16:46:52 +0530
committerbors-servo <lbergstrom+bors@mozilla.com>2016-01-13 16:46:52 +0530
commit0e6bca8e8efce40f99aca24475d5ba1dac317e2c (patch)
treedf263d6fdc7868e1a098123beb5b8f70da46fc43
parentee5aead60bba3c6a482960021677aac3d559289b (diff)
parentbfec0f7274f00738592a263ab74715c6165eef69 (diff)
downloadservo-0e6bca8e8efce40f99aca24475d5ba1dac317e2c.tar.gz
servo-0e6bca8e8efce40f99aca24475d5ba1dac317e2c.zip
Auto merge of #9272 - Ms2ger:dpi, r=ato
Support device-pixel-ratio in wpt reftests. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9272) <!-- Reviewable:end -->
-rw-r--r--tests/ref/basic.list3
-rw-r--r--tests/wpt/css-tests/tools/manifest/item.py8
-rw-r--r--tests/wpt/css-tests/tools/manifest/sourcefile.py20
-rw-r--r--tests/wpt/harness/wptrunner/executors/base.py17
-rw-r--r--tests/wpt/harness/wptrunner/executors/executormarionette.py3
-rw-r--r--tests/wpt/harness/wptrunner/executors/executorselenium.py3
-rw-r--r--tests/wpt/harness/wptrunner/executors/executorservo.py5
-rw-r--r--tests/wpt/harness/wptrunner/executors/executorservodriver.py3
-rw-r--r--tests/wpt/harness/wptrunner/wpttest.py4
-rw-r--r--tests/wpt/mozilla/meta/MANIFEST.json56
-rw-r--r--tests/wpt/mozilla/tests/css/pixel_snapping_border_a.html (renamed from tests/ref/pixel_snapping_border_a.html)3
-rw-r--r--tests/wpt/mozilla/tests/css/pixel_snapping_border_ref.html (renamed from tests/ref/pixel_snapping_border_ref.html)0
-rw-r--r--tests/wpt/mozilla/tests/css/pixel_snapping_position_a.html (renamed from tests/ref/pixel_snapping_position_a.html)3
-rw-r--r--tests/wpt/mozilla/tests/css/pixel_snapping_position_ref.html (renamed from tests/ref/pixel_snapping_position_ref.html)0
-rw-r--r--tests/wpt/web-platform-tests/tools/manifest/item.py8
-rw-r--r--tests/wpt/web-platform-tests/tools/manifest/sourcefile.py20
16 files changed, 134 insertions, 22 deletions
diff --git a/tests/ref/basic.list b/tests/ref/basic.list
index 60c869a4d84..4ee563b6c09 100644
--- a/tests/ref/basic.list
+++ b/tests/ref/basic.list
@@ -4,8 +4,5 @@
# Should be == with expected failure:
fragment=top != ../html/acid2.html acid2_ref.html
-resolution=300x300,device-pixel-ratio=2 != pixel_snapping_border_a.html pixel_snapping_border_ref.html
-resolution=300x300,device-pixel-ratio=2 != pixel_snapping_position_a.html pixel_snapping_position_ref.html
-
# This file must be sorted alphabetically.
# Please run `./mach test-tidy` to check your changes.
diff --git a/tests/wpt/css-tests/tools/manifest/item.py b/tests/wpt/css-tests/tools/manifest/item.py
index 8ee17004495..70f51d10cb9 100644
--- a/tests/wpt/css-tests/tools/manifest/item.py
+++ b/tests/wpt/css-tests/tools/manifest/item.py
@@ -123,7 +123,7 @@ class RefTest(URLManifestItem):
item_type = "reftest"
def __init__(self, source_file, url, references, url_base="/", timeout=None,
- viewport_size=None, manifest=None):
+ viewport_size=None, dpi=None, manifest=None):
URLManifestItem.__init__(self, source_file, url, url_base=url_base, manifest=manifest)
for _, ref_type in references:
if ref_type not in ["==", "!="]:
@@ -131,13 +131,14 @@ class RefTest(URLManifestItem):
self.references = tuple(references)
self.timeout = timeout
self.viewport_size = viewport_size
+ self.dpi = dpi
@property
def is_reference(self):
return self.source_file.name_is_reference
def meta_key(self):
- return (self.timeout, self.viewport_size)
+ return (self.timeout, self.viewport_size, self.dpi)
def to_json(self):
rv = URLManifestItem.to_json(self)
@@ -146,6 +147,8 @@ class RefTest(URLManifestItem):
rv["timeout"] = self.timeout
if self.viewport_size is not None:
rv["viewport_size"] = self.viewport_size
+ if self.dpi is not None:
+ rv["dpi"] = self.dpi
return rv
@classmethod
@@ -157,6 +160,7 @@ class RefTest(URLManifestItem):
url_base=manifest.url_base,
timeout=obj.get("timeout"),
viewport_size=obj.get("viewport_size"),
+ dpi=obj.get("dpi"),
manifest=manifest)
diff --git a/tests/wpt/css-tests/tools/manifest/sourcefile.py b/tests/wpt/css-tests/tools/manifest/sourcefile.py
index 3681f85276e..fb592272119 100644
--- a/tests/wpt/css-tests/tools/manifest/sourcefile.py
+++ b/tests/wpt/css-tests/tools/manifest/sourcefile.py
@@ -198,6 +198,23 @@ class SourceFile(object):
return self.viewport_nodes[0].attrib.get("content", None)
@cached_property
+ def dpi_nodes(self):
+ """List of ElementTree Elements corresponding to nodes in a test that
+ specify device pixel ratios"""
+ return self.root.findall(".//{http://www.w3.org/1999/xhtml}meta[@name='device-pixel-ratio']")
+
+ @cached_property
+ def dpi(self):
+ """The device pixel ratio of a test or reference file"""
+ if not self.root:
+ return None
+
+ if not self.dpi_nodes:
+ return None
+
+ return self.dpi_nodes[0].attrib.get("content", None)
+
+ @cached_property
def testharness_nodes(self):
"""List of ElementTree Elements corresponding to nodes representing a
testharness.js script"""
@@ -288,7 +305,8 @@ class SourceFile(object):
rv.append(TestharnessTest(self, url, timeout=self.timeout))
elif self.content_is_ref_node:
- rv = [RefTest(self, self.url, self.references, timeout=self.timeout, viewport_size=self.viewport_size)]
+ rv = [RefTest(self, self.url, self.references, timeout=self.timeout,
+ viewport_size=self.viewport_size, dpi=self.dpi)]
else:
# If nothing else it's a helper file, which we don't have a specific type for
diff --git a/tests/wpt/harness/wptrunner/executors/base.py b/tests/wpt/harness/wptrunner/executors/base.py
index 614eeee86e6..0c8c2a1bc50 100644
--- a/tests/wpt/harness/wptrunner/executors/base.py
+++ b/tests/wpt/harness/wptrunner/executors/base.py
@@ -206,12 +206,12 @@ class RefTestImplementation(object):
def logger(self):
return self.executor.logger
- def get_hash(self, test, viewport_size):
+ def get_hash(self, test, viewport_size, dpi):
timeout = test.timeout * self.timeout_multiplier
- key = (test.url, viewport_size)
+ key = (test.url, viewport_size, dpi)
if key not in self.screenshot_cache:
- success, data = self.executor.screenshot(test, viewport_size)
+ success, data = self.executor.screenshot(test, viewport_size, dpi)
if not success:
return False, data
@@ -236,6 +236,7 @@ class RefTestImplementation(object):
def run_test(self, test):
viewport_size = test.viewport_size
+ dpi = test.dpi
self.message = []
# Depth-first search of reference tree, with the goal
@@ -249,7 +250,7 @@ class RefTestImplementation(object):
nodes, relation = stack.pop()
for i, node in enumerate(nodes):
- success, data = self.get_hash(node, viewport_size)
+ success, data = self.get_hash(node, viewport_size, dpi)
if success is False:
return {"status": data[0], "message": data[1]}
@@ -266,7 +267,7 @@ class RefTestImplementation(object):
for i, (node, screenshot) in enumerate(zip(nodes, screenshots)):
if screenshot is None:
- success, screenshot = self.retake_screenshot(node, viewport_size)
+ success, screenshot = self.retake_screenshot(node, viewport_size, dpi)
if success:
screenshots[i] = screenshot
@@ -277,12 +278,12 @@ class RefTestImplementation(object):
"message": "\n".join(self.message),
"extra": {"reftest_screenshots": log_data}}
- def retake_screenshot(self, node, viewport_size):
- success, data = self.executor.screenshot(node, viewport_size)
+ def retake_screenshot(self, node, viewport_size, dpi):
+ success, data = self.executor.screenshot(node, viewport_size, dpi)
if not success:
return False, data
- key = (node.url, viewport_size)
+ key = (node.url, viewport_size, dpi)
hash_val, _ = self.screenshot_cache[key]
self.screenshot_cache[key] = hash_val, data
return True, data
diff --git a/tests/wpt/harness/wptrunner/executors/executormarionette.py b/tests/wpt/harness/wptrunner/executors/executormarionette.py
index ecae5ac5e77..c502b425da2 100644
--- a/tests/wpt/harness/wptrunner/executors/executormarionette.py
+++ b/tests/wpt/harness/wptrunner/executors/executormarionette.py
@@ -385,9 +385,10 @@ class MarionetteRefTestExecutor(RefTestExecutor):
return self.convert_result(test, result)
- def screenshot(self, test, viewport_size):
+ def screenshot(self, test, viewport_size, dpi):
# https://github.com/w3c/wptrunner/issues/166
assert viewport_size is None
+ assert dpi is None
timeout = self.timeout_multiplier * test.timeout if self.debug_info is None else None
diff --git a/tests/wpt/harness/wptrunner/executors/executorselenium.py b/tests/wpt/harness/wptrunner/executors/executorselenium.py
index 5671d476f57..587c49c7c92 100644
--- a/tests/wpt/harness/wptrunner/executors/executorselenium.py
+++ b/tests/wpt/harness/wptrunner/executors/executorselenium.py
@@ -247,9 +247,10 @@ class SeleniumRefTestExecutor(RefTestExecutor):
return self.convert_result(test, result)
- def screenshot(self, test, viewport_size):
+ def screenshot(self, test, viewport_size, dpi):
# https://github.com/w3c/wptrunner/issues/166
assert viewport_size is None
+ assert dpi is None
return SeleniumRun(self._screenshot,
self.protocol.webdriver,
diff --git a/tests/wpt/harness/wptrunner/executors/executorservo.py b/tests/wpt/harness/wptrunner/executors/executorservo.py
index 0f25aaf7b71..8189e9ac7b8 100644
--- a/tests/wpt/harness/wptrunner/executors/executorservo.py
+++ b/tests/wpt/harness/wptrunner/executors/executorservo.py
@@ -196,7 +196,7 @@ class ServoRefTestExecutor(ProcessTestExecutor):
os.rmdir(self.tempdir)
ProcessTestExecutor.teardown(self)
- def screenshot(self, test, viewport_size):
+ def screenshot(self, test, viewport_size, dpi):
full_url = self.test_url(test)
with TempFilename(self.tempdir) as output_path:
@@ -216,6 +216,9 @@ class ServoRefTestExecutor(ProcessTestExecutor):
if viewport_size:
command += ["--resolution", viewport_size]
+ if dpi:
+ command += ["--device-pixel-ratio", dpi]
+
self.command = debug_args + command
env = os.environ.copy()
diff --git a/tests/wpt/harness/wptrunner/executors/executorservodriver.py b/tests/wpt/harness/wptrunner/executors/executorservodriver.py
index 0317ca61cb8..52154d09ba0 100644
--- a/tests/wpt/harness/wptrunner/executors/executorservodriver.py
+++ b/tests/wpt/harness/wptrunner/executors/executorservodriver.py
@@ -226,9 +226,10 @@ class ServoWebDriverRefTestExecutor(RefTestExecutor):
message += traceback.format_exc(e)
return test.result_cls("ERROR", message), []
- def screenshot(self, test, viewport_size):
+ def screenshot(self, test, viewport_size, dpi):
# https://github.com/w3c/wptrunner/issues/166
assert viewport_size is None
+ assert dpi is None
timeout = (test.timeout * self.timeout_multiplier + extra_timeout
if self.debug_info is None else None)
diff --git a/tests/wpt/harness/wptrunner/wpttest.py b/tests/wpt/harness/wptrunner/wpttest.py
index 82bcc689b6b..73a50bb129e 100644
--- a/tests/wpt/harness/wptrunner/wpttest.py
+++ b/tests/wpt/harness/wptrunner/wpttest.py
@@ -216,7 +216,7 @@ class ReftestTest(Test):
def __init__(self, url, inherit_metadata, test_metadata, references,
timeout=DEFAULT_TIMEOUT, path=None, viewport_size=None,
- protocol="http"):
+ dpi=None, protocol="http"):
Test.__init__(self, url, inherit_metadata, test_metadata, timeout, path, protocol)
for _, ref_type in references:
@@ -225,6 +225,7 @@ class ReftestTest(Test):
self.references = references
self.viewport_size = viewport_size
+ self.dpi = dpi
@classmethod
def from_manifest(cls,
@@ -250,6 +251,7 @@ class ReftestTest(Test):
timeout=timeout,
path=manifest_test.path,
viewport_size=manifest_test.viewport_size,
+ dpi=manifest_test.dpi,
protocol="https" if hasattr(manifest_test, "https") and manifest_test.https else "http")
nodes[url] = node
diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json
index 83dbc474127..d6fc30b6a8f 100644
--- a/tests/wpt/mozilla/meta/MANIFEST.json
+++ b/tests/wpt/mozilla/meta/MANIFEST.json
@@ -3511,6 +3511,34 @@
"url": "/_mozilla/css/percentage_width_inline_block_a.html"
}
],
+ "css/pixel_snapping_border_a.html": [
+ {
+ "dpi": "2",
+ "path": "css/pixel_snapping_border_a.html",
+ "references": [
+ [
+ "/_mozilla/css/pixel_snapping_border_ref.html",
+ "!="
+ ]
+ ],
+ "url": "/_mozilla/css/pixel_snapping_border_a.html",
+ "viewport_size": "300x300"
+ }
+ ],
+ "css/pixel_snapping_position_a.html": [
+ {
+ "dpi": "2",
+ "path": "css/pixel_snapping_position_a.html",
+ "references": [
+ [
+ "/_mozilla/css/pixel_snapping_position_ref.html",
+ "!="
+ ]
+ ],
+ "url": "/_mozilla/css/pixel_snapping_position_a.html",
+ "viewport_size": "300x300"
+ }
+ ],
"css/png_rgba_colorspace_a.html": [
{
"path": "css/png_rgba_colorspace_a.html",
@@ -9526,6 +9554,34 @@
"url": "/_mozilla/css/percentage_width_inline_block_a.html"
}
],
+ "css/pixel_snapping_border_a.html": [
+ {
+ "dpi": "2",
+ "path": "css/pixel_snapping_border_a.html",
+ "references": [
+ [
+ "/_mozilla/css/pixel_snapping_border_ref.html",
+ "!="
+ ]
+ ],
+ "url": "/_mozilla/css/pixel_snapping_border_a.html",
+ "viewport_size": "300x300"
+ }
+ ],
+ "css/pixel_snapping_position_a.html": [
+ {
+ "dpi": "2",
+ "path": "css/pixel_snapping_position_a.html",
+ "references": [
+ [
+ "/_mozilla/css/pixel_snapping_position_ref.html",
+ "!="
+ ]
+ ],
+ "url": "/_mozilla/css/pixel_snapping_position_a.html",
+ "viewport_size": "300x300"
+ }
+ ],
"css/png_rgba_colorspace_a.html": [
{
"path": "css/png_rgba_colorspace_a.html",
diff --git a/tests/ref/pixel_snapping_border_a.html b/tests/wpt/mozilla/tests/css/pixel_snapping_border_a.html
index 78d76b1b353..c55be8adeb7 100644
--- a/tests/ref/pixel_snapping_border_a.html
+++ b/tests/wpt/mozilla/tests/css/pixel_snapping_border_a.html
@@ -3,6 +3,9 @@
<head>
<meta charset="UTF-8">
<title>Pixel snapping border test</title>
+ <meta name=device-pixel-ratio content=2>
+ <meta name=viewport-size content=300x300>
+ <link rel=mismatch href=pixel_snapping_border_ref.html>
<style>
div {
height: 101px;
diff --git a/tests/ref/pixel_snapping_border_ref.html b/tests/wpt/mozilla/tests/css/pixel_snapping_border_ref.html
index 483046f65cf..483046f65cf 100644
--- a/tests/ref/pixel_snapping_border_ref.html
+++ b/tests/wpt/mozilla/tests/css/pixel_snapping_border_ref.html
diff --git a/tests/ref/pixel_snapping_position_a.html b/tests/wpt/mozilla/tests/css/pixel_snapping_position_a.html
index a62dd36bbb4..ed438f9ed50 100644
--- a/tests/ref/pixel_snapping_position_a.html
+++ b/tests/wpt/mozilla/tests/css/pixel_snapping_position_a.html
@@ -3,6 +3,9 @@
<head>
<meta charset="UTF-8">
<title>Pixel snapping position test</title>
+ <meta name=device-pixel-ratio content=2>
+ <meta name=viewport-size content=300x300>
+ <link rel=mismatch href=pixel_snapping_position_ref.html>
<style>
div {
position: absolute;
diff --git a/tests/ref/pixel_snapping_position_ref.html b/tests/wpt/mozilla/tests/css/pixel_snapping_position_ref.html
index 58e3e4eddb0..58e3e4eddb0 100644
--- a/tests/ref/pixel_snapping_position_ref.html
+++ b/tests/wpt/mozilla/tests/css/pixel_snapping_position_ref.html
diff --git a/tests/wpt/web-platform-tests/tools/manifest/item.py b/tests/wpt/web-platform-tests/tools/manifest/item.py
index f03ea9d61b5..55bbbe80a5a 100644
--- a/tests/wpt/web-platform-tests/tools/manifest/item.py
+++ b/tests/wpt/web-platform-tests/tools/manifest/item.py
@@ -130,7 +130,7 @@ class RefTest(URLManifestItem):
item_type = "reftest"
def __init__(self, source_file, url, references, url_base="/", timeout=None,
- viewport_size=None, manifest=None):
+ viewport_size=None, dpi=None, manifest=None):
URLManifestItem.__init__(self, source_file, url, url_base=url_base, manifest=manifest)
for _, ref_type in references:
if ref_type not in ["==", "!="]:
@@ -138,13 +138,14 @@ class RefTest(URLManifestItem):
self.references = tuple(references)
self.timeout = timeout
self.viewport_size = viewport_size
+ self.dpi = dpi
@property
def is_reference(self):
return self.source_file.name_is_reference
def meta_key(self):
- return (self.timeout, self.viewport_size)
+ return (self.timeout, self.viewport_size, self.dpi)
def to_json(self):
rv = URLManifestItem.to_json(self)
@@ -153,6 +154,8 @@ class RefTest(URLManifestItem):
rv["timeout"] = self.timeout
if self.viewport_size is not None:
rv["viewport_size"] = self.viewport_size
+ if self.dpi is not None:
+ rv["dpi"] = self.dpi
return rv
@classmethod
@@ -165,6 +168,7 @@ class RefTest(URLManifestItem):
url_base=manifest.url_base,
timeout=obj.get("timeout"),
viewport_size=obj.get("viewport_size"),
+ dpi=obj.get("dpi"),
manifest=manifest)
diff --git a/tests/wpt/web-platform-tests/tools/manifest/sourcefile.py b/tests/wpt/web-platform-tests/tools/manifest/sourcefile.py
index 8950e7b1fbc..14cbdd780ca 100644
--- a/tests/wpt/web-platform-tests/tools/manifest/sourcefile.py
+++ b/tests/wpt/web-platform-tests/tools/manifest/sourcefile.py
@@ -198,6 +198,23 @@ class SourceFile(object):
return self.viewport_nodes[0].attrib.get("content", None)
@cached_property
+ def dpi_nodes(self):
+ """List of ElementTree Elements corresponding to nodes in a test that
+ specify device pixel ratios"""
+ return self.root.findall(".//{http://www.w3.org/1999/xhtml}meta[@name='device-pixel-ratio']")
+
+ @cached_property
+ def dpi(self):
+ """The device pixel ratio of a test or reference file"""
+ if not self.root:
+ return None
+
+ if not self.dpi_nodes:
+ return None
+
+ return self.dpi_nodes[0].attrib.get("content", None)
+
+ @cached_property
def testharness_nodes(self):
"""List of ElementTree Elements corresponding to nodes representing a
testharness.js script"""
@@ -288,7 +305,8 @@ class SourceFile(object):
rv.append(TestharnessTest(self, url, timeout=self.timeout))
elif self.content_is_ref_node:
- rv = [RefTest(self, self.url, self.references, timeout=self.timeout, viewport_size=self.viewport_size)]
+ rv = [RefTest(self, self.url, self.references, timeout=self.timeout,
+ viewport_size=self.viewport_size, dpi=self.dpi)]
else:
# If nothing else it's a helper file, which we don't have a specific type for