1 //-------------------------------------------------------------------------------------------------------
2 // Java script library to run editing layout tests
5 var commandDelay = window.location.search.substring(1);
6 if (commandDelay == '')
8 var selection = window.getSelection();
10 //-------------------------------------------------------------------------------------------------------
12 function execSetSelectionCommand(sn, so, en, eo) {
13 window.getSelection().setBaseAndExtent(sn, so, en, eo);
15 function setSelectionCommand(sn, so, en, eo) {
16 if (commandDelay > 0) {
17 window.setTimeout(execSetSelectionCommand, commandCount * commandDelay, sn, so, en, eo);
20 execSetSelectionCommand(sn, so, en, eo);
23 //-------------------------------------------------------------------------------------------------------
25 function execTransposeCharactersCommand() {
26 document.execCommand("Transpose");
28 function transposeCharactersCommand() {
29 if (commandDelay > 0) {
30 window.setTimeout(execTransposeCharactersCommand, commandCount * commandDelay);
34 execTransposeCharactersCommand();
38 //-------------------------------------------------------------------------------------------------------
40 function execMoveSelectionForwardByCharacterCommand() {
41 selection.modify("move", "forward", "character");
43 function moveSelectionForwardByCharacterCommand() {
44 if (commandDelay > 0) {
45 window.setTimeout(execMoveSelectionForwardByCharacterCommand, commandCount * commandDelay);
49 execMoveSelectionForwardByCharacterCommand();
53 //-------------------------------------------------------------------------------------------------------
55 function execExtendSelectionForwardByCharacterCommand() {
56 selection.modify("extend", "forward", "character");
58 function extendSelectionForwardByCharacterCommand() {
59 if (commandDelay > 0) {
60 window.setTimeout(execExtendSelectionForwardByCharacterCommand, commandCount * commandDelay);
64 execExtendSelectionForwardByCharacterCommand();
68 //-------------------------------------------------------------------------------------------------------
70 function execMoveSelectionForwardByWordCommand() {
71 selection.modify("move", "forward", "word");
73 function moveSelectionForwardByWordCommand() {
74 if (commandDelay > 0) {
75 window.setTimeout(execMoveSelectionForwardByWordCommand, commandCount * commandDelay);
79 execMoveSelectionForwardByWordCommand();
83 //-------------------------------------------------------------------------------------------------------
85 function execExtendSelectionForwardByWordCommand() {
86 selection.modify("extend", "forward", "word");
88 function extendSelectionForwardByWordCommand() {
89 if (commandDelay > 0) {
90 window.setTimeout(execExtendSelectionForwardByWordCommand, commandCount * commandDelay);
94 execExtendSelectionForwardByWordCommand();
98 //-------------------------------------------------------------------------------------------------------
100 function execMoveSelectionForwardBySentenceCommand() {
101 selection.modify("move", "forward", "sentence");
103 function moveSelectionForwardBySentenceCommand() {
104 if (commandDelay > 0) {
105 window.setTimeout(execMoveSelectionForwardBySentenceCommand, commandCount * commandDelay);
109 execMoveSelectionForwardBySentenceCommand();
113 //-------------------------------------------------------------------------------------------------------
115 function execExtendSelectionForwardBySentenceCommand() {
116 selection.modify("extend", "forward", "sentence");
118 function extendSelectionForwardBySentenceCommand() {
119 if (commandDelay > 0) {
120 window.setTimeout(execExtendSelectionForwardBySentenceCommand, commandCount * commandDelay);
124 execExtendSelectionForwardBySentenceCommand();
128 //-------------------------------------------------------------------------------------------------------
130 function execMoveSelectionForwardByLineCommand() {
131 selection.modify("move", "forward", "line");
133 function moveSelectionForwardByLineCommand() {
134 if (commandDelay > 0) {
135 window.setTimeout(execMoveSelectionForwardByLineCommand, commandCount * commandDelay);
139 execMoveSelectionForwardByLineCommand();
143 //-------------------------------------------------------------------------------------------------------
145 function execExtendSelectionForwardByLineCommand() {
146 selection.modify("extend", "forward", "line");
148 function extendSelectionForwardByLineCommand() {
149 if (commandDelay > 0) {
150 window.setTimeout(execExtendSelectionForwardByLineCommand, commandCount * commandDelay);
154 execExtendSelectionForwardByLineCommand();
158 //-------------------------------------------------------------------------------------------------------
160 function execMoveSelectionBackwardByCharacterCommand() {
161 selection.modify("move", "backward", "character");
163 function moveSelectionBackwardByCharacterCommand() {
164 if (commandDelay > 0) {
165 window.setTimeout(execMoveSelectionBackwardByCharacterCommand, commandCount * commandDelay);
169 execMoveSelectionBackwardByCharacterCommand();
173 //-------------------------------------------------------------------------------------------------------
175 function execExtendSelectionBackwardByCharacterCommand() {
176 selection.modify("extend", "backward", "character");
178 function extendSelectionBackwardByCharacterCommand() {
179 if (commandDelay > 0) {
180 window.setTimeout(execExtendSelectionBackwardByCharacterCommand, commandCount * commandDelay);
184 execExtendSelectionBackwardByCharacterCommand();
188 //-------------------------------------------------------------------------------------------------------
190 function execMoveSelectionBackwardByWordCommand() {
191 selection.modify("move", "backward", "word");
193 function moveSelectionBackwardByWordCommand() {
194 if (commandDelay > 0) {
195 window.setTimeout(execMoveSelectionBackwardByWordCommand, commandCount * commandDelay);
199 execMoveSelectionBackwardByWordCommand();
203 //-------------------------------------------------------------------------------------------------------
205 function execExtendSelectionBackwardByWordCommand() {
206 selection.modify("extend", "backward", "word");
208 function extendSelectionBackwardByWordCommand() {
209 if (commandDelay > 0) {
210 window.setTimeout(execExtendSelectionBackwardByWordCommand, commandCount * commandDelay);
214 execExtendSelectionBackwardByWordCommand();
218 //-------------------------------------------------------------------------------------------------------
220 function execMoveSelectionBackwardBySentenceCommand() {
221 selection.modify("move", "backward", "sentence");
223 function moveSelectionBackwardBySentenceCommand() {
224 if (commandDelay > 0) {
225 window.setTimeout(execMoveSelectionBackwardBySentenceCommand, commandCount * commandDelay);
229 execMoveSelectionBackwardBySentenceCommand();
233 //-------------------------------------------------------------------------------------------------------
235 function execExtendSelectionBackwardBySentenceCommand() {
236 selection.modify("extend", "backward", "sentence");
238 function extendSelectionBackwardBySentenceCommand() {
239 if (commandDelay > 0) {
240 window.setTimeout(execExtendSelectionBackwardBySentenceCommand, commandCount * commandDelay);
244 execExtendSelectionBackwardBySentenceCommand();
248 //-------------------------------------------------------------------------------------------------------
250 function execMoveSelectionBackwardByLineCommand() {
251 selection.modify("move", "backward", "line");
253 function moveSelectionBackwardByLineCommand() {
254 if (commandDelay > 0) {
255 window.setTimeout(execMoveSelectionBackwardByLineCommand, commandCount * commandDelay);
259 execMoveSelectionBackwardByLineCommand();
263 //-------------------------------------------------------------------------------------------------------
265 function execExtendSelectionBackwardByLineCommand() {
266 selection.modify("extend", "backward", "line");
268 function extendSelectionBackwardByLineCommand() {
269 if (commandDelay > 0) {
270 window.setTimeout(execExtendSelectionBackwardByLineCommand, commandCount * commandDelay);
274 execExtendSelectionBackwardByLineCommand();
278 //-------------------------------------------------------------------------------------------------------
280 function execBoldCommand() {
281 document.execCommand("Bold");
283 function boldCommand() {
284 if (commandDelay > 0) {
285 window.setTimeout(execBoldCommand, commandCount * commandDelay);
293 //-------------------------------------------------------------------------------------------------------
295 function execUnderlineCommand() {
296 document.execCommand("Underline");
298 function underlineCommand() {
299 if (commandDelay > 0) {
300 window.setTimeout(execUnderlineCommand, commandCount * commandDelay);
304 execUnderlineCommand();
308 //-------------------------------------------------------------------------------------------------------
310 function execFontNameCommand() {
311 document.execCommand("FontName", false, "Courier");
313 function fontNameCommand() {
314 if (commandDelay > 0) {
315 window.setTimeout(execFontNameCommand, commandCount * commandDelay);
319 execFontNameCommand();
323 //-------------------------------------------------------------------------------------------------------
325 function execFontSizeCommand(s) {
326 if (arguments.length == 0 || s == undefined || s.length == 0)
328 document.execCommand("FontSize", false, s);
330 function fontSizeCommand(s) {
331 if (commandDelay > 0) {
332 window.setTimeout(execFontSizeCommand, commandCount * commandDelay, s);
336 execFontSizeCommand(s);
340 //-------------------------------------------------------------------------------------------------------
342 function execFontSizeDeltaCommand(s) {
343 if (arguments.length == 0 || s == undefined || s.length == 0)
345 document.execCommand("FontSizeDelta", false, s);
347 function fontSizeDeltaCommand(s) {
348 if (commandDelay > 0) {
349 window.setTimeout(execFontSizeDeltaCommand, commandCount * commandDelay, s);
353 execFontSizeDeltaCommand(s);
357 //-------------------------------------------------------------------------------------------------------
359 function execItalicCommand() {
360 document.execCommand("Italic");
362 function italicCommand() {
363 if (commandDelay > 0) {
364 window.setTimeout(execItalicCommand, commandCount * commandDelay);
373 //-------------------------------------------------------------------------------------------------------
375 function execJustifyCenterCommand() {
376 document.execCommand("JustifyCenter");
378 function justifyCenterCommand() {
379 if (commandDelay > 0) {
380 window.setTimeout(execJustifyCenterCommand, commandCount * commandDelay);
384 execJustifyCenterCommand();
389 //-------------------------------------------------------------------------------------------------------
391 function execJustifyLeftCommand() {
392 document.execCommand("JustifyLeft");
394 function justifyLeftCommand() {
395 if (commandDelay > 0) {
396 window.setTimeout(execJustifyLeftCommand, commandCount * commandDelay);
400 execJustifyLeftCommand();
405 //-------------------------------------------------------------------------------------------------------
407 function execJustifyRightCommand() {
408 document.execCommand("JustifyRight");
410 function justifyRightCommand() {
411 if (commandDelay > 0) {
412 window.setTimeout(execJustifyRightCommand, commandCount * commandDelay);
416 execJustifyRightCommand();
420 //-------------------------------------------------------------------------------------------------------
422 function execInsertHTMLCommand(html) {
423 document.execCommand("InsertHTML", false, html);
425 function insertHTMLCommand(html) {
426 if (commandDelay > 0) {
427 window.setTimeout(execInsertHTMLCommand, commandCount * commandDelay, html);
431 execInsertHTMLCommand(html);
435 //-------------------------------------------------------------------------------------------------------
437 function execInsertImageCommand(imgSrc) {
438 document.execCommand("InsertImage", false, imgSrc);
440 function insertImageCommand(imgSrc) {
441 if (commandDelay > 0) {
442 window.setTimeout(execInsertImageCommand, commandCount * commandDelay, imgSrc);
446 execInsertImageCommand(imgSrc);
450 //-------------------------------------------------------------------------------------------------------
452 function execInsertLineBreakCommand() {
453 document.execCommand("InsertLineBreak");
455 function insertLineBreakCommand() {
456 if (commandDelay > 0) {
457 window.setTimeout(execInsertLineBreakCommand, commandCount * commandDelay);
461 execInsertLineBreakCommand();
465 //-------------------------------------------------------------------------------------------------------
467 function execInsertParagraphCommand() {
468 document.execCommand("InsertParagraph");
470 function insertParagraphCommand() {
471 if (commandDelay > 0) {
472 window.setTimeout(execInsertParagraphCommand, commandCount * commandDelay);
476 execInsertParagraphCommand();
480 //-------------------------------------------------------------------------------------------------------
482 function execInsertNewlineInQuotedContentCommand() {
483 document.execCommand("InsertNewlineInQuotedContent");
485 function insertNewlineInQuotedContentCommand() {
486 if (commandDelay > 0) {
487 window.setTimeout(execInsertNewlineInQuotedContentCommand, commandCount * commandDelay);
491 execInsertNewlineInQuotedContentCommand();
495 //-------------------------------------------------------------------------------------------------------
497 function execTypeCharacterCommand(c) {
498 if (arguments.length == 0 || c == undefined || c.length == 0 || c.length > 1)
500 document.execCommand("InsertText", false, c);
502 function typeCharacterCommand(c) {
503 if (commandDelay > 0) {
504 window.setTimeout(execTypeCharacterCommand, commandCount * commandDelay, c);
508 execTypeCharacterCommand(c);
512 //-------------------------------------------------------------------------------------------------------
514 function execSelectAllCommand() {
515 document.execCommand("SelectAll");
517 function selectAllCommand() {
518 if (commandDelay > 0) {
519 window.setTimeout(execSelectAllCommand, commandCount * commandDelay);
523 execSelectAllCommand();
527 //-------------------------------------------------------------------------------------------------------
529 function execStrikethroughCommand() {
530 document.execCommand("Strikethrough");
532 function strikethroughCommand() {
533 if (commandDelay > 0) {
534 window.setTimeout(execStrikethroughCommand, commandCount * commandDelay);
538 execStrikethroughCommand();
542 //-------------------------------------------------------------------------------------------------------
544 function execUndoCommand() {
545 document.execCommand("Undo");
547 function undoCommand() {
548 if (commandDelay > 0) {
549 window.setTimeout(execUndoCommand, commandCount * commandDelay);
557 //-------------------------------------------------------------------------------------------------------
559 function execRedoCommand() {
560 document.execCommand("Redo");
562 function redoCommand() {
563 if (commandDelay > 0) {
564 window.setTimeout(execRedoCommand, commandCount * commandDelay);
572 //-------------------------------------------------------------------------------------------------------
574 function execChangeRootSize() {
575 document.getElementById("root").style.width = "600px";
577 function changeRootSize() {
578 if (commandDelay > 0) {
579 window.setTimeout(execChangeRootSize, commandCount * commandDelay);
583 execChangeRootSize();
587 //-------------------------------------------------------------------------------------------------------
589 function execCutCommand() {
590 document.execCommand("Cut");
592 function cutCommand() {
593 if (commandDelay > 0) {
594 window.setTimeout(execCutCommand, commandCount * commandDelay);
602 //-------------------------------------------------------------------------------------------------------
604 function execCopyCommand() {
605 document.execCommand("Copy");
607 function copyCommand() {
608 if (commandDelay > 0) {
609 window.setTimeout(execCopyCommand, commandCount * commandDelay);
617 //-------------------------------------------------------------------------------------------------------
619 function execPasteCommand() {
620 document.execCommand("Paste");
622 function pasteCommand() {
623 if (commandDelay > 0) {
624 window.setTimeout(execPasteCommand, commandCount * commandDelay);
632 //-------------------------------------------------------------------------------------------------------
634 function execCreateLinkCommand(url) {
635 document.execCommand("CreateLink", false, url);
637 function createLinkCommand(url) {
638 if (commandDelay > 0) {
639 window.setTimeout(execCreateLinkCommand, commandCount * commandDelay, url);
642 execCreateLinkCommand(url);
645 //-------------------------------------------------------------------------------------------------------
647 function execUnlinkCommand() {
648 document.execCommand("Unlink");
650 function unlinkCommand() {
651 if (commandDelay > 0) {
652 window.setTimeout(execUnlinkCommand, commandCount * commandDelay);
658 //-------------------------------------------------------------------------------------------------------
660 function execPasteAndMatchStyleCommand() {
661 document.execCommand("PasteAndMatchStyle");
663 function pasteAndMatchStyleCommand() {
664 if (commandDelay > 0) {
665 window.setTimeout(execPasteAndMatchStyleCommand, commandCount * commandDelay);
669 execPasteAndMatchStyleCommand();
673 //-------------------------------------------------------------------------------------------------------
675 function execDeleteCommand() {
676 document.execCommand("Delete");
678 function deleteCommand() {
679 if (commandDelay > 0) {
680 window.setTimeout(execDeleteCommand, commandCount * commandDelay);
688 //-------------------------------------------------------------------------------------------------------
690 function execForwardDeleteCommand() {
691 document.execCommand("ForwardDelete");
693 function forwardDeleteCommand() {
694 if (commandDelay > 0) {
695 window.setTimeout(execForwardDeleteCommand, commandCount * commandDelay);
699 execForwardDeleteCommand();
703 //-------------------------------------------------------------------------------------------------------
705 function runEditingTest() {
706 if (window.layoutTestController)
707 layoutTestController.dumpEditingCallbacks();
709 var elem = document.getElementById("test");
710 var selection = window.getSelection();
711 selection.setPosition(elem, 0);
715 //-------------------------------------------------------------------------------------------------------
718 function execBackColorCommand() {
719 document.execCommand("BackColor", false, "Chartreuse");
721 function backColorCommand() {
722 if (commandDelay > 0) {
723 window.setTimeout(execBackColorCommand, commandCount * commandDelay);
727 execBackColorCommand();
731 //-------------------------------------------------------------------------------------------------------
734 function runCommand(command, arg1, arg2) {
735 document.execCommand(command,arg1,arg2);
738 function executeCommand(command,arg1,arg2) {
739 if (commandDelay > 0) {
740 window.setTimeout(runCommand, commandCount * commandDelay);
744 runCommand(command,arg1,arg2);