escaped-eof.html (1730B)
1 <!doctype html> 2 <title>Escaped EOF</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 6 <meta name="author" title="Tab Atkins-Bittner"> 7 <link rel=help href="https://drafts.csswg.org/css-syntax/#consume-escaped-code-point"> 8 <link rel=help href="https://drafts.csswg.org/css-syntax/#consume-string-token"> 9 <link rel=help href="https://drafts.csswg.org/css-syntax/#consume-token"> 10 11 <style>foo { --foo:foo\</style> 12 <style>foo { --foo:1foo\</style> 13 <style>foo { --foo:url(foo\</style> 14 <style>foo { --foo:"foo\</style> 15 16 <script> 17 test(()=>{ 18 assert_throws_dom("SyntaxError", ()=>{document.querySelector("#123");}, "numeric hash token is invalid in a selector"); 19 document.querySelector("#foo\\"); // escaped-EOF in a hash token is valid in a selector 20 }, "Escaped EOF turns into a U+FFFD in a hash token, makes it 'ID' type."); 21 22 test(()=>{ 23 const sh = document.styleSheets[0]; 24 const val = sh.cssRules[0].style.getPropertyValue("--foo"); 25 assert_equals("foo\ufffd", val); 26 }, "Escaped EOF turns into a U+FFFD in an ident token."); 27 28 test(()=>{ 29 const sh = document.styleSheets[1]; 30 const val = sh.cssRules[0].style.getPropertyValue("--foo"); 31 assert_equals("1foo\ufffd", val); 32 }, "Escaped EOF turns into a U+FFFD in a dimension token."); 33 34 test(()=>{ 35 const sh = document.styleSheets[2]; 36 const val = sh.cssRules[0].style.getPropertyValue("--foo"); 37 assert_equals("url(foo\ufffd)", val); 38 }, "Escaped EOF turns into a U+FFFD in a url token."); 39 40 test(()=>{ 41 const sh = document.styleSheets[3]; 42 const val = sh.cssRules[0].style.getPropertyValue("--foo"); 43 assert_equals(`"foo"`, val); 44 }, "Escaped EOF in a string is ignored."); 45 46 </script>