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);
206 //-------------------------------------------------------------------------------------------------------
208 function execItalicCommand() {
209 document.execCommand("Italic");
211 function italicCommand() {
212 if (commandDelay > 0) {
213 window.setTimeout(execItalicCommand, commandCount * commandDelay);
222 //-------------------------------------------------------------------------------------------------------
224 function execJustifyCenterCommand() {
225 document.execCommand("JustifyCenter");
227 function justifyCenterCommand() {
228 if (commandDelay > 0) {
229 window.setTimeout(execJustifyCenterCommand, commandCount * commandDelay);
233 execJustifyCenterCommand();
238 //-------------------------------------------------------------------------------------------------------
240 function execJustifyLeftCommand() {
241 document.execCommand("JustifyLeft");
243 function justifyLeftCommand() {
244 if (commandDelay > 0) {
245 window.setTimeout(execJustifyLeftCommand, commandCount * commandDelay);
249 execJustifyLeftCommand();
254 //-------------------------------------------------------------------------------------------------------
256 function execJustifyRightCommand() {
257 document.execCommand("JustifyRight");
259 function justifyRightCommand() {
260 if (commandDelay > 0) {
261 window.setTimeout(execJustifyRightCommand, commandCount * commandDelay);
265 execJustifyRightCommand();
270 //-------------------------------------------------------------------------------------------------------
272 function execInsertLineBreakCommand() {
273 document.execCommand("InsertLineBreak");
275 function insertLineBreakCommand() {
276 if (commandDelay > 0) {
277 window.setTimeout(execInsertLineBreakCommand, commandCount * commandDelay);
281 execInsertLineBreakCommand();
285 //-------------------------------------------------------------------------------------------------------
287 function execInsertParagraphCommand() {
288 document.execCommand("InsertParagraph");
290 function insertParagraphCommand() {
291 if (commandDelay > 0) {
292 window.setTimeout(execInsertParagraphCommand, commandCount * commandDelay);
296 execInsertParagraphCommand();
300 //-------------------------------------------------------------------------------------------------------
302 function execTypeCharacterCommand(c) {
303 if (arguments.length == 0 || c == undefined || c.length == 0 || c.length > 1)
305 document.execCommand("InsertText", false, c);
307 function typeCharacterCommand(c) {
308 if (commandDelay > 0) {
309 window.setTimeout(execTypeCharacterCommand, commandCount * commandDelay, c);
313 execTypeCharacterCommand(c);
317 //-------------------------------------------------------------------------------------------------------
319 function execSelectAllCommand() {
320 document.execCommand("SelectAll");
322 function selectAllCommand() {
323 if (commandDelay > 0) {
324 window.setTimeout(execSelectAllCommand, commandCount * commandDelay);
328 execSelectAllCommand();
332 //-------------------------------------------------------------------------------------------------------
334 function execUndoCommand() {
335 document.execCommand("Undo");
337 function undoCommand() {
338 if (commandDelay > 0) {
339 window.setTimeout(execUndoCommand, commandCount * commandDelay);
347 //-------------------------------------------------------------------------------------------------------
349 function execRedoCommand() {
350 document.execCommand("Redo");
352 function redoCommand() {
353 if (commandDelay > 0) {
354 window.setTimeout(execRedoCommand, commandCount * commandDelay);
362 //-------------------------------------------------------------------------------------------------------
364 function execChangeRootSize() {
365 document.getElementById("root").style.width = "600px";
367 function changeRootSize() {
368 if (commandDelay > 0) {
369 window.setTimeout(execChangeRootSize, commandCount * commandDelay);
373 execChangeRootSize();
377 //-------------------------------------------------------------------------------------------------------
379 function execCutCommand() {
380 document.execCommand("Cut");
382 function cutCommand() {
383 if (commandDelay > 0) {
384 window.setTimeout(execCutCommand, commandCount * commandDelay);
392 //-------------------------------------------------------------------------------------------------------
394 function execCopyCommand() {
395 document.execCommand("Copy");
397 function copyCommand() {
398 if (commandDelay > 0) {
399 window.setTimeout(execCopyCommand, commandCount * commandDelay);
407 //-------------------------------------------------------------------------------------------------------
409 function execPasteCommand() {
410 document.execCommand("Paste");
412 function pasteCommand() {
413 if (commandDelay > 0) {
414 window.setTimeout(execPasteCommand, commandCount * commandDelay);
422 //-------------------------------------------------------------------------------------------------------
424 function execDeleteCommand() {
425 document.execCommand("Delete");
427 function deleteCommand() {
428 if (commandDelay > 0) {
429 window.setTimeout(execDeleteCommand, commandCount * commandDelay);
437 //-------------------------------------------------------------------------------------------------------
439 function runEditingTest() {
440 var elem = document.getElementById("test");
441 var selection = window.getSelection();
442 selection.setPosition(elem, 0);
446 //-------------------------------------------------------------------------------------------------------
449 function execBackColorCommand() {
450 document.execCommand("BackColor", false, "Chartreuse");
452 function backColorCommand() {
453 if (commandDelay > 0) {
454 window.setTimeout(execBackColorCommand, commandCount * commandDelay);
458 execBackColorCommand();
463 //-------------------------------------------------------------------------------------------------------
466 function execFontNameCommand() {
467 document.execCommand("FontName", false, "Courier");
469 function fontNameCommand() {
470 if (commandDelay > 0) {
471 window.setTimeout(execFontNameCommand, commandCount * commandDelay);
475 execFontNameCommand();
479 //-------------------------------------------------------------------------------------------------------
482 function runCommand(command, arg1, arg2) {
483 document.execCommand(command,arg1,arg2);
486 function executeCommand(command,arg1,arg2) {
487 if (commandDelay > 0) {
488 window.setTimeout(runCommand, commandCount * commandDelay);
492 runCommand(command,arg1,arg2);