contenteditable-enumerated-ascii-case-insensitive.html (1480B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <link rel="help" href="https://html.spec.whatwg.org/#attr-contenteditable"> 4 <link rel="help" href="https://html.spec.whatwg.org/#enumerated-attribute"> 5 <meta name="assert" content="@contenteditable values are ASCII case-insensitive"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 9 <script> 10 function testValue(value, isValid) { 11 const valueLower = value.toLowerCase(); 12 13 test(() => { 14 const el = document.createElement('div'); 15 if (valueLower !== "inherit") { 16 el.setAttribute('contenteditable', value); 17 } 18 assert_equals(el.contentEditable, isValid ? valueLower : "inherit"); 19 }, `IDL attribute getter for attribute value "${value}"`); 20 21 test(() => { 22 const el = document.createElement('div'); 23 if (isValid) { 24 el.contentEditable = value; 25 assert_equals(el.getAttribute('contenteditable'), valueLower === "inherit" ? null : valueLower); 26 } else { 27 assert_throws_dom("SyntaxError", () => { 28 el.contentEditable = value; 29 }); 30 } 31 }, `IDL attribute setter for value "${value}"`); 32 } 33 34 const valid = ["true", "false", "inherit", "plaintext-only"]; // "inherit" is treated specially 35 const invalid = ["foobar", "falſe", "plaıntext-only", "plaİntext-only"]; 36 37 for (const value of valid) { 38 testValue(value, true); 39 testValue(value.toUpperCase(), true); 40 } 41 42 for (const value of invalid) { 43 testValue(value, false); 44 } 45 </script>