inclusive-ranges.html (1823B)
1 <!doctype html> 2 <title>Inclusive Ranges</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <style> 6 7 foo { z-index: 0; } 8 9 </style> 10 11 <meta name="author" title="Tab Atkins-Bittner"> 12 <link rel=help href="https://drafts.csswg.org/css-syntax/#digit"> 13 <link rel=help href="https://drafts.csswg.org/css-syntax/#non-printable-code-point"> 14 15 <script> 16 17 function roundtripIdent(str) { 18 const rule = document.styleSheets[0].cssRules[0]; 19 rule.selectorText = "original-ident"; 20 rule.selectorText = str; 21 // Check for parse error. 22 if(rule.selectorText == "original-ident") return "parse error"; 23 return rule.selectorText; 24 } 25 function roundtripInteger(str) { 26 const rule = document.styleSheets[0].cssRules[0]; 27 rule.style.zIndex = "12345"; 28 rule.style.zIndex = str; 29 // Check for parse error. 30 if(rule.style.zIndex == "12345") return "parse error"; 31 return rule.style.zIndex; 32 } 33 function testInteger(input, expected) { 34 test(()=>{ 35 assert_equals(roundtripInteger(input), expected); 36 }, `"${input}" becomes "${expected}"`); 37 } 38 function testIdent(input, expected) { 39 test(()=>{ 40 assert_equals(roundtripIdent(input), expected); 41 }, `"${input}" becomes "${expected}"`); 42 } 43 44 /* Digits are the inclusive range 0-9 */ 45 for(var i = 0; i <= 9; i++) { 46 testInteger(i+"", i+""); 47 } 48 49 /* Non-printables are the inclusive ranges 0-8, b, e-1f, or 7f */ 50 // 0 never shows up due to preprocessing, so start at 1 51 for(var i = 1; i <= 8; i++) { 52 testIdent("foo"+String.fromCodePoint(i), "parse error"); 53 } 54 testIdent("foo"+String.fromCodePoint(0xb), "parse error"); 55 for(var i = 0xe; i <= 0x1f; i++) { 56 testIdent("foo"+String.fromCodePoint(i), "parse error"); 57 } 58 testIdent("foo" + String.fromCodePoint(0x7f), "parse error"); 59 60 </script>