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 execTransposeCharactersCommand() {
13 document.execCommand("Transpose");
15 function transposeCharactersCommand() {
16 if (commandDelay > 0) {
17 window.setTimeout(execTransposeCharactersCommand, commandCount * commandDelay);
21 execTransposeCharactersCommand();
25 //-------------------------------------------------------------------------------------------------------
27 function execMoveSelectionForwardByCharacterCommand() {
28 selection.modify("move", "forward", "character");
30 function moveSelectionForwardByCharacterCommand() {
31 if (commandDelay > 0) {
32 window.setTimeout(execMoveSelectionForwardByCharacterCommand, commandCount * commandDelay);
36 execMoveSelectionForwardByCharacterCommand();
40 //-------------------------------------------------------------------------------------------------------
42 function execExtendSelectionForwardByCharacterCommand() {
43 selection.modify("extend", "forward", "character");
45 function extendSelectionForwardByCharacterCommand() {
46 if (commandDelay > 0) {
47 window.setTimeout(execExtendSelectionForwardByCharacterCommand, commandCount * commandDelay);
51 execExtendSelectionForwardByCharacterCommand();
55 //-------------------------------------------------------------------------------------------------------
57 function execMoveSelectionForwardByWordCommand() {
58 selection.modify("move", "forward", "word");
60 function moveSelectionForwardByWordCommand() {
61 if (commandDelay > 0) {
62 window.setTimeout(execMoveSelectionForwardByWordCommand, commandCount * commandDelay);
66 execMoveSelectionForwardByWordCommand();
70 //-------------------------------------------------------------------------------------------------------
72 function execExtendSelectionForwardByWordCommand() {
73 selection.modify("extend", "forward", "word");
75 function extendSelectionForwardByWordCommand() {
76 if (commandDelay > 0) {
77 window.setTimeout(execExtendSelectionForwardByWordCommand, commandCount * commandDelay);
81 execExtendSelectionForwardByWordCommand();
85 //-------------------------------------------------------------------------------------------------------
87 function execMoveSelectionForwardByLineCommand() {
88 selection.modify("move", "forward", "line");
90 function moveSelectionForwardByLineCommand() {
91 if (commandDelay > 0) {
92 window.setTimeout(execMoveSelectionForwardByLineCommand, commandCount * commandDelay);
96 execMoveSelectionForwardByLineCommand();
100 //-------------------------------------------------------------------------------------------------------
102 function execExtendSelectionForwardByLineCommand() {
103 selection.modify("extend", "forward", "line");
105 function extendSelectionForwardByLineCommand() {
106 if (commandDelay > 0) {
107 window.setTimeout(execExtendSelectionForwardByLineCommand, commandCount * commandDelay);
111 execExtendSelectionForwardByLineCommand();
115 //-------------------------------------------------------------------------------------------------------
117 function execMoveSelectionBackwardByCharacterCommand() {
118 selection.modify("move", "backward", "character");
120 function moveSelectionBackwardByCharacterCommand() {
121 if (commandDelay > 0) {
122 window.setTimeout(execMoveSelectionBackwardByCharacterCommand, commandCount * commandDelay);
126 execMoveSelectionBackwardByCharacterCommand();
130 //-------------------------------------------------------------------------------------------------------
132 function execExtendSelectionBackwardByCharacterCommand() {
133 selection.modify("extend", "backward", "character");
135 function extendSelectionBackwardByCharacterCommand() {
136 if (commandDelay > 0) {
137 window.setTimeout(execExtendSelectionBackwardByCharacterCommand, commandCount * commandDelay);
141 execExtendSelectionBackwardByCharacterCommand();
145 //-------------------------------------------------------------------------------------------------------
147 function execMoveSelectionBackwardByWordCommand() {
148 selection.modify("move", "backward", "word");
150 function moveSelectionBackwardByWordCommand() {
151 if (commandDelay > 0) {
152 window.setTimeout(execMoveSelectionBackwardByWordCommand, commandCount * commandDelay);
156 execMoveSelectionBackwardByWordCommand();
160 //-------------------------------------------------------------------------------------------------------
162 function execExtendSelectionBackwardByWordCommand() {
163 selection.modify("extend", "backward", "word");
165 function extendSelectionBackwardByWordCommand() {
166 if (commandDelay > 0) {
167 window.setTimeout(execExtendSelectionBackwardByWordCommand, commandCount * commandDelay);
171 execExtendSelectionBackwardByWordCommand();
175 //-------------------------------------------------------------------------------------------------------
177 function execMoveSelectionBackwardByLineCommand() {
178 selection.modify("move", "backward", "line");
180 function moveSelectionBackwardByLineCommand() {
181 if (commandDelay > 0) {
182 window.setTimeout(execMoveSelectionBackwardByLineCommand, commandCount * commandDelay);
186 execMoveSelectionBackwardByLineCommand();
190 //-------------------------------------------------------------------------------------------------------
192 function execExtendSelectionBackwardByLineCommand() {
193 selection.modify("extend", "backward", "line");
195 function extendSelectionBackwardByLineCommand() {
196 if (commandDelay > 0) {
197 window.setTimeout(execExtendSelectionBackwardByLineCommand, commandCount * commandDelay);
201 execExtendSelectionBackwardByLineCommand();
205 //-------------------------------------------------------------------------------------------------------
207 function execBoldCommand() {
208 document.execCommand("Bold");
210 function boldCommand() {
211 if (commandDelay > 0) {
212 window.setTimeout(execBoldCommand, commandCount * commandDelay);
220 //-------------------------------------------------------------------------------------------------------
222 function execUnderlineCommand() {
223 document.execCommand("Underline");
225 function underlineCommand() {
226 if (commandDelay > 0) {
227 window.setTimeout(execUnderlineCommand, commandCount * commandDelay);
231 execUnderlineCommand();
235 //-------------------------------------------------------------------------------------------------------
237 function execFontNameCommand() {
238 document.execCommand("FontName", false, "Courier");
240 function fontNameCommand() {
241 if (commandDelay > 0) {
242 window.setTimeout(execFontNameCommand, commandCount * commandDelay);
246 execFontNameCommand();
250 //-------------------------------------------------------------------------------------------------------
252 function execFontSizeCommand(s) {
253 if (arguments.length == 0 || s == undefined || s.length == 0)
255 document.execCommand("FontSize", false, s);
257 function fontSizeCommand(s) {
258 if (commandDelay > 0) {
259 window.setTimeout(execFontSizeCommand, commandCount * commandDelay, s);
263 execFontSizeCommand(s);
267 //-------------------------------------------------------------------------------------------------------
269 function execFontSizeDeltaCommand(s) {
270 if (arguments.length == 0 || s == undefined || s.length == 0)
272 document.execCommand("FontSizeDelta", false, s);
274 function fontSizeDeltaCommand(s) {
275 if (commandDelay > 0) {
276 window.setTimeout(execFontSizeDeltaCommand, commandCount * commandDelay, s);
280 execFontSizeDeltaCommand(s);
284 //-------------------------------------------------------------------------------------------------------
286 function execItalicCommand() {
287 document.execCommand("Italic");
289 function italicCommand() {
290 if (commandDelay > 0) {
291 window.setTimeout(execItalicCommand, commandCount * commandDelay);
300 //-------------------------------------------------------------------------------------------------------
302 function execJustifyCenterCommand() {
303 document.execCommand("JustifyCenter");
305 function justifyCenterCommand() {
306 if (commandDelay > 0) {
307 window.setTimeout(execJustifyCenterCommand, commandCount * commandDelay);
311 execJustifyCenterCommand();
316 //-------------------------------------------------------------------------------------------------------
318 function execJustifyLeftCommand() {
319 document.execCommand("JustifyLeft");
321 function justifyLeftCommand() {
322 if (commandDelay > 0) {
323 window.setTimeout(execJustifyLeftCommand, commandCount * commandDelay);
327 execJustifyLeftCommand();
332 //-------------------------------------------------------------------------------------------------------
334 function execJustifyRightCommand() {
335 document.execCommand("JustifyRight");
337 function justifyRightCommand() {
338 if (commandDelay > 0) {
339 window.setTimeout(execJustifyRightCommand, commandCount * commandDelay);
343 execJustifyRightCommand();
347 //-------------------------------------------------------------------------------------------------------
349 function execInsertLineBreakCommand() {
350 document.execCommand("InsertLineBreak");
352 function insertLineBreakCommand() {
353 if (commandDelay > 0) {
354 window.setTimeout(execInsertLineBreakCommand, commandCount * commandDelay);
358 execInsertLineBreakCommand();
362 //-------------------------------------------------------------------------------------------------------
364 function execInsertParagraphCommand() {
365 document.execCommand("InsertParagraph");
367 function insertParagraphCommand() {
368 if (commandDelay > 0) {
369 window.setTimeout(execInsertParagraphCommand, commandCount * commandDelay);
373 execInsertParagraphCommand();
377 //-------------------------------------------------------------------------------------------------------
379 function execInsertNewlineInQuotedContentCommand() {
380 document.execCommand("InsertNewlineInQuotedContent");
382 function insertNewlineInQuotedContentCommand() {
383 if (commandDelay > 0) {
384 window.setTimeout(execInsertNewlineInQuotedContentCommand, commandCount * commandDelay);
388 execInsertNewlineInQuotedContentCommand();
392 //-------------------------------------------------------------------------------------------------------
394 function execTypeCharacterCommand(c) {
395 if (arguments.length == 0 || c == undefined || c.length == 0 || c.length > 1)
397 document.execCommand("InsertText", false, c);
399 function typeCharacterCommand(c) {
400 if (commandDelay > 0) {
401 window.setTimeout(execTypeCharacterCommand, commandCount * commandDelay, c);
405 execTypeCharacterCommand(c);
409 //-------------------------------------------------------------------------------------------------------
411 function execSelectAllCommand() {
412 document.execCommand("SelectAll");
414 function selectAllCommand() {
415 if (commandDelay > 0) {
416 window.setTimeout(execSelectAllCommand, commandCount * commandDelay);
420 execSelectAllCommand();
424 //-------------------------------------------------------------------------------------------------------
426 function execStrikethroughCommand() {
427 document.execCommand("Strikethrough");
429 function strikethroughCommand() {
430 if (commandDelay > 0) {
431 window.setTimeout(execStrikethroughCommand, commandCount * commandDelay);
435 execStrikethroughCommand();
439 //-------------------------------------------------------------------------------------------------------
441 function execUndoCommand() {
442 document.execCommand("Undo");
444 function undoCommand() {
445 if (commandDelay > 0) {
446 window.setTimeout(execUndoCommand, commandCount * commandDelay);
454 //-------------------------------------------------------------------------------------------------------
456 function execRedoCommand() {
457 document.execCommand("Redo");
459 function redoCommand() {
460 if (commandDelay > 0) {
461 window.setTimeout(execRedoCommand, commandCount * commandDelay);
469 //-------------------------------------------------------------------------------------------------------
471 function execChangeRootSize() {
472 document.getElementById("root").style.width = "600px";
474 function changeRootSize() {
475 if (commandDelay > 0) {
476 window.setTimeout(execChangeRootSize, commandCount * commandDelay);
480 execChangeRootSize();
484 //-------------------------------------------------------------------------------------------------------
486 function execCutCommand() {
487 document.execCommand("Cut");
489 function cutCommand() {
490 if (commandDelay > 0) {
491 window.setTimeout(execCutCommand, commandCount * commandDelay);
499 //-------------------------------------------------------------------------------------------------------
501 function execCopyCommand() {
502 document.execCommand("Copy");
504 function copyCommand() {
505 if (commandDelay > 0) {
506 window.setTimeout(execCopyCommand, commandCount * commandDelay);
514 //-------------------------------------------------------------------------------------------------------
516 function execPasteCommand() {
517 document.execCommand("Paste");
519 function pasteCommand() {
520 if (commandDelay > 0) {
521 window.setTimeout(execPasteCommand, commandCount * commandDelay);
529 //-------------------------------------------------------------------------------------------------------
531 function execPasteAndMatchStyleCommand() {
532 document.execCommand("PasteAndMatchStyle");
534 function pasteAndMatchStyleCommand() {
535 if (commandDelay > 0) {
536 window.setTimeout(execPasteAndMatchStyleCommand, commandCount * commandDelay);
540 execPasteAndMatchStyleCommand();
544 //-------------------------------------------------------------------------------------------------------
546 function execDeleteCommand() {
547 document.execCommand("Delete");
549 function deleteCommand() {
550 if (commandDelay > 0) {
551 window.setTimeout(execDeleteCommand, commandCount * commandDelay);
559 //-------------------------------------------------------------------------------------------------------
561 function execForwardDeleteCommand() {
562 document.execCommand("ForwardDelete");
564 function forwardDeleteCommand() {
565 if (commandDelay > 0) {
566 window.setTimeout(execForwardDeleteCommand, commandCount * commandDelay);
570 execForwardDeleteCommand();
574 //-------------------------------------------------------------------------------------------------------
576 function runEditingTest() {
577 var elem = document.getElementById("test");
578 var selection = window.getSelection();
579 selection.setPosition(elem, 0);
583 //-------------------------------------------------------------------------------------------------------
586 function execBackColorCommand() {
587 document.execCommand("BackColor", false, "Chartreuse");
589 function backColorCommand() {
590 if (commandDelay > 0) {
591 window.setTimeout(execBackColorCommand, commandCount * commandDelay);
595 execBackColorCommand();
599 //-------------------------------------------------------------------------------------------------------
602 function runCommand(command, arg1, arg2) {
603 document.execCommand(command,arg1,arg2);
606 function executeCommand(command,arg1,arg2) {
607 if (commandDelay > 0) {
608 window.setTimeout(runCommand, commandCount * commandDelay);
612 runCommand(command,arg1,arg2);