test_bug674927.html (1723B)
1 <!DOCTYPE html> 2 <!-- 3 https://bugzilla.mozilla.org/show_bug.cgi?id=674927 4 --> 5 <title>Test for Bug 674927</title> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/> 8 <p><span>Hello</span></p> 9 <div contenteditable>Contenteditable <i>is</i> splelchecked by default</div> 10 <textarea>Textareas are spellchekced by default</textarea> 11 <input value="Inputs are not spellcheckde by default"> 12 <script> 13 // Test the effect of setting spellcheck on various elements 14 [ 15 "html", 16 "body", 17 "p", 18 "span", 19 "div", 20 "i", 21 "textarea", 22 "input", 23 ].forEach(function(query) { 24 var element = document.querySelector(query); 25 26 // First check what happens if no attributes are set 27 var defaultSpellcheck; 28 if (element.isContentEditable || element.tagName == "TEXTAREA") { 29 defaultSpellcheck = true; 30 } else { 31 defaultSpellcheck = false; 32 } 33 is(element.spellcheck, defaultSpellcheck, 34 "Default spellcheck for <" + element.tagName.toLowerCase() + ">"); 35 36 // Now try setting spellcheck on ancestors 37 var ancestor = element; 38 do { 39 testSpellcheck(ancestor, element); 40 ancestor = ancestor.parentNode; 41 } while (ancestor.nodeType == Node.ELEMENT_NODE); 42 }); 43 44 function testSpellcheck(ancestor, element) { 45 ancestor.spellcheck = true; 46 is(element.spellcheck, true, 47 ".spellcheck on <" + element.tagName.toLowerCase() + "> with " + 48 "spellcheck=true on <" + ancestor.tagName.toLowerCase() + ">"); 49 ancestor.spellcheck = false; 50 is(element.spellcheck, false, 51 ".spellcheck on <" + element.tagName.toLowerCase() + "> with " + 52 "spellcheck=false on <" + ancestor.tagName.toLowerCase() + ">"); 53 ancestor.removeAttribute("spellcheck"); 54 } 55 </script>