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 execInsertNewlineCommand() {
273 document.execCommand("InsertNewline");
275 function insertNewlineCommand() {
276 if (commandDelay > 0) {
277 window.setTimeout(execInsertNewlineCommand, commandCount * commandDelay);
281 execInsertNewlineCommand();
285 //-------------------------------------------------------------------------------------------------------
287 function execTypeCharacterCommand(c) {
288 if (arguments.length == 0 || c == undefined || c.length == 0 || c.length > 1)
290 document.execCommand("InsertText", false, c);
292 function typeCharacterCommand(c) {
293 if (commandDelay > 0) {
294 window.setTimeout(execTypeCharacterCommand, commandCount * commandDelay, c);
298 execTypeCharacterCommand(c);
302 //-------------------------------------------------------------------------------------------------------
304 function execSelectAllCommand() {
305 document.execCommand("SelectAll");
307 function selectAllCommand() {
308 if (commandDelay > 0) {
309 window.setTimeout(execSelectAllCommand, commandCount * commandDelay);
313 execSelectAllCommand();
317 //-------------------------------------------------------------------------------------------------------
319 function execUndoCommand() {
320 document.execCommand("Undo");
322 function undoCommand() {
323 if (commandDelay > 0) {
324 window.setTimeout(execUndoCommand, commandCount * commandDelay);
332 //-------------------------------------------------------------------------------------------------------
334 function execRedoCommand() {
335 document.execCommand("Redo");
337 function redoCommand() {
338 if (commandDelay > 0) {
339 window.setTimeout(execRedoCommand, commandCount * commandDelay);
347 //-------------------------------------------------------------------------------------------------------
349 function execChangeRootSize() {
350 document.getElementById("root").style.width = "600px";
352 function changeRootSize() {
353 if (commandDelay > 0) {
354 window.setTimeout(execChangeRootSize, commandCount * commandDelay);
358 execChangeRootSize();
362 //-------------------------------------------------------------------------------------------------------
364 function execCutCommand() {
365 document.execCommand("Cut");
367 function cutCommand() {
368 if (commandDelay > 0) {
369 window.setTimeout(execCutCommand, commandCount * commandDelay);
377 //-------------------------------------------------------------------------------------------------------
379 function execCopyCommand() {
380 document.execCommand("Copy");
382 function copyCommand() {
383 if (commandDelay > 0) {
384 window.setTimeout(execCopyCommand, commandCount * commandDelay);
392 //-------------------------------------------------------------------------------------------------------
394 function execPasteCommand() {
395 document.execCommand("Paste");
397 function pasteCommand() {
398 if (commandDelay > 0) {
399 window.setTimeout(execPasteCommand, commandCount * commandDelay);
407 //-------------------------------------------------------------------------------------------------------
409 function execDeleteCommand() {
410 document.execCommand("Delete");
412 function deleteCommand() {
413 if (commandDelay > 0) {
414 window.setTimeout(execDeleteCommand, commandCount * commandDelay);
422 //-------------------------------------------------------------------------------------------------------
424 function runEditingTest() {
425 var elem = document.getElementById("test");
426 var selection = window.getSelection();
427 selection.setPosition(elem, 0);
431 //-------------------------------------------------------------------------------------------------------
434 function execBackColorCommand() {
435 document.execCommand("BackColor", false, "Chartreuse");
437 function backColorCommand() {
438 if (commandDelay > 0) {
439 window.setTimeout(execBackColorCommand, commandCount * commandDelay);
443 execBackColorCommand();
448 //-------------------------------------------------------------------------------------------------------
451 function execFontNameCommand() {
452 document.execCommand("FontName", false, "Courier");
454 function fontNameCommand() {
455 if (commandDelay > 0) {
456 window.setTimeout(execFontNameCommand, commandCount * commandDelay);
460 execFontNameCommand();
464 //-------------------------------------------------------------------------------------------------------
467 function runCommand(command, arg1, arg2) {
468 document.execCommand(command,arg1,arg2);
471 function executeCommand(command,arg1,arg2) {
472 if (commandDelay > 0) {
473 window.setTimeout(runCommand, commandCount * commandDelay);
477 runCommand(command,arg1,arg2);