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 execExtendSelectionForwardByLineCommand() {
43 selection.modify("extend", "forward", "line");
45 function extendSelectionForwardByCharacterCommand() {
46 if (commandDelay > 0) {
47 window.setTimeout(execExtendSelectionForwardByCharacterCommand, commandCount * commandDelay);
51 execExtendSelectionForwardByCharacterCommand();
54 //-------------------------------------------------------------------------------------------------------
56 function execMoveSelectionBackwardByCharacterCommand() {
57 selection.modify("move", "backward", "character");
59 function moveSelectionBackwardByCharacterCommand() {
60 if (commandDelay > 0) {
61 window.setTimeout(execMoveSelectionBackwardByCharacterCommand, commandCount * commandDelay);
65 execMoveSelectionBackwardByCharacterCommand();
69 //-------------------------------------------------------------------------------------------------------
71 function execExtendSelectionBackwardByCharacterCommand() {
72 selection.modify("extend", "backward", "character");
74 function extendSelectionBackwardByCharacterCommand() {
75 if (commandDelay > 0) {
76 window.setTimeout(execExtendSelectionBackwardByCharacterCommand, commandCount * commandDelay);
80 execExtendSelectionBackwardByCharacterCommand();
84 //-------------------------------------------------------------------------------------------------------
86 function execBoldCommand() {
87 document.execCommand("Bold");
89 function boldCommand() {
90 if (commandDelay > 0) {
91 window.setTimeout(execBoldCommand, commandCount * commandDelay);
100 //-------------------------------------------------------------------------------------------------------
102 function execItalicCommand() {
103 document.execCommand("Italic");
105 function italicCommand() {
106 if (commandDelay > 0) {
107 window.setTimeout(execItalicCommand, commandCount * commandDelay);
116 //-------------------------------------------------------------------------------------------------------
118 function execInsertNewlineCommand() {
119 document.execCommand("InsertNewline");
121 function insertNewlineCommand() {
122 if (commandDelay > 0) {
123 window.setTimeout(execInsertNewlineCommand, commandCount * commandDelay);
127 execInsertNewlineCommand();
131 //-------------------------------------------------------------------------------------------------------
133 function execTypeCharacterCommand(c) {
134 if (arguments.length == 0 || c == undefined || c.length == 0 || c.length > 1)
136 document.execCommand("InsertText", false, c);
138 function typeCharacterCommand(c) {
139 if (commandDelay > 0) {
140 window.setTimeout(execTypeCharacterCommand, commandCount * commandDelay);
144 execTypeCharacterCommand(c);
148 //-------------------------------------------------------------------------------------------------------
150 function execSelectAllCommand() {
151 document.execCommand("SelectAll");
153 function selectAllCommand() {
154 if (commandDelay > 0) {
155 window.setTimeout(execSelectAllCommand, commandCount * commandDelay);
159 execSelectAllCommand();
163 //-------------------------------------------------------------------------------------------------------
165 function execUndoCommand() {
166 document.execCommand("Undo");
168 function undoCommand() {
169 if (commandDelay > 0) {
170 window.setTimeout(execUndoCommand, commandCount * commandDelay);
178 //-------------------------------------------------------------------------------------------------------
180 function execRedoCommand() {
181 document.execCommand("Redo");
183 function redoCommand() {
184 if (commandDelay > 0) {
185 window.setTimeout(execRedoCommand, commandCount * commandDelay);
193 //-------------------------------------------------------------------------------------------------------
195 function execChangeRootSize() {
196 document.getElementById("root").style.width = "600px";
198 function changeRootSize() {
199 if (commandDelay > 0) {
200 window.setTimeout(execChangeRootSize, commandCount * commandDelay);
204 execChangeRootSize();
208 //-------------------------------------------------------------------------------------------------------
210 function execCutCommand() {
211 document.execCommand("Cut");
213 function cutCommand() {
214 if (commandDelay > 0) {
215 window.setTimeout(execCutCommand, commandCount * commandDelay);
223 //-------------------------------------------------------------------------------------------------------
225 function execCopyCommand() {
226 document.execCommand("Copy");
228 function copyCommand() {
229 if (commandDelay > 0) {
230 window.setTimeout(execCopyCommand, commandCount * commandDelay);
238 //-------------------------------------------------------------------------------------------------------
240 function execPasteCommand() {
241 document.execCommand("Paste");
243 function pasteCommand() {
244 if (commandDelay > 0) {
245 window.setTimeout(execPasteCommand, commandCount * commandDelay);
253 //-------------------------------------------------------------------------------------------------------
255 function execDeleteCommand() {
256 document.execCommand("Delete");
258 function deleteCommand() {
259 if (commandDelay > 0) {
260 window.setTimeout(execDeleteCommand, commandCount * commandDelay);
268 //-------------------------------------------------------------------------------------------------------
270 function runEditingTest() {
271 var elem = document.getElementById("test");
272 var selection = window.getSelection();
273 selection.setPosition(elem, 0);
277 //-------------------------------------------------------------------------------------------------------
280 function execBackColorCommand() {
281 document.execCommand("BackColor", false, "Chartreuse");
283 function backColorCommand() {
284 if (commandDelay > 0) {
285 window.setTimeout(execBackColorCommand, commandCount * commandDelay);
289 execBackColorCommand();
294 //-------------------------------------------------------------------------------------------------------
297 function execFontNameCommand() {
298 document.execCommand("FontName", false, "Courier");
300 function fontNameCommand() {
301 if (commandDelay > 0) {
302 window.setTimeout(execFontNameCommand, commandCount * commandDelay);
306 execFontNameCommand();
310 //-------------------------------------------------------------------------------------------------------
313 function runCommand(command, arg1, arg2) {
314 document.execCommand(command,arg1,arg2);
317 function executeCommand(command,arg1,arg2) {
318 if (commandDelay > 0) {
319 window.setTimeout(runCommand, commandCount * commandDelay);
323 runCommand(command,arg1,arg2);