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() {
134 document.execCommand("InsertText", false, "x");
136 function typeCharacterCommand() {
137 if (commandDelay > 0) {
138 window.setTimeout(execTypeCharacterCommand, commandCount * commandDelay);
142 execTypeCharacterCommand();
146 //-------------------------------------------------------------------------------------------------------
148 function execSelectAllCommand() {
149 document.execCommand("SelectAll");
151 function selectAllCommand() {
152 if (commandDelay > 0) {
153 window.setTimeout(execSelectAllCommand, commandCount * commandDelay);
157 execSelectAllCommand();
161 //-------------------------------------------------------------------------------------------------------
163 function execUndoCommand() {
164 document.execCommand("Undo");
166 function undoCommand() {
167 if (commandDelay > 0) {
168 window.setTimeout(execUndoCommand, commandCount * commandDelay);
176 //-------------------------------------------------------------------------------------------------------
178 function execRedoCommand() {
179 document.execCommand("Redo");
181 function redoCommand() {
182 if (commandDelay > 0) {
183 window.setTimeout(execRedoCommand, commandCount * commandDelay);
191 //-------------------------------------------------------------------------------------------------------
193 function execChangeRootSize() {
194 document.getElementById("root").style.width = "600px";
196 function changeRootSize() {
197 if (commandDelay > 0) {
198 window.setTimeout(execChangeRootSize, commandCount * commandDelay);
202 execChangeRootSize();
206 //-------------------------------------------------------------------------------------------------------
208 function execCutCommand() {
209 document.execCommand("Cut");
211 function cutCommand() {
212 if (commandDelay > 0) {
213 window.setTimeout(execCutCommand, commandCount * commandDelay);
221 //-------------------------------------------------------------------------------------------------------
223 function execCopyCommand() {
224 document.execCommand("Copy");
226 function copyCommand() {
227 if (commandDelay > 0) {
228 window.setTimeout(execCopyCommand, commandCount * commandDelay);
236 //-------------------------------------------------------------------------------------------------------
238 function execPasteCommand() {
239 document.execCommand("Paste");
241 function pasteCommand() {
242 if (commandDelay > 0) {
243 window.setTimeout(execPasteCommand, commandCount * commandDelay);
251 //-------------------------------------------------------------------------------------------------------
253 function execDeleteCommand() {
254 document.execCommand("Delete");
256 function deleteCommand() {
257 if (commandDelay > 0) {
258 window.setTimeout(execDeleteCommand, commandCount * commandDelay);
266 //-------------------------------------------------------------------------------------------------------
268 function runEditingTest() {
269 var elem = document.getElementById("test");
270 var selection = window.getSelection();
271 selection.setPosition(elem, 0);
275 //-------------------------------------------------------------------------------------------------------
278 function execBackColorCommand() {
279 document.execCommand("BackColor", false, "Chartreuse");
281 function backColorCommand() {
282 if (commandDelay > 0) {
283 window.setTimeout(execBackColorCommand, commandCount * commandDelay);
287 execBackColorCommand();
292 //-------------------------------------------------------------------------------------------------------
295 function execFontNameCommand() {
296 document.execCommand("FontName", false, "Courier");
298 function fontNameCommand() {
299 if (commandDelay > 0) {
300 window.setTimeout(execFontNameCommand, commandCount * commandDelay);
304 execFontNameCommand();
308 //-------------------------------------------------------------------------------------------------------
311 function runCommand(command, arg1, arg2) {
312 document.execCommand(command,arg1,arg2);
315 function executeCommand(command,arg1,arg2) {
316 if (commandDelay > 0) {
317 window.setTimeout(runCommand, commandCount * commandDelay);
321 runCommand(command,arg1,arg2);