CSS-supports-L4.html (2977B)
1 <!doctype html> 2 <meta charset="utf-8"> 3 <title>CSS.supports() Level 4</title> 4 <link rel="help" href="https://www.w3.org/TR/css-conditional-4/#the-css-namespace"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script> 8 test(function() { 9 assert_equals(CSS.supports("selector(div)"), true); 10 }, "selector() function accepts a selector"); 11 12 test(function() { 13 assert_equals(CSS.supports("selector(div, div)"), false); 14 }, "selector() function doesn't accept a selector list"); 15 16 test(function() { 17 assert_equals(CSS.supports("selector(::-webkit-unknown-pseudo-element)"), false); 18 }, "selector() function rejects unknown webkit pseudo-elements."); 19 20 test(function() { 21 assert_equals(CSS.supports("selector(::before)"), true); 22 }, "selector() function accepts known pseudo-elements"); 23 24 test(function() { 25 assert_equals(CSS.supports("selector(div + .c)"), true); 26 }, "selector() with simple combinators"); 27 28 test(function() { 29 assert_equals(CSS.supports("selector(div | .c)"), false); 30 }, "selector() with unknown combinators"); 31 32 test(function() { 33 assert_equals(CSS.supports("selector(:is(:foo))"), false); 34 }, "selector() with forgiving :is, 1 arg"); 35 36 test(function() { 37 assert_equals(CSS.supports("selector(:is(:foo, div))"), false); 38 }, "selector() with forgiving :is, multiple args"); 39 40 test(function() { 41 assert_equals(CSS.supports("selector(:where(:foo))"), false); 42 }, "selector() with forgiving :where, 1 arg"); 43 44 test(function() { 45 assert_equals(CSS.supports("selector(:where(:foo, div))"), false); 46 }, "selector() with forgiving :where, multiple args"); 47 48 test(function() { 49 assert_equals(CSS.supports("selector(:has(:foo))"), false); 50 }, "selector() with forgiving :has, 1 arg"); 51 52 test(function() { 53 assert_equals(CSS.supports("selector(:has(:foo, div))"), false); 54 }, "selector() with forgiving :has, multiple args"); 55 56 test(function() { 57 assert_equals(CSS.supports("selector(:nth-child(2n + 3 of :foo))"), false); 58 }, "selector() with unforgiving :nth-child, 1 arg"); 59 60 test(function() { 61 assert_equals(CSS.supports("selector(:nth-last-child(2n + 3 of :foo))"), false); 62 }, "selector() with unforgiving :nth-last-child, 1 arg"); 63 64 test(function() { 65 assert_equals(CSS.supports("selector(:nth-child(2n + 3 of :foo, div))"), false); 66 }, "selector() with unforgiving :nth-child, multiple args"); 67 68 test(function() { 69 assert_equals(CSS.supports("selector(:nth-last-child(2n + 3 of :foo, div))"), false); 70 }, "selector() with unforgiving :nth-last-child, multiple args"); 71 72 test(function() { 73 assert_equals(CSS.supports("selector(:nth-child(2n 4))"), false); 74 }, "selector() with a non-identifier after :nth-child's An+B index"); 75 76 test(function() { 77 assert_equals(CSS.supports("selector(:nth-last-child(2n 4))"), false); 78 }, "selector() with a non-identifier after :nth-last-child's An+B index"); 79 </script>