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 execFontNameCommand() {
208 document.execCommand("FontName", false, "Courier");
210 function fontNameCommand() {
211 if (commandDelay > 0) {
212 window.setTimeout(execFontNameCommand, commandCount * commandDelay);
216 execFontNameCommand();
220 //-------------------------------------------------------------------------------------------------------
222 function execFontSizeCommand(s) {
223 if (arguments.length == 0 || s == undefined || s.length == 0)
225 document.execCommand("FontSize", false, s);
227 function fontSizeCommand(s) {
228 if (commandDelay > 0) {
229 window.setTimeout(execFontSizeCommand, commandCount * commandDelay, s);
233 execFontSizeCommand(s);
237 //-------------------------------------------------------------------------------------------------------
239 function execFontSizeDeltaCommand(s) {
240 if (arguments.length == 0 || s == undefined || s.length == 0)
242 document.execCommand("FontSizeDelta", false, s);
244 function fontSizeDeltaCommand(s) {
245 if (commandDelay > 0) {
246 window.setTimeout(execFontSizeDeltaCommand, commandCount * commandDelay, s);
250 execFontSizeDeltaCommand(s);
254 //-------------------------------------------------------------------------------------------------------
256 function execItalicCommand() {
257 document.execCommand("Italic");
259 function italicCommand() {
260 if (commandDelay > 0) {
261 window.setTimeout(execItalicCommand, commandCount * commandDelay);
270 //-------------------------------------------------------------------------------------------------------
272 function execJustifyCenterCommand() {
273 document.execCommand("JustifyCenter");
275 function justifyCenterCommand() {
276 if (commandDelay > 0) {
277 window.setTimeout(execJustifyCenterCommand, commandCount * commandDelay);
281 execJustifyCenterCommand();
286 //-------------------------------------------------------------------------------------------------------
288 function execJustifyLeftCommand() {
289 document.execCommand("JustifyLeft");
291 function justifyLeftCommand() {
292 if (commandDelay > 0) {
293 window.setTimeout(execJustifyLeftCommand, commandCount * commandDelay);
297 execJustifyLeftCommand();
302 //-------------------------------------------------------------------------------------------------------
304 function execJustifyRightCommand() {
305 document.execCommand("JustifyRight");
307 function justifyRightCommand() {
308 if (commandDelay > 0) {
309 window.setTimeout(execJustifyRightCommand, commandCount * commandDelay);
313 execJustifyRightCommand();
318 //-------------------------------------------------------------------------------------------------------
320 function execInsertLineBreakCommand() {
321 document.execCommand("InsertLineBreak");
323 function insertLineBreakCommand() {
324 if (commandDelay > 0) {
325 window.setTimeout(execInsertLineBreakCommand, commandCount * commandDelay);
329 execInsertLineBreakCommand();
333 //-------------------------------------------------------------------------------------------------------
335 function execInsertParagraphCommand() {
336 document.execCommand("InsertParagraph");
338 function insertParagraphCommand() {
339 if (commandDelay > 0) {
340 window.setTimeout(execInsertParagraphCommand, commandCount * commandDelay);
344 execInsertParagraphCommand();
348 //-------------------------------------------------------------------------------------------------------
350 function execTypeCharacterCommand(c) {
351 if (arguments.length == 0 || c == undefined || c.length == 0 || c.length > 1)
353 document.execCommand("InsertText", false, c);
355 function typeCharacterCommand(c) {
356 if (commandDelay > 0) {
357 window.setTimeout(execTypeCharacterCommand, commandCount * commandDelay, c);
361 execTypeCharacterCommand(c);
365 //-------------------------------------------------------------------------------------------------------
367 function execSelectAllCommand() {
368 document.execCommand("SelectAll");
370 function selectAllCommand() {
371 if (commandDelay > 0) {
372 window.setTimeout(execSelectAllCommand, commandCount * commandDelay);
376 execSelectAllCommand();
380 //-------------------------------------------------------------------------------------------------------
382 function execUndoCommand() {
383 document.execCommand("Undo");
385 function undoCommand() {
386 if (commandDelay > 0) {
387 window.setTimeout(execUndoCommand, commandCount * commandDelay);
395 //-------------------------------------------------------------------------------------------------------
397 function execRedoCommand() {
398 document.execCommand("Redo");
400 function redoCommand() {
401 if (commandDelay > 0) {
402 window.setTimeout(execRedoCommand, commandCount * commandDelay);
410 //-------------------------------------------------------------------------------------------------------
412 function execChangeRootSize() {
413 document.getElementById("root").style.width = "600px";
415 function changeRootSize() {
416 if (commandDelay > 0) {
417 window.setTimeout(execChangeRootSize, commandCount * commandDelay);
421 execChangeRootSize();
425 //-------------------------------------------------------------------------------------------------------
427 function execCutCommand() {
428 document.execCommand("Cut");
430 function cutCommand() {
431 if (commandDelay > 0) {
432 window.setTimeout(execCutCommand, commandCount * commandDelay);
440 //-------------------------------------------------------------------------------------------------------
442 function execCopyCommand() {
443 document.execCommand("Copy");
445 function copyCommand() {
446 if (commandDelay > 0) {
447 window.setTimeout(execCopyCommand, commandCount * commandDelay);
455 //-------------------------------------------------------------------------------------------------------
457 function execPasteCommand() {
458 document.execCommand("Paste");
460 function pasteCommand() {
461 if (commandDelay > 0) {
462 window.setTimeout(execPasteCommand, commandCount * commandDelay);
470 //-------------------------------------------------------------------------------------------------------
472 function execDeleteCommand() {
473 document.execCommand("Delete");
475 function deleteCommand() {
476 if (commandDelay > 0) {
477 window.setTimeout(execDeleteCommand, commandCount * commandDelay);
485 //-------------------------------------------------------------------------------------------------------
487 function runEditingTest() {
488 var elem = document.getElementById("test");
489 var selection = window.getSelection();
490 selection.setPosition(elem, 0);
494 //-------------------------------------------------------------------------------------------------------
497 function execBackColorCommand() {
498 document.execCommand("BackColor", false, "Chartreuse");
500 function backColorCommand() {
501 if (commandDelay > 0) {
502 window.setTimeout(execBackColorCommand, commandCount * commandDelay);
506 execBackColorCommand();
510 //-------------------------------------------------------------------------------------------------------
513 function runCommand(command, arg1, arg2) {
514 document.execCommand(command,arg1,arg2);
517 function executeCommand(command,arg1,arg2) {
518 if (commandDelay > 0) {
519 window.setTimeout(runCommand, commandCount * commandDelay);
523 runCommand(command,arg1,arg2);