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 execInsertNewlineCommand() {
225 document.execCommand("InsertNewline");
227 function insertNewlineCommand() {
228 if (commandDelay > 0) {
229 window.setTimeout(execInsertNewlineCommand, commandCount * commandDelay);
233 execInsertNewlineCommand();
237 //-------------------------------------------------------------------------------------------------------
239 function execTypeCharacterCommand(c) {
240 if (arguments.length == 0 || c == undefined || c.length == 0 || c.length > 1)
242 document.execCommand("InsertText", false, c);
244 function typeCharacterCommand(c) {
245 if (commandDelay > 0) {
246 window.setTimeout(execTypeCharacterCommand, commandCount * commandDelay, c);
250 execTypeCharacterCommand(c);
254 //-------------------------------------------------------------------------------------------------------
256 function execSelectAllCommand() {
257 document.execCommand("SelectAll");
259 function selectAllCommand() {
260 if (commandDelay > 0) {
261 window.setTimeout(execSelectAllCommand, commandCount * commandDelay);
265 execSelectAllCommand();
269 //-------------------------------------------------------------------------------------------------------
271 function execUndoCommand() {
272 document.execCommand("Undo");
274 function undoCommand() {
275 if (commandDelay > 0) {
276 window.setTimeout(execUndoCommand, commandCount * commandDelay);
284 //-------------------------------------------------------------------------------------------------------
286 function execRedoCommand() {
287 document.execCommand("Redo");
289 function redoCommand() {
290 if (commandDelay > 0) {
291 window.setTimeout(execRedoCommand, commandCount * commandDelay);
299 //-------------------------------------------------------------------------------------------------------
301 function execChangeRootSize() {
302 document.getElementById("root").style.width = "600px";
304 function changeRootSize() {
305 if (commandDelay > 0) {
306 window.setTimeout(execChangeRootSize, commandCount * commandDelay);
310 execChangeRootSize();
314 //-------------------------------------------------------------------------------------------------------
316 function execCutCommand() {
317 document.execCommand("Cut");
319 function cutCommand() {
320 if (commandDelay > 0) {
321 window.setTimeout(execCutCommand, commandCount * commandDelay);
329 //-------------------------------------------------------------------------------------------------------
331 function execCopyCommand() {
332 document.execCommand("Copy");
334 function copyCommand() {
335 if (commandDelay > 0) {
336 window.setTimeout(execCopyCommand, commandCount * commandDelay);
344 //-------------------------------------------------------------------------------------------------------
346 function execPasteCommand() {
347 document.execCommand("Paste");
349 function pasteCommand() {
350 if (commandDelay > 0) {
351 window.setTimeout(execPasteCommand, commandCount * commandDelay);
359 //-------------------------------------------------------------------------------------------------------
361 function execDeleteCommand() {
362 document.execCommand("Delete");
364 function deleteCommand() {
365 if (commandDelay > 0) {
366 window.setTimeout(execDeleteCommand, commandCount * commandDelay);
374 //-------------------------------------------------------------------------------------------------------
376 function runEditingTest() {
377 var elem = document.getElementById("test");
378 var selection = window.getSelection();
379 selection.setPosition(elem, 0);
383 //-------------------------------------------------------------------------------------------------------
386 function execBackColorCommand() {
387 document.execCommand("BackColor", false, "Chartreuse");
389 function backColorCommand() {
390 if (commandDelay > 0) {
391 window.setTimeout(execBackColorCommand, commandCount * commandDelay);
395 execBackColorCommand();
400 //-------------------------------------------------------------------------------------------------------
403 function execFontNameCommand() {
404 document.execCommand("FontName", false, "Courier");
406 function fontNameCommand() {
407 if (commandDelay > 0) {
408 window.setTimeout(execFontNameCommand, commandCount * commandDelay);
412 execFontNameCommand();
416 //-------------------------------------------------------------------------------------------------------
419 function runCommand(command, arg1, arg2) {
420 document.execCommand(command,arg1,arg2);
423 function executeCommand(command,arg1,arg2) {
424 if (commandDelay > 0) {
425 window.setTimeout(runCommand, commandCount * commandDelay);
429 runCommand(command,arg1,arg2);