|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
|
4 <!-- |
|
5 XUL Widget Test for textbox with Add and Undo Add to Dictionary |
|
6 --> |
|
7 <window title="Textbox Add and Undo Add to Dictionary Test" width="500" height="600" |
|
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
|
11 |
|
12 <hbox> |
|
13 <textbox id="t1" value="Hellop" oncontextmenu="runContextMenuTest()" spellcheck="true"/> |
|
14 </hbox> |
|
15 |
|
16 <!-- test results are displayed in the html:body --> |
|
17 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/> |
|
18 |
|
19 <!-- test code goes here --> |
|
20 <script type="application/javascript"><![CDATA[ |
|
21 |
|
22 SimpleTest.waitForExplicitFinish(); |
|
23 |
|
24 var textbox; |
|
25 var testNum; |
|
26 |
|
27 function bringUpContextMenu(element) |
|
28 { |
|
29 synthesizeMouseAtCenter(element, { type: "contextmenu", button: 2}); |
|
30 } |
|
31 |
|
32 function leftClickElement(element) |
|
33 { |
|
34 synthesizeMouseAtCenter(element, { button: 0 }); |
|
35 } |
|
36 |
|
37 function startTests() |
|
38 { |
|
39 textbox = document.getElementById("t1"); |
|
40 textbox.focus(); |
|
41 testNum = 0; |
|
42 |
|
43 Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm"); |
|
44 onSpellCheck(textbox, function () { |
|
45 bringUpContextMenu(textbox); |
|
46 }); |
|
47 } |
|
48 |
|
49 function runContextMenuTest() |
|
50 { |
|
51 SimpleTest.executeSoon( function() { |
|
52 // The textbox has its children in an hbox XUL element, so get that first |
|
53 var hbox = document.getAnonymousNodes(textbox).item(0); |
|
54 |
|
55 var contextMenu = document.getAnonymousElementByAttribute(hbox, "anonid", "input-box-contextmenu"); |
|
56 |
|
57 switch(testNum) |
|
58 { |
|
59 case 0: // "Add to Dictionary" button |
|
60 var addToDict = contextMenu.querySelector("[anonid=spell-add-to-dictionary]"); |
|
61 ok(!addToDict.hidden, "Is Add to Dictionary visible?"); |
|
62 |
|
63 var separator = contextMenu.querySelector("[anonid=spell-suggestions-separator]"); |
|
64 ok(!separator.hidden, "Is separator visible?"); |
|
65 |
|
66 addToDict.doCommand(); |
|
67 |
|
68 contextMenu.hidePopup(); |
|
69 testNum++; |
|
70 |
|
71 onSpellCheck(textbox, function () { |
|
72 bringUpContextMenu(textbox); |
|
73 }); |
|
74 break; |
|
75 |
|
76 case 1: // "Undo Add to Dictionary" button |
|
77 var undoAddDict = contextMenu.querySelector("[anonid=spell-undo-add-to-dictionary]"); |
|
78 ok(!undoAddDict.hidden, "Is Undo Add to Dictioanry visible?"); |
|
79 |
|
80 var separator = contextMenu.querySelector("[anonid=spell-suggestions-separator]"); |
|
81 ok(!separator.hidden, "Is separator hidden?"); |
|
82 |
|
83 undoAddDict.doCommand(); |
|
84 |
|
85 contextMenu.hidePopup(); |
|
86 onSpellCheck(textbox, function () { |
|
87 SimpleTest.finish(); |
|
88 }); |
|
89 break; |
|
90 } |
|
91 }); |
|
92 } |
|
93 |
|
94 SimpleTest.waitForFocus(startTests); |
|
95 |
|
96 ]]></script> |
|
97 |
|
98 </window> |