Bug 1443820 [wpt PR 9898] - Upstream CSS selectors tests to WPT, a=testonly
authorChris Nardi <cnardi@chromium.org>
Mon, 26 Mar 2018 15:33:41 +0000
changeset 411271 9dff5d3acd29a1b0452e04f8a4ae4b7aa98e8e43
parent 411270 c9bc5924730003ce7847960cee2fe8aa25138681
child 411272 80d4d807f8a1f866d92bf9ef1e59df0124382906
push id33749
push usercsabou@mozilla.com
push dateMon, 02 Apr 2018 10:18:51 +0000
treeherdermozilla-central@c44f60c43432 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1443820, 818475, 952078, 541774
milestone61.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 1443820 [wpt PR 9898] - Upstream CSS selectors tests to WPT, a=testonly Automatic update from web-platform-testsUpstream CSS selectors tests to WPT Remove already existing duplicate tests, and upstream a unified version of currently existing an + b selector parsing tests. Bug: 818475 Change-Id: Id889175e0d4df27037ee335d23020c213c148b44 Reviewed-on: https://chromium-review.googlesource.com/952078 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Commit-Queue: Chris Nardi <cnardi@chromium.org> Cr-Commit-Position: refs/heads/master@{#541774} wpt-commits: 3ac8f0533e2f064a389aef29f194761112ce0d6e wpt-pr: 9898 wpt-commits: 3ac8f0533e2f064a389aef29f194761112ce0d6e wpt-pr: 9898
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/css/selectors/anplusb-selector-parsing.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -318575,16 +318575,22 @@
     ]
    ],
    "css/motion/parsing/offset-rotate-parsing-valid.html": [
     [
      "/css/motion/parsing/offset-rotate-parsing-valid.html",
      {}
     ]
    ],
+   "css/selectors/anplusb-selector-parsing.html": [
+    [
+     "/css/selectors/anplusb-selector-parsing.html",
+     {}
+    ]
+   ],
    "css/selectors/attribute-selectors/attribute-case/cssom.html": [
     [
      "/css/selectors/attribute-selectors/attribute-case/cssom.html",
      {}
     ]
    ],
    "css/selectors/attribute-selectors/attribute-case/semantics.html": [
     [
@@ -532822,16 +532828,20 @@
   "css/selectors/README": [
    "6733737a200903ff0bdb21abfb34b7cb62c630f6",
    "support"
   ],
   "css/selectors/TODO": [
    "b45da5560d0eb821b5552f1b67fab5cead4508b1",
    "support"
   ],
+  "css/selectors/anplusb-selector-parsing.html": [
+   "f510ea09367f2219c9c7cab55e010018b893604e",
+   "testharness"
+  ],
   "css/selectors/any-link-dynamic-001-ref.html": [
    "342d89969da0ca3782efacee0ecbf882c718d6c6",
    "support"
   ],
   "css/selectors/any-link-dynamic-001.html": [
    "c33602e863151182d29afd88a8878374bb118b69",
    "reftest"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/selectors/anplusb-selector-parsing.html
@@ -0,0 +1,76 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>CSS Selectors: Test parsing of an+b selectors</title>
+        <link rel="author" title="Chris Nardi" href="mailto:cnardi@chromium.org">
+        <link rel="help" href="https://drafts.csswg.org/selectors-3/#nth-child-pseudo">
+        <link rel="help" href="https://drafts.csswg.org/selectors-3/#nth-last-child-pseudo">
+        <link rel="help" href="https://drafts.csswg.org/selectors-3/#nth-of-type-pseudo">
+        <link rel="help" href="https://drafts.csswg.org/selectors-3/#nth-last-of-type-pseudo">
+        <meta charset="utf-8">
+        <script src="/resources/testharness.js"></script>
+        <script src="/resources/testharnessreport.js"></script>
+        <style id="teststyles">
+        </style>
+    </head>
+    <body>
+        <script>
+            function add_selector_style(source) {
+                var style_element = document.getElementById("teststyles");
+                style_element.firstChild.data = source + "{ font-size: 1em; }";
+                return style_element.sheet;
+            }
+
+            function assert_selector_serializes_to(source, expected_result) {
+                test(function() {
+                    var sheet = add_selector_style(source);
+                    assert_equals(sheet.cssRules[0].selectorText, expected_result);
+                }, source + " should be parsed and serialized correctly");
+            }
+
+            function assert_invalid_selector(source) {
+                test(function() {
+                    var sheet = add_selector_style(source);
+                    assert_equals(sheet.cssRules[0], undefined);
+                }, source + " should not parse");
+            }
+
+            function run_tests_on_anplusb_selector(source) {
+                assert_selector_serializes_to(source + '(1n+0)', source + '(n)');
+                assert_selector_serializes_to(source + '(n+0)', source + '(n)');
+                assert_selector_serializes_to(source + '(n)', source + '(n)');
+                assert_selector_serializes_to(source + '(-n+0)', source + '(-n)');
+                assert_selector_serializes_to(source + '(-n)', source + '(-n)');
+                assert_selector_serializes_to(source + '(N)', source + '(n)');
+                assert_selector_serializes_to(source + '(+n+3)', source + '(n+3)');
+                assert_selector_serializes_to(source + '( +n + 7 )', source + '(n+7)');
+                assert_selector_serializes_to(source + '(  N- 123)', source + '(n-123)');
+                assert_selector_serializes_to(source + '(n- 10)', source + '(n-10)');
+                assert_selector_serializes_to(source + '(-n\n- 1)', source + '(-n-1)');
+                assert_selector_serializes_to(source + '( 23n\n\n+\n\n123 )', source + '(23n+123)');
+
+                assert_invalid_selector(source + '(n- 1 2)');
+                assert_invalid_selector(source + '(n-b1)');
+                assert_invalid_selector(source + '(n-+1)');
+                assert_invalid_selector(source + '(n-1n)');
+                assert_invalid_selector(source + '(-n -b1)');
+                assert_invalid_selector(source + '(-1n- b1)');
+                assert_invalid_selector(source + '(-n-13b1)');
+                assert_invalid_selector(source + '(-n-+1)');
+                assert_invalid_selector(source + '(-n+n)');
+                assert_invalid_selector(source + '(+ 1n)');
+                assert_invalid_selector(source + '(  n +12 3)');
+                assert_invalid_selector(source + '(  12 n )');
+                assert_invalid_selector(source + '(+12n-0+1)');
+                assert_invalid_selector(source + '(+12N -- 1)');
+                assert_invalid_selector(source + '(+12 N )');
+                assert_invalid_selector(source + '(+ n + 7)');
+            }
+
+            run_tests_on_anplusb_selector(':nth-child');
+            run_tests_on_anplusb_selector(':nth-last-child');
+            run_tests_on_anplusb_selector(':nth-of-type');
+            run_tests_on_anplusb_selector(':nth-last-of-type');
+        </script>
+    </body>
+</html>