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 execMoveSelectionForwardByCharacterCommand() {
13 selection.modify("move", "forward", "character");
15 function moveSelectionForwardByCharacterCommand() {
16 if (commandDelay > 0) {
17 window.setTimeout(execMoveSelectionForwardByCharacterCommand, commandCount * commandDelay);
21 execMoveSelectionForwardByCharacterCommand();
25 //-------------------------------------------------------------------------------------------------------
27 function execExtendSelectionForwardByCharacterCommand() {
28 selection.modify("extend", "forward", "character");
30 function extendSelectionForwardByCharacterCommand() {
31 if (commandDelay > 0) {
32 window.setTimeout(execExtendSelectionForwardByCharacterCommand, commandCount * commandDelay);
36 execExtendSelectionForwardByCharacterCommand();
40 //-------------------------------------------------------------------------------------------------------
42 function execMoveSelectionForwardByWordCommand() {
43 selection.modify("move", "forward", "word");
45 function moveSelectionForwardByWordCommand() {
46 if (commandDelay > 0) {
47 window.setTimeout(execMoveSelectionForwardByWordCommand, commandCount * commandDelay);
51 execMoveSelectionForwardByWordCommand();
55 //-------------------------------------------------------------------------------------------------------
57 function execExtendSelectionForwardByWordCommand() {
58 selection.modify("extend", "forward", "word");
60 function extendSelectionForwardByWordCommand() {
61 if (commandDelay > 0) {
62 window.setTimeout(execExtendSelectionForwardByWordCommand, commandCount * commandDelay);
66 execExtendSelectionForwardByWordCommand();
70 //-------------------------------------------------------------------------------------------------------
72 function execMoveSelectionForwardByLineCommand() {
73 selection.modify("move", "forward", "line");
75 function moveSelectionForwardByLineCommand() {
76 if (commandDelay > 0) {
77 window.setTimeout(execMoveSelectionForwardByLineCommand, commandCount * commandDelay);
81 execMoveSelectionForwardByLineCommand();
85 //-------------------------------------------------------------------------------------------------------
87 function execExtendSelectionForwardByLineCommand() {
88 selection.modify("extend", "forward", "line");
90 function extendSelectionForwardByLineCommand() {
91 if (commandDelay > 0) {
92 window.setTimeout(execExtendSelectionForwardByLineCommand, commandCount * commandDelay);
96 execExtendSelectionForwardByLineCommand();
100 //-------------------------------------------------------------------------------------------------------
102 function execMoveSelectionBackwardByCharacterCommand() {
103 selection.modify("move", "backward", "character");
105 function moveSelectionBackwardByCharacterCommand() {
106 if (commandDelay > 0) {
107 window.setTimeout(execMoveSelectionBackwardByCharacterCommand, commandCount * commandDelay);
111 execMoveSelectionBackwardByCharacterCommand();
115 //-------------------------------------------------------------------------------------------------------
117 function execExtendSelectionBackwardByCharacterCommand() {
118 selection.modify("extend", "backward", "character");
120 function extendSelectionBackwardByCharacterCommand() {
121 if (commandDelay > 0) {
122 window.setTimeout(execExtendSelectionBackwardByCharacterCommand, commandCount * commandDelay);
126 execExtendSelectionBackwardByCharacterCommand();
130 //-------------------------------------------------------------------------------------------------------
132 function execMoveSelectionBackwardByWordCommand() {
133 selection.modify("move", "backward", "word");
135 function moveSelectionBackwardByWordCommand() {
136 if (commandDelay > 0) {
137 window.setTimeout(execMoveSelectionBackwardByWordCommand, commandCount * commandDelay);
141 execMoveSelectionBackwardByWordCommand();
145 //-------------------------------------------------------------------------------------------------------
147 function execExtendSelectionBackwardByWordCommand() {
148 selection.modify("extend", "backward", "word");
150 function extendSelectionBackwardByWordCommand() {
151 if (commandDelay > 0) {
152 window.setTimeout(execExtendSelectionBackwardByWordCommand, commandCount * commandDelay);
156 execExtendSelectionBackwardByWordCommand();
160 //-------------------------------------------------------------------------------------------------------
162 function execMoveSelectionBackwardByLineCommand() {
163 selection.modify("move", "backward", "line");
165 function moveSelectionBackwardByLineCommand() {
166 if (commandDelay > 0) {
167 window.setTimeout(execMoveSelectionBackwardByLineCommand, commandCount * commandDelay);
171 execMoveSelectionBackwardByLineCommand();
175 //-------------------------------------------------------------------------------------------------------
177 function execExtendSelectionBackwardByLineCommand() {
178 selection.modify("extend", "backward", "line");
180 function extendSelectionBackwardByLineCommand() {
181 if (commandDelay > 0) {
182 window.setTimeout(execExtendSelectionBackwardByLineCommand, commandCount * commandDelay);
186 execExtendSelectionBackwardByLineCommand();
190 //-------------------------------------------------------------------------------------------------------
192 function execBoldCommand() {
193 document.execCommand("Bold");
195 function boldCommand() {
196 if (commandDelay > 0) {
197 window.setTimeout(execBoldCommand, commandCount * commandDelay);
205 //-------------------------------------------------------------------------------------------------------
207 function execUnderlineCommand() {
208 document.execCommand("Underline");
210 function underlineCommand() {
211 if (commandDelay > 0) {
212 window.setTimeout(execUnderlineCommand, commandCount * commandDelay);
216 execUnderlineCommand();
220 //-------------------------------------------------------------------------------------------------------
222 function execFontNameCommand() {
223 document.execCommand("FontName", false, "Courier");
225 function fontNameCommand() {
226 if (commandDelay > 0) {
227 window.setTimeout(execFontNameCommand, commandCount * commandDelay);
231 execFontNameCommand();
235 //-------------------------------------------------------------------------------------------------------
237 function execFontSizeCommand(s) {
238 if (arguments.length == 0 || s == undefined || s.length == 0)
240 document.execCommand("FontSize", false, s);
242 function fontSizeCommand(s) {
243 if (commandDelay > 0) {
244 window.setTimeout(execFontSizeCommand, commandCount * commandDelay, s);
248 execFontSizeCommand(s);
252 //-------------------------------------------------------------------------------------------------------
254 function execFontSizeDeltaCommand(s) {
255 if (arguments.length == 0 || s == undefined || s.length == 0)
257 document.execCommand("FontSizeDelta", false, s);
259 function fontSizeDeltaCommand(s) {
260 if (commandDelay > 0) {
261 window.setTimeout(execFontSizeDeltaCommand, commandCount * commandDelay, s);
265 execFontSizeDeltaCommand(s);
269 //-------------------------------------------------------------------------------------------------------
271 function execItalicCommand() {
272 document.execCommand("Italic");
274 function italicCommand() {
275 if (commandDelay > 0) {
276 window.setTimeout(execItalicCommand, commandCount * commandDelay);
285 //-------------------------------------------------------------------------------------------------------
287 function execJustifyCenterCommand() {
288 document.execCommand("JustifyCenter");
290 function justifyCenterCommand() {
291 if (commandDelay > 0) {
292 window.setTimeout(execJustifyCenterCommand, commandCount * commandDelay);
296 execJustifyCenterCommand();
301 //-------------------------------------------------------------------------------------------------------
303 function execJustifyLeftCommand() {
304 document.execCommand("JustifyLeft");
306 function justifyLeftCommand() {
307 if (commandDelay > 0) {
308 window.setTimeout(execJustifyLeftCommand, commandCount * commandDelay);
312 execJustifyLeftCommand();
317 //-------------------------------------------------------------------------------------------------------
319 function execJustifyRightCommand() {
320 document.execCommand("JustifyRight");
322 function justifyRightCommand() {
323 if (commandDelay > 0) {
324 window.setTimeout(execJustifyRightCommand, commandCount * commandDelay);
328 execJustifyRightCommand();
333 //-------------------------------------------------------------------------------------------------------
335 function execInsertLineBreakCommand() {
336 document.execCommand("InsertLineBreak");
338 function insertLineBreakCommand() {
339 if (commandDelay > 0) {
340 window.setTimeout(execInsertLineBreakCommand, commandCount * commandDelay);
344 execInsertLineBreakCommand();
348 //-------------------------------------------------------------------------------------------------------
350 function execInsertParagraphCommand() {
351 document.execCommand("InsertParagraph");
353 function insertParagraphCommand() {
354 if (commandDelay > 0) {
355 window.setTimeout(execInsertParagraphCommand, commandCount * commandDelay);
359 execInsertParagraphCommand();
363 //-------------------------------------------------------------------------------------------------------
365 function execTypeCharacterCommand(c) {
366 if (arguments.length == 0 || c == undefined || c.length == 0 || c.length > 1)
368 document.execCommand("InsertText", false, c);
370 function typeCharacterCommand(c) {
371 if (commandDelay > 0) {
372 window.setTimeout(execTypeCharacterCommand, commandCount * commandDelay, c);
376 execTypeCharacterCommand(c);
380 //-------------------------------------------------------------------------------------------------------
382 function execSelectAllCommand() {
383 document.execCommand("SelectAll");
385 function selectAllCommand() {
386 if (commandDelay > 0) {
387 window.setTimeout(execSelectAllCommand, commandCount * commandDelay);
391 execSelectAllCommand();
395 //-------------------------------------------------------------------------------------------------------
397 function execUndoCommand() {
398 document.execCommand("Undo");
400 function undoCommand() {
401 if (commandDelay > 0) {
402 window.setTimeout(execUndoCommand, commandCount * commandDelay);
410 //-------------------------------------------------------------------------------------------------------
412 function execRedoCommand() {
413 document.execCommand("Redo");
415 function redoCommand() {
416 if (commandDelay > 0) {
417 window.setTimeout(execRedoCommand, commandCount * commandDelay);
425 //-------------------------------------------------------------------------------------------------------
427 function execChangeRootSize() {
428 document.getElementById("root").style.width = "600px";
430 function changeRootSize() {
431 if (commandDelay > 0) {
432 window.setTimeout(execChangeRootSize, commandCount * commandDelay);
436 execChangeRootSize();
440 //-------------------------------------------------------------------------------------------------------
442 function execCutCommand() {
443 document.execCommand("Cut");
445 function cutCommand() {
446 if (commandDelay > 0) {
447 window.setTimeout(execCutCommand, commandCount * commandDelay);
455 //-------------------------------------------------------------------------------------------------------
457 function execCopyCommand() {
458 document.execCommand("Copy");
460 function copyCommand() {
461 if (commandDelay > 0) {
462 window.setTimeout(execCopyCommand, commandCount * commandDelay);
470 //-------------------------------------------------------------------------------------------------------
472 function execPasteCommand() {
473 document.execCommand("Paste");
475 function pasteCommand() {
476 if (commandDelay > 0) {
477 window.setTimeout(execPasteCommand, commandCount * commandDelay);
485 //-------------------------------------------------------------------------------------------------------
487 function execPasteAndMatchStyleCommand() {
488 document.execCommand("PasteAndMatchStyle");
490 function pasteAndMatchStyleCommand() {
491 if (commandDelay > 0) {
492 window.setTimeout(execPasteAndMatchStyleCommand, commandCount * commandDelay);
496 execPasteAndMatchStyleCommand();
500 //-------------------------------------------------------------------------------------------------------
502 function execDeleteCommand() {
503 document.execCommand("Delete");
505 function deleteCommand() {
506 if (commandDelay > 0) {
507 window.setTimeout(execDeleteCommand, commandCount * commandDelay);
515 //-------------------------------------------------------------------------------------------------------
517 function execForwardDeleteCommand() {
518 document.execCommand("ForwardDelete");
520 function forwardDeleteCommand() {
521 if (commandDelay > 0) {
522 window.setTimeout(execForwardDeleteCommand, commandCount * commandDelay);
526 execForwardDeleteCommand();
530 //-------------------------------------------------------------------------------------------------------
532 function runEditingTest() {
533 var elem = document.getElementById("test");
534 var selection = window.getSelection();
535 selection.setPosition(elem, 0);
539 //-------------------------------------------------------------------------------------------------------
542 function execBackColorCommand() {
543 document.execCommand("BackColor", false, "Chartreuse");
545 function backColorCommand() {
546 if (commandDelay > 0) {
547 window.setTimeout(execBackColorCommand, commandCount * commandDelay);
551 execBackColorCommand();
555 //-------------------------------------------------------------------------------------------------------
558 function runCommand(command, arg1, arg2) {
559 document.execCommand(command,arg1,arg2);
562 function executeCommand(command,arg1,arg2) {
563 if (commandDelay > 0) {
564 window.setTimeout(runCommand, commandCount * commandDelay);
568 runCommand(command,arg1,arg2);