test_textattrchange.html (3204B)
1 <html> 2 3 <head> 4 <title>Text attribute changed event for misspelled text</title> 5 6 <link rel="stylesheet" type="text/css" 7 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 8 9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 10 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 11 12 <script type="application/javascript" 13 src="../common.js"></script> 14 <script type="application/javascript" 15 src="../role.js"></script> 16 <script type="application/javascript" 17 src="../states.js"></script> 18 <script type="application/javascript" 19 src="../events.js"></script> 20 <script type="application/javascript" 21 src="../attributes.js"></script> 22 23 <script type="application/javascript"> 24 25 const {InlineSpellChecker} = ChromeUtils.importESModule( 26 "resource://gre/modules/InlineSpellChecker.sys.mjs" 27 ); 28 29 function spelledTextInvoker(aID) { 30 this.DOMNode = getNode(aID); 31 32 this.eventSeq = [ 33 new invokerChecker(EVENT_TEXT_ATTRIBUTE_CHANGED, this.DOMNode), 34 ]; 35 36 this.invoke = function spelledTextInvoker_invoke() { 37 var editor = this.DOMNode.editor; 38 var spellChecker = new InlineSpellChecker(editor); 39 spellChecker.enabled = true; 40 41 // var spellchecker = editor.getInlineSpellChecker(true); 42 // spellchecker.enableRealTimeSpell = true; 43 44 this.DOMNode.value = "valid text inalid tixt"; 45 }; 46 47 this.finalCheck = function spelledTextInvoker_finalCheck() { 48 var defAttrs = buildDefaultTextAttrs(this.DOMNode, kInputFontSize, 49 kNormalFontWeight, 50 kInputFontFamily); 51 testDefaultTextAttrs(aID, defAttrs); 52 53 var attrs = { }; 54 var misspelledAttrs = { 55 "invalid": "spelling", 56 }; 57 58 testTextAttrs(aID, 0, attrs, defAttrs, 0, 11); 59 testTextAttrs(aID, 11, misspelledAttrs, defAttrs, 11, 17); 60 testTextAttrs(aID, 17, attrs, defAttrs, 17, 18); 61 testTextAttrs(aID, 18, misspelledAttrs, defAttrs, 18, 22); 62 }; 63 64 this.getID = function spelledTextInvoker_getID() { 65 return "text attribute change for misspelled text"; 66 }; 67 } 68 69 /** 70 * Do tests. 71 */ 72 // gA11yEventDumpID = "eventdump"; // debug stuff 73 // gA11yEventDumpToConsole = true; 74 75 var gQueue = null; 76 function doTests() { 77 // Synth focus before spellchecking turning on to make sure editor 78 // gets a time for initialization. 79 80 gQueue = new eventQueue(); 81 gQueue.push(new synthFocus("input")); 82 gQueue.push(new spelledTextInvoker("input")); 83 gQueue.invoke(); // Will call SimpleTest.finish(); 84 } 85 86 SimpleTest.waitForExplicitFinish(); 87 addA11yLoadEvent(doTests); 88 </script> 89 </head> 90 91 <body> 92 93 <a target="_blank" 94 href="https://bugzilla.mozilla.org/show_bug.cgi?id=345759" 95 title="Implement text attributes"> 96 Mozilla Bug 345759 97 </a> 98 <p id="display"></p> 99 <div id="content" style="display: none"></div> 100 <pre id="test"> 101 </pre> 102 103 <input id="input"/> 104 105 <div id="eventdump"></div> 106 </body> 107 </html>