Debian Codegraph @

dijit/tests/_BidiSupport/form/robot/Textarea.html

raw symbols SCIP
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <title>doh.robot Textarea textDir Tests</title>
7
8 <style>
9 @import "../../../../../util/doh/robot/robot.css";
10 </style>
11
12 <!-- required: dojo.js -->
13 <script type="text/javascript" src="../../../../../dojo/dojo.js">
14 </script>
15
16 <script type="text/javascript">
17 dojo.require("dijit.robotx");
18
19 dojo.ready(function(){
20 doh.robot.initRobot('../test_Textarea.html');
21 var textarea;
22
23 // execute some test as soon as the widget gets focus
24 var focusThenRun = function(widget, fcn){
25 if(!widget.focused){
26 var handler = widget.connect(widget, '_onFocus', function(){
27 widget.disconnect(handler);
28 setTimeout(fcn, 1);
29 });
30 widget.focus();
31 }else{
32 fcn();
33 }
34 };
35
36 doh.register("LTR textarea", [
37 {
38 name: "initial text direction of empty 'blankL'",
39
40 setUp: function(){
41 textarea = dijit.byId("blankL");
42 modifier = dojo.isMac ? {meta: true} : {ctrl: true};
43 },
44
45 runTest: function(){
46 doh.is("ltr",textarea.focusNode.dir,"direction of :" + textarea.id);
47 }
48 },
49 {
50 name: "write in English in 'blankL'",
51 timeout: 3000,
52
53 runTest: function(){
54 var d = new doh.Deferred();
55
56 focusThenRun(textarea, function(){
57 doh.robot.typeKeys('Hello!', 1, 300);
58 doh.robot.sequence(d.getTestCallback(function(){
59 doh.is("ltr",textarea.focusNode.dir,"direction of :" + textarea.id);
60 }), 400);
61 });
62
63 return d;
64 }
65 },
66 {
67 name: "paste Hebrew in 'blankL'",
68 timeout: 3000,
69
70 runTest: function(){
71 var d = new doh.Deferred();
72
73 focusThenRun(textarea, function(){
74 doh.robot.setClipboard("\u05e9\u05dc\u05d5\u05dd\u0021",'text/html');
75
76 doh.robot.keyPress("a", 400, modifier);
77 doh.robot.keyPress(dojo.keys.DELETE, 100, {});
78
79 doh.robot.keyPress("v", 300, modifier);
80 doh.robot.sequence(d.getTestCallback(function(){
81 doh.is("ltr",textarea.focusNode.dir,"direction of :" + textarea.id);
82 }), 400);
83 });
84
85 return d;
86 }
87 }
88 ]);
89
90 doh.register("RTL textarea", [
91 {
92 name: "initial text direction of empty 'blankR'",
93
94 setUp: function(){
95 textarea = dijit.byId("blankR");
96 },
97
98 runTest: function(){
99 doh.is("rtl",textarea.focusNode.dir,"direction of :" + textarea.id);
100 }
101 },
102 {
103 name: "write in English in 'blankR'",
104 timeout: 3000,
105
106 runTest: function(){
107 var d = new doh.Deferred();
108
109 focusThenRun(textarea, function(){
110 doh.robot.typeKeys('Hello!', 1, 300);
111 doh.robot.sequence(d.getTestCallback(function(){
112 doh.is("rtl",textarea.focusNode.dir,"direction of :" + textarea.id);
113 }), 400);
114 });
115
116 return d;
117 }
118 },
119 {
120 name: "paste Hebrew in 'blankR'",
121 timeout: 3000,
122
123 runTest: function(){
124 var d = new doh.Deferred();
125
126 focusThenRun(textarea, function(){
127 doh.robot.setClipboard("\u05e9\u05dc\u05d5\u05dd\u0021",'text/html');
128
129 doh.robot.keyPress("a", 400, modifier);
130 doh.robot.keyPress(dojo.keys.DELETE, 100, {});
131
132 doh.robot.keyPress("v", 300, modifier);
133 doh.robot.sequence(d.getTestCallback(function(){
134 doh.is("rtl",textarea.focusNode.dir,"direction of :" + textarea.id);
135 }), 400);
136 });
137
138 return d;
139 }
140 }
141 ]);
142
143 doh.register("Contextual textarea", [
144 {
145 name: "initial text direction of empty 'blankA'",
146
147 setUp: function(){
148 textarea = dijit.byId("blankA");
149 },
150
151 runTest: function(){
152 doh.is(textarea.isLeftToRight() ? "ltr" : "rtl", textarea.focusNode.dir,
153 "direction of :" + textarea.id);
154 }
155 },
156 {
157 name: "text direction cut/paste English",
158 timeout: 6000,
159
160 runTest: function(){
161 var d = new doh.Deferred();
162
163 focusThenRun(textarea, function(){
164 doh.robot.setClipboard("Hello again I'm pasted!!!",'text/html');
165
166 doh.robot.keyPress("a", 400, modifier);
167 doh.robot.keyPress(dojo.keys.DELETE, 100, {});
168
169 doh.robot.keyPress("v", 400, modifier);
170 doh.robot.sequence(d.getTestCallback(function(){
171 doh.is("ltr",textarea.focusNode.dir,"direction of :" + textarea.id);
172 }), 900);
173 });
174
175 return d;
176 }
177 },
178 {
179 name: "text direction paste Hebrew before English",
180 timeout: 6000,
181
182 runTest: function(){
183 var d = new doh.Deferred();
184
185 focusThenRun(textarea, function(){
186 doh.robot.setClipboard("\u05d0\u05e0\u05d9\u0020\u05d0\u05d5\u05de\u05e8\u05ea\u003a\u0020",'text/html');
187
188 dojo.isMac ? doh.robot.keyPress("a", 100, {ctrl:true}): doh.robot.keyPress(dojo.keys.HOME, 100, {});
189
190 doh.robot.keyPress("v", 400, modifier);
191 doh.robot.sequence(d.getTestCallback(function(){
192 doh.is("rtl",textarea.focusNode.dir,"direction of :" + textarea.id);
193 }), 400);
194 });
195
196 return d;
197 }
198 }
199 ]);
200
201 doh.register("Test the programmatic textareas in the tab container", [
202 {
203 name: "initial direction of the textareas",
204
205 setUp: function(){
206 textareaL = dijit.byId("programmaticLTR");
207 textareaR = dijit.byId("programmaticRTL");
208 textareaA = dijit.byId("programmaticAuto");
209 },
210 runTest: function(){
211 doh.is("ltr",textareaL.focusNode.dir,"Initial direction of - 'programmaticLTR'");
212 doh.is("rtl",textareaR.focusNode.dir,"Initial direction of - 'programmaticRTL'");
213 doh.is("ltr",textareaA.focusNode.dir,"Initial direction of - 'programmaticAUTO'");
214 }
215 },
216 {
217 name: "direction of textareas after Hebrew button in second tab is pressed",
218
219 runTest: function(){
220 var id = "buttonHebrew";
221 var buttonHebrew = dojo.byId("buttonHebrew");
222
223 buttonHebrew.click();
224
225 doh.is("ltr",textareaL.focusNode.dir,"Initial direction of - 'programmaticLTR'");
226 doh.is("rtl",textareaR.focusNode.dir,"Initial direction of - 'programmaticRTL'");
227 doh.is("rtl",textareaA.focusNode.dir,"Initial direction of - 'programmaticAUTO'");
228 }
229 },
230 {
231 name: "direction of textareas after English button in second tab is pressed",
232
233 runTest: function(){
234 var buttonEnglish = dojo.byId("buttonEnglish");
235
236 buttonEnglish.click();
237
238 doh.is("ltr",textareaL.focusNode.dir,"Initial direction of - 'programmaticLTR'");
239 doh.is("rtl",textareaR.focusNode.dir,"Initial direction of - 'programmaticRTL'");
240 doh.is("ltr",textareaA.focusNode.dir,"Initial direction of - 'programmaticAUTO'");
241 }
242 }
243 ]);
244
245 doh.register("Test the large textareas", [
246 {
247 name: "initial direction of the textareas",
248
249 setUp: function(){
250 textareaL = dijit.byId("largeTextAreaLTR");
251 textareaR = dijit.byId("largeTextAreaRTL");
252 },
253
254 runTest: function(){
255 doh.is("ltr",textareaL.focusNode.dir,"Initial direction of - 'programmaticLTR'");
256 doh.is("rtl",textareaR.focusNode.dir,"Initial direction of - 'programmaticRTL'");
257 }
258 }
259 ]);
260
261 doh.run();
262 });
263 </script>
264 </head>
265 </html>