/public/javascripts/dojo-1.7.0/dijit/tests/_BidiSupport/form/robot/SimpleTextarea.html

https://github.com/zerekw/Kickpunch · HTML · 388 lines · 302 code · 85 blank · 1 comment · 0 complexity · a767787b715aa5a0bc60e6a0ce0709f2 MD5 · raw file

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>doh.robot SimpleTextarea textDir Tests</title>
  6. <style>
  7. @import "../../../../../util/doh/robot/robot.css";
  8. </style>
  9. <!-- required: dojo.js -->
  10. <script type="text/javascript" src="../../../../../dojo/dojo.js">
  11. </script>
  12. <script type="text/javascript">
  13. dojo.require("dijit.robotx");
  14. dojo.ready(function(){
  15. doh.robot.initRobot('../test_SimpleTextarea.html');
  16. var textarea;
  17. var focusThenRun = function(widget, fcn){
  18. if(!widget.focused){
  19. var handler = widget.connect(widget, '_onFocus', function(){
  20. widget.disconnect(handler);
  21. setTimeout(fcn, 1);
  22. });
  23. widget.focus();
  24. }else{
  25. fcn();
  26. }
  27. };
  28. doh.register("LTR textarea", [
  29. {
  30. name: "initial text direction of filled 'ltrSimpleTexarea'",
  31. setUp: function(){
  32. textarea = dijit.byId("ltrSimpleTexarea");
  33. modifier = dojo.isMac ? {meta: true} : {ctrl: true};
  34. },
  35. runTest: function(){
  36. doh.is("ltr",textarea.focusNode.dir,"direction of :" + textarea.id);
  37. }
  38. },
  39. {
  40. name: "write in English in 'ltrSimpleTexarea'",
  41. timeout: 2000,
  42. runTest: function(){
  43. var d = new doh.Deferred();
  44. focusThenRun(textarea, function(){
  45. doh.robot.keyPress("a", 400, modifier);
  46. doh.robot.keyPress(dojo.keys.DELETE, 100, {});
  47. doh.robot.typeKeys("Hi this is my new value, and it's on English!!!", 1, 300);
  48. doh.robot.sequence(d.getTestCallback(function(){
  49. doh.is("ltr",textarea.focusNode.dir,"direction of :" + textarea.id);
  50. }), 800);
  51. });
  52. return d;
  53. }
  54. },
  55. {
  56. name: "paste Hebrew in 'ltrSimpleTexarea'",
  57. timeout: 2000,
  58. setUp: function(){
  59. textarea = dijit.byId("ltrSimpleTexarea");
  60. },
  61. runTest: function(){
  62. var d = new doh.Deferred();
  63. focusThenRun(textarea, function(){
  64. doh.robot.setClipboard("\u05d5\u05e2\u05db\u05e9\u05d9\u05d5\u0020\u05e7\u05e6\u05ea\u0020\u05d8\u05e7\u05e1\u05d8\u0020\u05d1\u05e2\u05d9\u05d1\u05e8\u05d9\u05ea\u0021\u0021\u0021\u000a\u05d0\u05e4\u05d9\u05dc\u05d5\u0020\u05e0\u05db\u05ea\u05d5\u05d1\u0020\u05e9\u05d5\u05e8\u05d4\u0020\u05e9\u05e0\u05d9\u05d9\u05d4\u002e\u0020\u0020\u0020",'text/html');
  65. doh.robot.keyPress("a", 400, modifier);
  66. doh.robot.keyPress(dojo.keys.DELETE, 100, {});
  67. doh.robot.keyPress("v", 300, modifier);
  68. doh.robot.sequence(d.getTestCallback(function(){
  69. doh.is("ltr",textarea.focusNode.dir,"direction of :" + textarea.id);
  70. }), 400);
  71. });
  72. return d;
  73. }
  74. }
  75. ]);
  76. doh.register("RTL textarea", [
  77. {
  78. name: "initial text direction of filled 'rtlSimpleTexarea'",
  79. setUp: function(){
  80. textarea = dijit.byId("rtlSimpleTexarea");
  81. },
  82. runTest: function(){
  83. doh.is("rtl",textarea.focusNode.dir,"direction of :" + textarea.id);
  84. }
  85. },
  86. {
  87. name: "write in English in 'rtlSimpleTexarea'",
  88. timeout: 2000,
  89. runTest: function(){
  90. var d = new doh.Deferred();
  91. focusThenRun(textarea, function(){
  92. doh.robot.keyPress("a", 400, modifier);
  93. doh.robot.keyPress(dojo.keys.DELETE, 100, {});
  94. doh.robot.typeKeys("Hi this is my new value, and it's on English!!!", 1, 300);
  95. doh.robot.sequence(d.getTestCallback(function(){
  96. doh.is("rtl",textarea.focusNode.dir,"direction of :" + textarea.id);
  97. }), 800);
  98. });
  99. return d;
  100. }
  101. },
  102. {
  103. name: "paste Hebrew in 'rtlSimpleTexarea'",
  104. timeout: 2000,
  105. runTest: function(){
  106. var d = new doh.Deferred();
  107. focusThenRun(textarea, function(){
  108. doh.robot.setClipboard("\u05d5\u05e2\u05db\u05e9\u05d9\u05d5\u0020\u05e7\u05e6\u05ea\u0020\u05d8\u05e7\u05e1\u05d8\u0020\u05d1\u05e2\u05d9\u05d1\u05e8\u05d9\u05ea\u0021\u0021\u0021\u000a\u05d0\u05e4\u05d9\u05dc\u05d5\u0020\u05e0\u05db\u05ea\u05d5\u05d1\u0020\u05e9\u05d5\u05e8\u05d4\u0020\u05e9\u05e0\u05d9\u05d9\u05d4\u002e\u0020\u0020\u0020",'text/html');
  109. doh.robot.keyPress("a", 400, modifier);
  110. doh.robot.keyPress(dojo.keys.DELETE, 100, {});
  111. doh.robot.keyPress("v", 300, modifier);
  112. doh.robot.sequence(d.getTestCallback(function(){
  113. doh.is("rtl",textarea.focusNode.dir,"direction of :" + textarea.id);
  114. }), 400);
  115. });
  116. return d;
  117. }
  118. }
  119. ]);
  120. doh.register("Contextual textarea", [
  121. {
  122. name: "initial text direction of filled 'contextualSimpleTexarea'",
  123. setUp: function(){
  124. textarea = dijit.byId("contextualSimpleTexarea");
  125. },
  126. runTest: function(){
  127. doh.is("rtl",textarea.focusNode.dir,"direction of :" + textarea.id);
  128. }
  129. },
  130. {
  131. name: "write in English in 'contextualSimpleTexarea'",
  132. timeout: 2000,
  133. runTest: function(){
  134. var d = new doh.Deferred();
  135. focusThenRun(textarea, function(){
  136. doh.robot.keyPress("a", 400, modifier);
  137. doh.robot.keyPress(dojo.keys.DELETE, 100, {});
  138. doh.robot.typeKeys("Hi this is my new value, and it's on English!!!", 1, 400);
  139. doh.robot.sequence(d.getTestCallback(function(){
  140. doh.is("ltr",textarea.focusNode.dir,"direction of :" + textarea.id);
  141. }), 500);
  142. });
  143. return d;
  144. }
  145. },
  146. {
  147. name: "text direction paste Hebrew before English",
  148. timeout: 3000,
  149. runTest: function(){
  150. var d = new doh.Deferred(),
  151. modifier = dojo.isMac ? {meta: true} : {ctrl: true},
  152. textarea = dijit.byId("contextualSimpleTexarea");
  153. focusThenRun(textarea, function(){
  154. doh.robot.setClipboard("\u05d0\u05e0\u05d9\u0020\u05d0\u05d5\u05de\u05e8\u05ea\u003a\u0020");
  155. dojo.isMac ? doh.robot.keyPress("a", 100, {ctrl:true}): doh.robot.keyPress(dojo.keys.HOME, 100, {});
  156. doh.robot.keyPress("v", 400, modifier);
  157. doh.robot.sequence(d.getTestCallback(function(){
  158. doh.is("rtl",textarea.focusNode.dir,"direction of :" + textarea.id);
  159. }), 800);
  160. });
  161. return d;
  162. }
  163. }
  164. ]);
  165. doh.register("programmaticAuto textarea in the border container", [
  166. {
  167. name: "initial text direction of filled 'programmaticAuto'",
  168. setUp: function(){
  169. textarea = dijit.byId("programmaticAuto");
  170. modifier = dojo.isMac ? {meta: true} : {ctrl: true};
  171. },
  172. runTest: function(){
  173. doh.is("auto",textarea.textDir,"direction of :" + textarea.id);
  174. }
  175. },
  176. {
  177. name: "write in English in 'programmaticAuto'",
  178. timeout: 2000,
  179. runTest: function(){
  180. var d = new doh.Deferred();
  181. focusThenRun(textarea, function(){
  182. doh.robot.keyPress("a", 400, modifier);
  183. doh.robot.keyPress(dojo.keys.DELETE, 100, {});
  184. doh.robot.typeKeys("Hi this is my new value, and it's on English!!!", 1, 300);
  185. doh.robot.sequence(d.getTestCallback(function(){
  186. doh.is("ltr",textarea.focusNode.dir,"direction of :" + textarea.id);
  187. }), 800);
  188. });
  189. return d;
  190. }
  191. },
  192. {
  193. name: "paste Hebrew in 'programmaticAuto'",
  194. timeout: 2000,
  195. runTest: function(){
  196. var d = new doh.Deferred();
  197. focusThenRun(textarea, function(){
  198. doh.robot.setClipboard("\u05d5\u05e2\u05db\u05e9\u05d9\u05d5\u0020\u05e7\u05e6\u05ea\u0020\u05d8\u05e7\u05e1\u05d8\u0020\u05d1\u05e2\u05d9\u05d1\u05e8\u05d9\u05ea\u0021\u0021\u0021\u000a\u05d0\u05e4\u05d9\u05dc\u05d5\u0020\u05e0\u05db\u05ea\u05d5\u05d1\u0020\u05e9\u05d5\u05e8\u05d4\u0020\u05e9\u05e0\u05d9\u05d9\u05d4\u002e\u0020\u0020\u0020",'text/html');
  199. doh.robot.keyPress("a", 400, modifier);
  200. doh.robot.keyPress(dojo.keys.DELETE, 100, {});
  201. doh.robot.keyPress("v", 300, modifier);
  202. doh.robot.sequence(d.getTestCallback(function(){
  203. doh.is("rtl",textarea.focusNode.dir,"direction of :" + textarea.id);
  204. }), 400);
  205. });
  206. return d;
  207. }
  208. }
  209. ]);
  210. doh.register("programmaticRTL textarea in the border container", [
  211. {
  212. name: "initial text direction of filled 'programmaticRTL'",
  213. setUp: function(){
  214. textarea = dijit.byId("programmaticRTL");
  215. },
  216. runTest: function(){
  217. doh.is("rtl",textarea.focusNode.dir,"direction of :" + textarea.id);
  218. }
  219. },
  220. {
  221. name: "write in English in 'programmaticRTL'",
  222. timeout: 2000,
  223. runTest: function(){
  224. var d = new doh.Deferred();
  225. focusThenRun(textarea, function(){
  226. doh.robot.keyPress("a", 400, modifier);
  227. doh.robot.keyPress(dojo.keys.DELETE, 100, {});
  228. doh.robot.typeKeys("Hi this is my new value, and it's on English!!!", 1, 300);
  229. doh.robot.sequence(d.getTestCallback(function(){
  230. doh.is("rtl",textarea.focusNode.dir,"direction of :" + textarea.id);
  231. }), 800);
  232. });
  233. return d;
  234. }
  235. },
  236. {
  237. name: "paste Hebrew in 'programmaticRTL'",
  238. timeout: 2000,
  239. runTest: function(){
  240. var d = new doh.Deferred();
  241. focusThenRun(textarea, function(){
  242. doh.robot.setClipboard("\u05d5\u05e2\u05db\u05e9\u05d9\u05d5\u0020\u05e7\u05e6\u05ea\u0020\u05d8\u05e7\u05e1\u05d8\u0020\u05d1\u05e2\u05d9\u05d1\u05e8\u05d9\u05ea\u0021\u0021\u0021\u000a\u05d0\u05e4\u05d9\u05dc\u05d5\u0020\u05e0\u05db\u05ea\u05d5\u05d1\u0020\u05e9\u05d5\u05e8\u05d4\u0020\u05e9\u05e0\u05d9\u05d9\u05d4\u002e\u0020\u0020\u0020",'text/html');
  243. doh.robot.keyPress("a", 400, modifier);
  244. doh.robot.keyPress(dojo.keys.DELETE, 100, {});
  245. doh.robot.keyPress("v", 300, modifier);
  246. doh.robot.sequence(d.getTestCallback(function(){
  247. doh.is("rtl",textarea.focusNode.dir,"direction of :" + textarea.id);
  248. }), 400);
  249. });
  250. return d;
  251. }
  252. }
  253. ]);
  254. doh.register("programmaticLTR textarea in the border container", [
  255. {
  256. name: "initial text direction of filled 'programmaticLTR'",
  257. setUp: function(){
  258. textarea = dijit.byId("programmaticLTR");
  259. },
  260. runTest: function(){
  261. doh.is("ltr",textarea.focusNode.dir,"direction of :" + textarea.id);
  262. }
  263. },
  264. {
  265. name: "write in English in 'programmaticLTR'",
  266. timeout: 2000,
  267. runTest: function(){
  268. var d = new doh.Deferred();
  269. focusThenRun(textarea, function(){
  270. doh.robot.keyPress("a", 400, modifier);
  271. doh.robot.keyPress(dojo.keys.DELETE, 100, {});
  272. doh.robot.typeKeys("Hi this is my new value, and it's on English!!!", 1, 400);
  273. doh.robot.sequence(d.getTestCallback(function(){
  274. doh.is("ltr",textarea.focusNode.dir,"direction of :" + textarea.id);
  275. }), 500);
  276. });
  277. return d;
  278. }
  279. },
  280. {
  281. name: "text direction paste Hebrew before English",
  282. timeout: 3000,
  283. runTest: function(){
  284. var d = new doh.Deferred(),
  285. modifier = dojo.isMac ? {meta: true} : {ctrl: true};
  286. focusThenRun(textarea, function(){
  287. doh.robot.setClipboard("\u05d5\u05e2\u05db\u05e9\u05d9\u05d5\u0020\u05e7\u05e6\u05ea\u0020\u05d8\u05e7\u05e1\u05d8\u0020\u05d1\u05e2\u05d9\u05d1\u05e8\u05d9\u05ea\u0021\u0021\u0021\u000a\u05d0\u05e4\u05d9\u05dc\u05d5\u0020\u05e0\u05db\u05ea\u05d5\u05d1\u0020\u05e9\u05d5\u05e8\u05d4\u0020\u05e9\u05e0\u05d9\u05d9\u05d4\u002e\u0020\u0020\u0020",'text/html');
  288. doh.robot.keyPress("a", 400, modifier);
  289. doh.robot.keyPress(dojo.keys.DELETE, 100, {});
  290. doh.robot.keyPress("v", 400, modifier);
  291. doh.robot.sequence(d.getTestCallback(function(){
  292. doh.is("ltr",textarea.focusNode.dir,"direction of :" + textarea.id);
  293. }), 800);
  294. });
  295. return d;
  296. }
  297. }
  298. ]);
  299. doh.run();
  300. });
  301. </script>
  302. </head>
  303. </html>