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