|
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 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> |
|
13 |
|
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> |
|
24 |
|
25 <script type="application/javascript"> |
|
26 |
|
27 const nsIDOMNSEditableElement = |
|
28 Components.interfaces.nsIDOMNSEditableElement; |
|
29 |
|
30 Components.utils.import("resource://gre/modules/InlineSpellChecker.jsm"); |
|
31 |
|
32 function spelledTextInvoker(aID) |
|
33 { |
|
34 this.DOMNode = getNode(aID); |
|
35 |
|
36 this.eventSeq = [ |
|
37 new invokerChecker(EVENT_TEXT_ATTRIBUTE_CHANGED, this.DOMNode) |
|
38 ]; |
|
39 |
|
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; |
|
45 |
|
46 //var spellchecker = editor.getInlineSpellChecker(true); |
|
47 //spellchecker.enableRealTimeSpell = true; |
|
48 |
|
49 this.DOMNode.value = "valid text inalid tixt"; |
|
50 } |
|
51 |
|
52 this.finalCheck = function spelledTextInvoker_finalCheck() |
|
53 { |
|
54 var defAttrs = buildDefaultTextAttrs(this.DOMNode, kInputFontSize, |
|
55 kNormalFontWeight, |
|
56 kInputFontFamily); |
|
57 testDefaultTextAttrs(aID, defAttrs); |
|
58 |
|
59 var attrs = { }; |
|
60 var misspelledAttrs = { |
|
61 "invalid": "spelling" |
|
62 }; |
|
63 |
|
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 } |
|
69 |
|
70 this.getID = function spelledTextInvoker_getID() |
|
71 { |
|
72 return "text attribute change for misspelled text"; |
|
73 } |
|
74 } |
|
75 |
|
76 /** |
|
77 * Do tests. |
|
78 */ |
|
79 //gA11yEventDumpID = "eventdump"; // debug stuff |
|
80 //gA11yEventDumpToConsole = true; |
|
81 |
|
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. |
|
87 |
|
88 gQueue = new eventQueue(); |
|
89 gQueue.push(new synthFocus("input")); |
|
90 gQueue.push(new spelledTextInvoker("input")); |
|
91 gQueue.invoke(); // Will call SimpleTest.finish(); |
|
92 } |
|
93 |
|
94 SimpleTest.waitForExplicitFinish(); |
|
95 addA11yLoadEvent(doTests); |
|
96 </script> |
|
97 </head> |
|
98 |
|
99 <body> |
|
100 |
|
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> |
|
110 |
|
111 <input id="input"/> |
|
112 |
|
113 <div id="eventdump"></div> |
|
114 </body> |
|
115 </html> |