Bug 1470658 [wpt PR 11636] - [css-color] Parsing color and opacity, a=testonly
authorEric Willigers <ewilligers@users.noreply.github.com>
Sat, 07 Jul 2018 00:07:36 +0000
changeset 426133 ed47c026dce2aea919483f2adbba6f8c274de585
parent 426132 d5982da03e7f918014b9ba84660c88e0243b6cee
child 426134 1dd327dac2f27cf226aa340fd8e8329c555f4b69
push id34267
push userrgurzau@mozilla.com
push dateWed, 11 Jul 2018 22:05:21 +0000
treeherdermozilla-central@3aca103e4915 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1470658, 11636
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1470658 [wpt PR 11636] - [css-color] Parsing color and opacity, a=testonly Automatic update from web-platform-testsMerge pull request #11636 from ewilligers/css-color-parsing [css-color] Parsing color and opacity -- wpt-commits: 8bb14e8b2bd36d97b216ef72ec46eaae44695707 wpt-pr: 11636
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/css/css-color/parsing/color-invalid.html
testing/web-platform/tests/css/css-color/parsing/color-valid.html
testing/web-platform/tests/css/css-color/parsing/opacity-invalid.html
testing/web-platform/tests/css/css-color/parsing/opacity-valid.html
testing/web-platform/tests/css/css-color/parsing/resources/parsing-testcommon.js
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -241161,16 +241161,21 @@
      {}
     ]
    ],
    "css/css-color/lab-007-ref.html": [
     [
      {}
     ]
    ],
+   "css/css-color/parsing/resources/parsing-testcommon.js": [
+    [
+     {}
+    ]
+   ],
    "css/css-color/rebeccapurple-ref.html": [
     [
      {}
     ]
    ],
    "css/css-color/t31-color-currentColor-b-ref.html": [
     [
      {}
@@ -317659,16 +317664,40 @@
     ]
    ],
    "css/css-color/color-resolving.html": [
     [
      "/css/css-color/color-resolving.html",
      {}
     ]
    ],
+   "css/css-color/parsing/color-invalid.html": [
+    [
+     "/css/css-color/parsing/color-invalid.html",
+     {}
+    ]
+   ],
+   "css/css-color/parsing/color-valid.html": [
+    [
+     "/css/css-color/parsing/color-valid.html",
+     {}
+    ]
+   ],
+   "css/css-color/parsing/opacity-invalid.html": [
+    [
+     "/css/css-color/parsing/opacity-invalid.html",
+     {}
+    ]
+   ],
+   "css/css-color/parsing/opacity-valid.html": [
+    [
+     "/css/css-color/parsing/opacity-valid.html",
+     {}
+    ]
+   ],
    "css/css-color/rgb-rounding-001.html": [
     [
      "/css/css-color/rgb-rounding-001.html",
      {}
     ]
    ],
    "css/css-conditional/idlharness.html": [
     [
@@ -505952,16 +505981,36 @@
   "css/css-color/lch-007.html": [
    "217195f6a5931c9008d10da1cb16756a59ecda8c",
    "reftest"
   ],
   "css/css-color/named-001.html": [
    "fad454c9b86d70e19fb89265c8e131ff381ed2a0",
    "reftest"
   ],
+  "css/css-color/parsing/color-invalid.html": [
+   "a716957996b6441d1bba1d6d4fa636d4368f68c5",
+   "testharness"
+  ],
+  "css/css-color/parsing/color-valid.html": [
+   "462c103850d5880ccecdf4e7a79ac55d28380bf0",
+   "testharness"
+  ],
+  "css/css-color/parsing/opacity-invalid.html": [
+   "7ba8ffc6bbb4c27d43e9e6a11edbe52f8ca21613",
+   "testharness"
+  ],
+  "css/css-color/parsing/opacity-valid.html": [
+   "edf3b52c29261dd0d4993f076ddd01dbe7edb805",
+   "testharness"
+  ],
+  "css/css-color/parsing/resources/parsing-testcommon.js": [
+   "14f32b772f27a9bc75fe90e2ea1d8e4fb3649e95",
+   "support"
+  ],
   "css/css-color/rebeccapurple-ref.html": [
    "e089e2daad5e5db7131015bf45739e64050c6b36",
    "support"
   ],
   "css/css-color/rgb-001.html": [
    "7b7c82b0c6e0534d710bd0713a2486326d099e3f",
    "reftest"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-color/parsing/color-invalid.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS Color Module Level 3: parsing color with invalid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://www.w3.org/TR/css-color-3/#color0">
+<meta name="assert" content="color supports only the grammar '<color>'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_invalid_value("color", "auto");
+test_invalid_value("color", "123");
+test_invalid_value("color", "#12");
+test_invalid_value("color", "#123456789");
+test_invalid_value("color", "rgb");
+test_invalid_value("color", "rgb(1)");
+test_invalid_value("color", "rgb(1,2,3,4,5)");
+test_invalid_value("color", "hsla(1,2,3,4,5)");
+test_invalid_value("color", "rgb(10%, 20, 30%)");
+test_invalid_value("color", "rgba(-2, 300, 400%, -0.5)");
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-color/parsing/color-valid.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS Color Module Level 3: parsing color with valid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://www.w3.org/TR/css-color-3/#color0">
+<meta name="assert" content="color supports the full grammar '<color>'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_valid_value("color", "currentcolor"); // Edge serializes as currentColor.
+test_valid_value("color", "transparent");
+test_valid_value("color", "red");
+test_valid_value("color", "magenta");
+test_valid_value("color", "#234", "rgb(34, 51, 68)");
+test_valid_value("color", "#FEDCBA", "rgb(254, 220, 186)");
+test_valid_value("color", "rgb(2, 3, 4)");
+test_valid_value("color", "rgb(100%, 0%, 0%)", "rgb(255, 0, 0)");
+test_valid_value("color", "rgba(2, 3, 4, 0.5)"); // Safari serializes alpha-value 0.498039
+test_valid_value("color", "hsl(120, 100%, 50%)", ["rgb(0, 255, 0)", "hsl(120, 100%, 50%)"]);
+test_valid_value("color", "hsla(120, 100%, 50%, 0.25)", ["rgba(0, 255, 0, 0.25)", "hsla(120, 100%, 50%, 0.25)"]); // Safari serializes alpha-value 0.247059
+test_valid_value("color", "rgb(-2, 3, 4)", "rgb(0, 3, 4)");
+test_valid_value("color", "rgb(100, 200, 300)", "rgb(100, 200, 255)");
+test_valid_value("color", "rgb(20, 10, 0, -10)", "rgba(20, 10, 0, 0)"); // Not supported by Edge/Safari.
+test_valid_value("color", "rgb(100%, 200%, 300%)", "rgb(255, 255, 255)");
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-color/parsing/opacity-invalid.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS opacity Module Level 3: parsing opacity with invalid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://www.w3.org/TR/css-color-3/#opacity">
+<meta name="assert" content="opacity supports only the grammar '<alphavalue>'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_invalid_value("opacity", "auto");
+test_invalid_value("opacity", "10px");
+test_invalid_value("opacity", "0 1");
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-color/parsing/opacity-valid.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS opacity Module Level 3: parsing opacity with valid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://www.w3.org/TR/css-color-3/#opacity">
+<meta name="assert" content="opacity supports the full grammar '<alphavalue>'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_valid_value("opacity", "1");
+test_valid_value("opacity", "0.5");
+test_valid_value("opacity", "0");
+test_valid_value("opacity", "-2");
+test_valid_value("opacity", "3");
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-color/parsing/resources/parsing-testcommon.js
@@ -0,0 +1,39 @@
+'use strict';
+
+// serializedValue can be the expected serialization of value,
+// or an array of permitted serializations,
+// or omitted if value should serialize as value.
+function test_valid_value(property, value, serializedValue) {
+    if (arguments.length < 3)
+        serializedValue = value;
+
+    var stringifiedValue = JSON.stringify(value);
+
+    test(function(){
+        var div = document.createElement('div');
+        div.style[property] = value;
+        assert_not_equals(div.style.getPropertyValue(property), "", "property should be set");
+
+        var div = document.createElement('div');
+        div.style[property] = value;
+        var readValue = div.style.getPropertyValue(property);
+        if (serializedValue instanceof Array)
+            assert_in_array(readValue, serializedValue, "serialization should be sound");
+        else
+            assert_equals(readValue, serializedValue, "serialization should be canonical");
+
+        div.style[property] = readValue;
+        assert_equals(div.style.getPropertyValue(property), readValue, "serialization should round-trip");
+
+    }, "e.style['" + property + "'] = " + stringifiedValue + " should set the property value");
+}
+
+function test_invalid_value(property, value) {
+    var stringifiedValue = JSON.stringify(value);
+
+    test(function(){
+        var div = document.createElement('div');
+        div.style[property] = value;
+        assert_equals(div.style.getPropertyValue(property), "");
+    }, "e.style['" + property + "'] = " + stringifiedValue + " should not set the property value");
+}