Update web-platform-tests to revision 8ae1ddbc812733c3a73b103eafad56fb43a2f4b5

This commit is contained in:
WPT Sync Bot 2019-01-26 20:37:16 -05:00
parent d44e9aced2
commit 0e5e5db397
109 changed files with 2053 additions and 708 deletions

View file

@ -0,0 +1,125 @@
<!doctype html>
<title>An+B Parsing</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
foo { color: blue; }
</style>
<meta name="author" title="Tab Atkins-Bittner">
<link rel=help href="https://drafts.csswg.org/css-syntax/#the-anb-type">
<script>
function roundtripANB(str) {
const rule = document.styleSheets[0].cssRules[0];
rule.selectorText = "foo";
rule.selectorText = `:nth-child(${str})`;
// Check for parse error.
if(rule.selectorText == "foo") return "parse error";
return rule.selectorText.slice(11, -1);
}
function testANB(input, expected) {
test(()=>{
assert_equals(roundtripANB(input), expected);
}, `"${input}" becomes "${expected}"`);
}
/* Just going down all the syntax clauses one-by-one */
// odd | even |
testANB("odd", "2n+1");
testANB("even", "2n");
// <integer> |
testANB("1", "1");
testANB("+1", "1");
testANB("-1", "-1");
//
// <n-dimension> |
testANB("5n", "5n");
testANB("5N", "5n");
// '+'?† n |
testANB("+n", "n");
testANB("n", "n");
testANB("N", "n");
testANB("+ n", "parse error");
// -n |
testANB("-n", "-n");
testANB("-N", "-n");
//
// <ndashdigit-dimension> |
testANB("5n-5", "5n-5");
// '+'?† <ndashdigit-ident> |
testANB("+n-5", "n-5");
testANB("n-5", "n-5");
testANB("+ n-5", "parse error");
// <dashndashdigit-ident> |
testANB("-n-5", "-n-5");
//
// <n-dimension> <signed-integer> |
testANB("5n +5", "5n+5");
testANB("5n -5", "5n-5");
// '+'?† n <signed-integer> |
testANB("+n +5", "n+5");
testANB("n +5", "n+5");
testANB("+n -5", "n-5");
testANB("+ n +5", "parse error");
testANB("n 5", "parse error");
// -n <signed-integer> |
testANB("-n +5", "-n+5");
testANB("-n -5", "-n-5");
testANB("-n 5", "parse error");
//
// <ndash-dimension> <signless-integer> |
testANB("5n- 5", "5n-5");
testANB("5n- -5", "parse error");
testANB("5n- +5", "parse error");
testANB("-5n- 5", "-5n-5");
// '+'?† n- <signless-integer> |
testANB("+n- 5", "n-5");
testANB("n- 5", "n-5");
testANB("+ n- 5", "parse error");
testANB("n- +5", "parse error");
testANB("n- -5", "parse error");
// -n- <signless-integer> |
testANB("-n- 5", "-n-5");
testANB("-n- +5", "parse error");
testANB("-n- -5", "parse error");
//
// <n-dimension> ['+' | '-'] <signless-integer>
testANB("5n + 5", "5n+5");
testANB("5n - 5", "5n-5");
testANB("5n + +5", "parse error");
testANB("5n + -5", "parse error");
testANB("5n - +5", "parse error");
testANB("5n - -5", "parse error");
// '+'?† n ['+' | '-'] <signless-integer> |
testANB("+n + 5", "n+5");
testANB("n + 5", "n+5");
testANB("+ n + 5", "parse error");
testANB("+n - 5", "n-5");
testANB("+n + +5", "parse error");
testANB("+n + -5", "parse error");
testANB("+n - +5", "parse error");
testANB("+n - -5", "parse error");
// -n ['+' | '-'] <signless-integer>
testANB("-n + 5", "-n+5");
testANB("-n - 5", "-n-5");
testANB("-n + +5", "parse error");
testANB("-n + -5", "parse error");
testANB("-n - +5", "parse error");
testANB("-n - -5", "parse error");
/* Swapped ordering is invalid */
testANB("1 - n", "parse error");
testANB("0 - n", "parse error");
testANB("-1 + n", "parse error");
/* Odd space usage */
testANB("2 n + 2", "parse error");
testANB("- 2n", "parse error");
testANB("+ 2n", "parse error");
testANB("+2 n", "parse error");
</script>

View file

@ -0,0 +1,62 @@
<!doctype html>
<title>An+B Serialization</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
foo { color: blue; }
</style>
<meta name="author" title="Tab Atkins-Bittner">
<link rel=help href="https://drafts.csswg.org/css-syntax/#serializing-anb">
<script>
function roundtripANB(str) {
const rule = document.styleSheets[0].cssRules[0];
rule.selectorText = "foo";
rule.selectorText = `:nth-child(${str})`;
// Check for parse error.
if(rule.selectorText == "foo") return "parse error";
return rule.selectorText.slice(11, -1);
}
function testANB(input, expected) {
test(()=>{
assert_equals(roundtripANB(input), expected);
}, `"${input}" becomes "${expected}"`);
}
/* A is 0, or omitted */
testANB("1", "1");
testANB("+1", "1");
testANB("-1", "-1");
testANB("0n + 0", "0");
testANB("0n + 1", "1");
testANB("0n - 1", "-1");
/* A is 1 */
testANB("1n", "n");
testANB("1n - 0", "n");
testANB("1n + 1", "n+1");
testANB("1n - 1", "n-1");
/* A is -1 */
testANB("-1n", "-n");
testANB("-1n - 0", "-n");
testANB("-1n + 1", "-n+1");
testANB("-1n - 1", "-n-1");
/* A is implied via + or - */
testANB("+n+1", "n+1");
testANB("-n-1", "-n-1");
/* B is 0 */
testANB("n + 0", "n");
testANB("n - 0", "n");
/* A & B both nonzero */
testANB("2n + 2", "2n+2");
testANB("-2n - 2", "-2n-2");
</script>

View file

@ -0,0 +1,60 @@
<!doctype html>
<title>Inclusive Ranges</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
foo { z-index: 0; }
</style>
<meta name="author" title="Tab Atkins-Bittner">
<link rel=help href="https://drafts.csswg.org/css-syntax/#digit">
<link rel=help href="https://drafts.csswg.org/css-syntax/#non-printable-code-point">
<script>
function roundtripIdent(str) {
const rule = document.styleSheets[0].cssRules[0];
rule.selectorText = "original-ident";
rule.selectorText = str;
// Check for parse error.
if(rule.selectorText == "original-ident") return "parse error";
return rule.selectorText;
}
function roundtripInteger(str) {
const rule = document.styleSheets[0].cssRules[0];
rule.style.zIndex = "12345";
rule.style.zIndex = str;
// Check for parse error.
if(rule.style.zIndex == "12345") return "parse error";
return rule.style.zIndex;
}
function testInteger(input, expected) {
test(()=>{
assert_equals(roundtripInteger(input), expected);
}, `"${input}" becomes "${expected}"`);
}
function testIdent(input, expected) {
test(()=>{
assert_equals(roundtripIdent(input), expected);
}, `"${input}" becomes "${expected}"`);
}
/* Digits are the inclusive range 0-9 */
for(var i = 0; i <= 9; i++) {
testInteger(i+"", i+"");
}
/* Non-printables are the inclusive ranges 0-8, b, e-1f, or 7f */
// 0 never shows up due to preprocessing, so start at 1
for(var i = 1; i <= 8; i++) {
testIdent("foo"+String.fromCodePoint(i), "parse error");
}
testIdent("foo"+String.fromCodePoint(0xb), "parse error");
for(var i = 0xe; i <= 0x1f; i++) {
testIdent("foo"+String.fromCodePoint(i), "parse error");
}
testIdent("foo" + String.fromCodePoint(0x7f), "parse error");
</script>

View file

@ -0,0 +1,46 @@
<!doctype html>
<title>Input Preprocessing</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
foo { color: blue; }
</style>
<meta name="author" title="Tab Atkins-Bittner">
<link rel=help href="https://drafts.csswg.org/css-syntax/#input-preprocessing">
<script>
function roundtripIdent(str) {
const rule = document.styleSheets[0].cssRules[0];
rule.selectorText = "original-ident";
rule.selectorText = str;
// Check for parse error.
if(rule.selectorText == "original-ident") return "parse error";
return rule.selectorText;
}
function testParsing(input, expected) {
test(()=>{
assert_equals(roundtripIdent(input), expected);
}, `"${input}" becomes "${expected}"`);
}
/* Can't figure out how to test the newline normalization... */
/* NULL becomes FFFD */
testParsing("foo\x00", "foo\ufffd");
testParsing("f\x00oo", "f\ufffdoo");
testParsing("\x00foo", "\ufffdfoo");
testParsing("\x00", "\ufffd");
testParsing("\x00\x00\x00", "\ufffd\ufffd\ufffd");
/* surrogates become FFFD */
testParsing("foo\ud800", "foo\ufffd");
testParsing("f\ud800oo", "f\ufffdoo");
testParsing("\ud800foo", "\ufffdfoo");
testParsing("\ud800", "\ufffd");
testParsing("\ud800\ud800\ud800", "\ufffd\ufffd\ufffd");
</script>

View file

@ -0,0 +1,36 @@
<!doctype html>
<title>Unclosed Constructs Are Valid</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<meta name="author" title="Tab Atkins-Bittner">
<link rel=help href="https://drafts.csswg.org/css-syntax/#rule-defs">
<!--
Tests that unclosed constructs are valid and match grammars,
because grammar-matching only sees the "block",
not the opening/closing characters themselves.
-->
<script>
function validSelector(str) {
try {
document.querySelector(str);
return true;
} catch(e) {
return false;
}
}
function shouldBeValid(str) {
test(()=>{
assert_true(validSelector(str));
}, `"${str}" is a valid selector`)
}
shouldBeValid("[foo]");
shouldBeValid("[foo");
shouldBeValid(":nth-child(1)");
shouldBeValid(":nth-child(1");
</script>

View file

@ -0,0 +1,62 @@
<!doctype html>
<title>CSS Whitespace</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<meta name="author" title="Tab Atkins-Bittner">
<link rel=help href="https://drafts.csswg.org/css-syntax/#whitespace">
<div class=a><b></b></div>
<div id=foo></div>
<!--
CSS's definition of "whitespace" matches HTML,
and includes only the five ASCII characters
U+0009, U+000A, U+000C, U+000D, and U+0020.
The rest of Unicode's whitespace characters,
many of which are recognized as whitespace by JS,
are not valid whitespace in CSS.
-->
<script>
function isWhitespace(codepoint) {
const char = String.fromCodePoint(codepoint);
const codepointName = "U+" + codepoint.toString(16).padStart(4, "0");
test(()=>{
const withSpace = document.querySelector(".a b");
const withChar = document.querySelector(`.a${char}b`);
assert_equals(withSpace, withChar);
}, `${codepointName} is CSS whitespace`);
}
function isNotWhitespace(codepoint) {
const char = String.fromCodePoint(codepoint);
const codepointName = "U+" + codepoint.toString(16).padStart(4, "0");
test(()=>{
const withSpace = document.querySelector(".a b");
document.querySelector("#foo").setAttribute("class", `.a${char}b`);
try {
var withChar = document.querySelector(`.a${char}b`);
} catch(e) {
assert_true(true, `${codepointName} isn't valid in a selector at all`);
return;
}
assert_not_equals(withSpace, withChar);
}, `${codepointName} is *not* CSS whitespace`);
}
// CSS Whitespace characters
var whitespace = [0x9, 0xa, 0xc, 0xd, 0x20];
// Unicode Whitespace characters not recognized by CSS
// https://en.wikipedia.org/wiki/Whitespace_character#Unicode
var notWhitespace = [0xb, 0x85, 0xa0, 0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200a, 0x2928, 0x2029, 0x202f, 0x205f, 0x3000, 0x180e, 0x200b, 0x200c, 0x200d, 0x2060, 0xfeff];
for(var codepoint of whitespace) {
isWhitespace(codepoint);
}
for(var codepoint of notWhitespace) {
isNotWhitespace(codepoint);
}
</script>