blob: a1069ae2e2c56093dea50a1b1bad2c93730a0ad1 [file] [log] [blame]
kocienda495c3032004-04-06 15:21:34 +00001//-------------------------------------------------------------------------------------------------------
2// Java script library to run editing layout tests
3
4var commandCount = 1;
5var commandDelay = window.location.search.substring(1);
6if (commandDelay == '')
7 commandDelay = 0;
8var selection = window.getSelection();
9
10//-------------------------------------------------------------------------------------------------------
11
12function execMoveSelectionForwardByCharacterCommand() {
13 selection.modify("move", "forward", "character");
14}
15function moveSelectionForwardByCharacterCommand() {
16 if (commandDelay > 0) {
17 window.setTimeout(execMoveSelectionForwardByCharacterCommand, commandCount * commandDelay);
18 commandCount++;
19 }
20 else {
21 execMoveSelectionForwardByCharacterCommand();
22 }
23}
24
25//-------------------------------------------------------------------------------------------------------
26
27function execExtendSelectionForwardByCharacterCommand() {
28 selection.modify("extend", "forward", "character");
29}
30function extendSelectionForwardByCharacterCommand() {
31 if (commandDelay > 0) {
32 window.setTimeout(execExtendSelectionForwardByCharacterCommand, commandCount * commandDelay);
33 commandCount++;
34 }
35 else {
36 execExtendSelectionForwardByCharacterCommand();
37 }
38}
39
40//-------------------------------------------------------------------------------------------------------
41
kocienda0c3df172004-09-13 18:39:31 +000042function execMoveSelectionForwardByWordCommand() {
43 selection.modify("move", "forward", "word");
44}
45function moveSelectionForwardByWordCommand() {
46 if (commandDelay > 0) {
47 window.setTimeout(execMoveSelectionForwardByWordCommand, commandCount * commandDelay);
48 commandCount++;
49 }
50 else {
51 execMoveSelectionForwardByWordCommand();
52 }
53}
54
55//-------------------------------------------------------------------------------------------------------
56
57function execExtendSelectionForwardByWordCommand() {
58 selection.modify("extend", "forward", "word");
59}
60function extendSelectionForwardByWordCommand() {
61 if (commandDelay > 0) {
62 window.setTimeout(execExtendSelectionForwardByWordCommand, commandCount * commandDelay);
63 commandCount++;
64 }
65 else {
66 execExtendSelectionForwardByWordCommand();
67 }
68}
69
70//-------------------------------------------------------------------------------------------------------
71
kociendae300a4c2004-08-31 15:41:34 +000072function execMoveSelectionForwardByLineCommand() {
73 selection.modify("move", "forward", "line");
kdeckerfd91e242004-07-14 00:38:38 +000074}
kociendae300a4c2004-08-31 15:41:34 +000075function moveSelectionForwardByLineCommand() {
kdeckerfd91e242004-07-14 00:38:38 +000076 if (commandDelay > 0) {
kociendae300a4c2004-08-31 15:41:34 +000077 window.setTimeout(execMoveSelectionForwardByLineCommand, commandCount * commandDelay);
kdeckerfd91e242004-07-14 00:38:38 +000078 commandCount++;
79 }
80 else {
kociendae300a4c2004-08-31 15:41:34 +000081 execMoveSelectionForwardByLineCommand();
kdeckerfd91e242004-07-14 00:38:38 +000082 }
83}
kociendae300a4c2004-08-31 15:41:34 +000084
85//-------------------------------------------------------------------------------------------------------
86
87function execExtendSelectionForwardByLineCommand() {
88 selection.modify("extend", "forward", "line");
89}
90function extendSelectionForwardByLineCommand() {
91 if (commandDelay > 0) {
92 window.setTimeout(execExtendSelectionForwardByLineCommand, commandCount * commandDelay);
93 commandCount++;
94 }
95 else {
96 execExtendSelectionForwardByLineCommand();
97 }
98}
99
kdeckerfd91e242004-07-14 00:38:38 +0000100//-------------------------------------------------------------------------------------------------------
101
kocienda495c3032004-04-06 15:21:34 +0000102function execMoveSelectionBackwardByCharacterCommand() {
103 selection.modify("move", "backward", "character");
104}
105function moveSelectionBackwardByCharacterCommand() {
106 if (commandDelay > 0) {
107 window.setTimeout(execMoveSelectionBackwardByCharacterCommand, commandCount * commandDelay);
108 commandCount++;
109 }
110 else {
111 execMoveSelectionBackwardByCharacterCommand();
112 }
113}
114
115//-------------------------------------------------------------------------------------------------------
116
117function execExtendSelectionBackwardByCharacterCommand() {
118 selection.modify("extend", "backward", "character");
119}
120function extendSelectionBackwardByCharacterCommand() {
121 if (commandDelay > 0) {
122 window.setTimeout(execExtendSelectionBackwardByCharacterCommand, commandCount * commandDelay);
123 commandCount++;
124 }
125 else {
126 execExtendSelectionBackwardByCharacterCommand();
127 }
128}
129
130//-------------------------------------------------------------------------------------------------------
131
kocienda0c3df172004-09-13 18:39:31 +0000132function execMoveSelectionBackwardByWordCommand() {
133 selection.modify("move", "backward", "word");
134}
135function moveSelectionBackwardByWordCommand() {
136 if (commandDelay > 0) {
137 window.setTimeout(execMoveSelectionBackwardByWordCommand, commandCount * commandDelay);
138 commandCount++;
139 }
140 else {
141 execMoveSelectionBackwardByWordCommand();
142 }
143}
144
145//-------------------------------------------------------------------------------------------------------
146
147function execExtendSelectionBackwardByWordCommand() {
148 selection.modify("extend", "backward", "word");
149}
150function extendSelectionBackwardByWordCommand() {
151 if (commandDelay > 0) {
152 window.setTimeout(execExtendSelectionBackwardByWordCommand, commandCount * commandDelay);
153 commandCount++;
154 }
155 else {
156 execExtendSelectionBackwardByWordCommand();
157 }
158}
159
160//-------------------------------------------------------------------------------------------------------
161
kociendae300a4c2004-08-31 15:41:34 +0000162function execMoveSelectionBackwardByLineCommand() {
163 selection.modify("move", "backward", "line");
164}
165function moveSelectionBackwardByLineCommand() {
166 if (commandDelay > 0) {
167 window.setTimeout(execMoveSelectionBackwardByLineCommand, commandCount * commandDelay);
168 commandCount++;
169 }
170 else {
171 execMoveSelectionBackwardByLineCommand();
172 }
173}
174
175//-------------------------------------------------------------------------------------------------------
176
177function execExtendSelectionBackwardByLineCommand() {
178 selection.modify("extend", "backward", "line");
179}
180function extendSelectionBackwardByLineCommand() {
181 if (commandDelay > 0) {
182 window.setTimeout(execExtendSelectionBackwardByLineCommand, commandCount * commandDelay);
183 commandCount++;
184 }
185 else {
186 execExtendSelectionBackwardByLineCommand();
187 }
188}
189
190//-------------------------------------------------------------------------------------------------------
191
kocienda259ced72004-06-11 18:33:50 +0000192function execBoldCommand() {
193 document.execCommand("Bold");
194}
195function boldCommand() {
196 if (commandDelay > 0) {
197 window.setTimeout(execBoldCommand, commandCount * commandDelay);
198 commandCount++;
199 }
200 else {
201 execBoldCommand();
202 }
203}
204
kocienda10bf0db2005-01-17 22:18:47 +0000205//-------------------------------------------------------------------------------------------------------
206
mjse99cfcb2005-01-28 01:13:07 +0000207function execUnderlineCommand() {
208 document.execCommand("Underline");
209}
210function underlineCommand() {
211 if (commandDelay > 0) {
212 window.setTimeout(execUnderlineCommand, commandCount * commandDelay);
213 commandCount++;
214 }
215 else {
216 execUnderlineCommand();
217 }
218}
219
220//-------------------------------------------------------------------------------------------------------
221
kocienda10bf0db2005-01-17 22:18:47 +0000222function execFontNameCommand() {
223 document.execCommand("FontName", false, "Courier");
224}
225function fontNameCommand() {
226 if (commandDelay > 0) {
227 window.setTimeout(execFontNameCommand, commandCount * commandDelay);
228 commandCount++;
229 }
230 else {
231 execFontNameCommand();
232 }
233}
234
235//-------------------------------------------------------------------------------------------------------
236
237function execFontSizeCommand(s) {
238 if (arguments.length == 0 || s == undefined || s.length == 0)
239 s = '12px';
240 document.execCommand("FontSize", false, s);
241}
242function fontSizeCommand(s) {
243 if (commandDelay > 0) {
244 window.setTimeout(execFontSizeCommand, commandCount * commandDelay, s);
245 commandCount++;
246 }
247 else {
248 execFontSizeCommand(s);
249 }
250}
251
252//-------------------------------------------------------------------------------------------------------
253
254function execFontSizeDeltaCommand(s) {
255 if (arguments.length == 0 || s == undefined || s.length == 0)
256 s = '1px';
257 document.execCommand("FontSizeDelta", false, s);
258}
259function fontSizeDeltaCommand(s) {
260 if (commandDelay > 0) {
261 window.setTimeout(execFontSizeDeltaCommand, commandCount * commandDelay, s);
262 commandCount++;
263 }
264 else {
265 execFontSizeDeltaCommand(s);
266 }
267}
kdeckerfd91e242004-07-14 00:38:38 +0000268
kocienda259ced72004-06-11 18:33:50 +0000269//-------------------------------------------------------------------------------------------------------
270
kocienda6a844e52004-08-31 15:02:27 +0000271function execItalicCommand() {
272 document.execCommand("Italic");
273}
274function italicCommand() {
275 if (commandDelay > 0) {
276 window.setTimeout(execItalicCommand, commandCount * commandDelay);
277 commandCount++;
278 }
279 else {
280 execItalicCommand();
281 }
282}
283
284
285//-------------------------------------------------------------------------------------------------------
286
kocienda2b62edb2004-11-01 17:56:33 +0000287function execJustifyCenterCommand() {
288 document.execCommand("JustifyCenter");
289}
290function justifyCenterCommand() {
291 if (commandDelay > 0) {
292 window.setTimeout(execJustifyCenterCommand, commandCount * commandDelay);
293 commandCount++;
294 }
295 else {
296 execJustifyCenterCommand();
297 }
298}
299
300
301//-------------------------------------------------------------------------------------------------------
302
303function execJustifyLeftCommand() {
304 document.execCommand("JustifyLeft");
305}
306function justifyLeftCommand() {
307 if (commandDelay > 0) {
308 window.setTimeout(execJustifyLeftCommand, commandCount * commandDelay);
309 commandCount++;
310 }
311 else {
312 execJustifyLeftCommand();
313 }
314}
315
316
317//-------------------------------------------------------------------------------------------------------
318
319function execJustifyRightCommand() {
320 document.execCommand("JustifyRight");
321}
322function justifyRightCommand() {
323 if (commandDelay > 0) {
324 window.setTimeout(execJustifyRightCommand, commandCount * commandDelay);
325 commandCount++;
326 }
327 else {
328 execJustifyRightCommand();
329 }
330}
331
332
333//-------------------------------------------------------------------------------------------------------
334
kocienda4b4f21f2004-12-03 17:31:30 +0000335function execInsertLineBreakCommand() {
336 document.execCommand("InsertLineBreak");
kocienda259ced72004-06-11 18:33:50 +0000337}
kocienda4b4f21f2004-12-03 17:31:30 +0000338function insertLineBreakCommand() {
kocienda259ced72004-06-11 18:33:50 +0000339 if (commandDelay > 0) {
kocienda4b4f21f2004-12-03 17:31:30 +0000340 window.setTimeout(execInsertLineBreakCommand, commandCount * commandDelay);
kocienda259ced72004-06-11 18:33:50 +0000341 commandCount++;
342 }
343 else {
kocienda4b4f21f2004-12-03 17:31:30 +0000344 execInsertLineBreakCommand();
kocienda259ced72004-06-11 18:33:50 +0000345 }
346}
347
348//-------------------------------------------------------------------------------------------------------
kocienda5f52bcb2004-12-06 17:39:44 +0000349
350function execInsertParagraphCommand() {
351 document.execCommand("InsertParagraph");
352}
353function insertParagraphCommand() {
354 if (commandDelay > 0) {
355 window.setTimeout(execInsertParagraphCommand, commandCount * commandDelay);
356 commandCount++;
357 }
358 else {
359 execInsertParagraphCommand();
360 }
361}
362
363//-------------------------------------------------------------------------------------------------------
kocienda259ced72004-06-11 18:33:50 +0000364
kocienda46aa5152004-08-31 15:14:57 +0000365function execTypeCharacterCommand(c) {
366 if (arguments.length == 0 || c == undefined || c.length == 0 || c.length > 1)
367 c = 'x';
368 document.execCommand("InsertText", false, c);
kocienda495c3032004-04-06 15:21:34 +0000369}
kocienda46aa5152004-08-31 15:14:57 +0000370function typeCharacterCommand(c) {
kocienda495c3032004-04-06 15:21:34 +0000371 if (commandDelay > 0) {
kociendaeecaf1f2004-08-31 16:39:10 +0000372 window.setTimeout(execTypeCharacterCommand, commandCount * commandDelay, c);
kocienda495c3032004-04-06 15:21:34 +0000373 commandCount++;
374 }
375 else {
kocienda46aa5152004-08-31 15:14:57 +0000376 execTypeCharacterCommand(c);
kocienda495c3032004-04-06 15:21:34 +0000377 }
378}
379
380//-------------------------------------------------------------------------------------------------------
381
382function execSelectAllCommand() {
383 document.execCommand("SelectAll");
384}
385function selectAllCommand() {
386 if (commandDelay > 0) {
387 window.setTimeout(execSelectAllCommand, commandCount * commandDelay);
388 commandCount++;
389 }
390 else {
391 execSelectAllCommand();
392 }
393}
394
395//-------------------------------------------------------------------------------------------------------
396
397function execUndoCommand() {
398 document.execCommand("Undo");
399}
400function undoCommand() {
401 if (commandDelay > 0) {
402 window.setTimeout(execUndoCommand, commandCount * commandDelay);
403 commandCount++;
404 }
405 else {
406 execUndoCommand();
407 }
408}
409
410//-------------------------------------------------------------------------------------------------------
411
412function execRedoCommand() {
413 document.execCommand("Redo");
414}
415function redoCommand() {
416 if (commandDelay > 0) {
417 window.setTimeout(execRedoCommand, commandCount * commandDelay);
418 commandCount++;
419 }
420 else {
421 execRedoCommand();
422 }
423}
424
425//-------------------------------------------------------------------------------------------------------
426
427function execChangeRootSize() {
428 document.getElementById("root").style.width = "600px";
429}
430function changeRootSize() {
431 if (commandDelay > 0) {
432 window.setTimeout(execChangeRootSize, commandCount * commandDelay);
433 commandCount++;
434 }
435 else {
436 execChangeRootSize();
437 }
438}
439
440//-------------------------------------------------------------------------------------------------------
441
kocienda69706492004-04-12 18:41:51 +0000442function execCutCommand() {
443 document.execCommand("Cut");
444}
445function cutCommand() {
446 if (commandDelay > 0) {
447 window.setTimeout(execCutCommand, commandCount * commandDelay);
448 commandCount++;
449 }
450 else {
451 execCutCommand();
452 }
453}
454
455//-------------------------------------------------------------------------------------------------------
456
457function execCopyCommand() {
458 document.execCommand("Copy");
459}
460function copyCommand() {
461 if (commandDelay > 0) {
462 window.setTimeout(execCopyCommand, commandCount * commandDelay);
463 commandCount++;
464 }
465 else {
466 execCopyCommand();
467 }
468}
469
470//-------------------------------------------------------------------------------------------------------
471
472function execPasteCommand() {
473 document.execCommand("Paste");
474}
475function pasteCommand() {
476 if (commandDelay > 0) {
477 window.setTimeout(execPasteCommand, commandCount * commandDelay);
478 commandCount++;
479 }
480 else {
481 execPasteCommand();
482 }
483}
484
485//-------------------------------------------------------------------------------------------------------
486
cblu4fb6bc52005-02-23 02:34:08 +0000487function execPasteAndMatchStyleCommand() {
488 document.execCommand("PasteAndMatchStyle");
489}
490function pasteAndMatchStyleCommand() {
491 if (commandDelay > 0) {
492 window.setTimeout(execPasteAndMatchStyleCommand, commandCount * commandDelay);
493 commandCount++;
494 }
495 else {
496 execPasteAndMatchStyleCommand();
497 }
498}
499
500//-------------------------------------------------------------------------------------------------------
501
kocienda495c3032004-04-06 15:21:34 +0000502function execDeleteCommand() {
503 document.execCommand("Delete");
504}
505function deleteCommand() {
506 if (commandDelay > 0) {
507 window.setTimeout(execDeleteCommand, commandCount * commandDelay);
508 commandCount++;
509 }
510 else {
511 execDeleteCommand();
512 }
513}
514
515//-------------------------------------------------------------------------------------------------------
516
kociendafe000852005-01-28 00:43:57 +0000517function execForwardDeleteCommand() {
518 document.execCommand("ForwardDelete");
519}
520function forwardDeleteCommand() {
521 if (commandDelay > 0) {
522 window.setTimeout(execForwardDeleteCommand, commandCount * commandDelay);
523 commandCount++;
524 }
525 else {
526 execForwardDeleteCommand();
527 }
528}
529
530//-------------------------------------------------------------------------------------------------------
531
kocienda495c3032004-04-06 15:21:34 +0000532function runEditingTest() {
533 var elem = document.getElementById("test");
534 var selection = window.getSelection();
535 selection.setPosition(elem, 0);
536 editingTest();
537}
538
539//-------------------------------------------------------------------------------------------------------
vickia1720332004-07-06 16:23:43 +0000540
kdeckerfd91e242004-07-14 00:38:38 +0000541
vickia1720332004-07-06 16:23:43 +0000542function execBackColorCommand() {
543 document.execCommand("BackColor", false, "Chartreuse");
544}
545function backColorCommand() {
546 if (commandDelay > 0) {
547 window.setTimeout(execBackColorCommand, commandCount * commandDelay);
548 commandCount++;
549 }
550 else {
551 execBackColorCommand();
552 }
553}
554
vickia1720332004-07-06 16:23:43 +0000555//-------------------------------------------------------------------------------------------------------
556
kdeckerfd91e242004-07-14 00:38:38 +0000557
558function runCommand(command, arg1, arg2) {
559 document.execCommand(command,arg1,arg2);
vickia1720332004-07-06 16:23:43 +0000560}
kdeckerfd91e242004-07-14 00:38:38 +0000561
562function executeCommand(command,arg1,arg2) {
vickia1720332004-07-06 16:23:43 +0000563 if (commandDelay > 0) {
kdeckerfd91e242004-07-14 00:38:38 +0000564 window.setTimeout(runCommand, commandCount * commandDelay);
vickia1720332004-07-06 16:23:43 +0000565 commandCount++;
566 }
567 else {
kdeckerfd91e242004-07-14 00:38:38 +0000568 runCommand(command,arg1,arg2);
vickia1720332004-07-06 16:23:43 +0000569 }
kdeckerfd91e242004-07-14 00:38:38 +0000570}
571