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 execMoveSelectionBackwardByCharacterCommand() {
43 selection.modify("move", "backward", "character");
45 function moveSelectionBackwardByCharacterCommand() {
46 if (commandDelay > 0) {
47 window.setTimeout(execMoveSelectionBackwardByCharacterCommand, commandCount * commandDelay);
51 execMoveSelectionBackwardByCharacterCommand();
55 //-------------------------------------------------------------------------------------------------------
57 function execExtendSelectionBackwardByCharacterCommand() {
58 selection.modify("extend", "backward", "character");
60 function extendSelectionBackwardByCharacterCommand() {
61 if (commandDelay > 0) {
62 window.setTimeout(execExtendSelectionBackwardByCharacterCommand, commandCount * commandDelay);
66 execExtendSelectionBackwardByCharacterCommand();
70 //-------------------------------------------------------------------------------------------------------
72 function execBoldCommand() {
73 document.execCommand("Bold");
75 function boldCommand() {
76 if (commandDelay > 0) {
77 window.setTimeout(execBoldCommand, commandCount * commandDelay);
85 //-------------------------------------------------------------------------------------------------------
87 function execInsertNewlineCommand() {
88 document.execCommand("InsertNewline");
90 function insertNewlineCommand() {
91 if (commandDelay > 0) {
92 window.setTimeout(execInsertNewlineCommand, commandCount * commandDelay);
96 execInsertNewlineCommand();
100 //-------------------------------------------------------------------------------------------------------
102 function execTypeCharacterCommand() {
103 document.execCommand("InsertText", false, "x");
105 function typeCharacterCommand() {
106 if (commandDelay > 0) {
107 window.setTimeout(execTypeCharacterCommand, commandCount * commandDelay);
111 execTypeCharacterCommand();
115 //-------------------------------------------------------------------------------------------------------
117 function execSelectAllCommand() {
118 document.execCommand("SelectAll");
120 function selectAllCommand() {
121 if (commandDelay > 0) {
122 window.setTimeout(execSelectAllCommand, commandCount * commandDelay);
126 execSelectAllCommand();
130 //-------------------------------------------------------------------------------------------------------
132 function execUndoCommand() {
133 document.execCommand("Undo");
135 function undoCommand() {
136 if (commandDelay > 0) {
137 window.setTimeout(execUndoCommand, commandCount * commandDelay);
145 //-------------------------------------------------------------------------------------------------------
147 function execRedoCommand() {
148 document.execCommand("Redo");
150 function redoCommand() {
151 if (commandDelay > 0) {
152 window.setTimeout(execRedoCommand, commandCount * commandDelay);
160 //-------------------------------------------------------------------------------------------------------
162 function execChangeRootSize() {
163 document.getElementById("root").style.width = "600px";
165 function changeRootSize() {
166 if (commandDelay > 0) {
167 window.setTimeout(execChangeRootSize, commandCount * commandDelay);
171 execChangeRootSize();
175 //-------------------------------------------------------------------------------------------------------
177 function execCutCommand() {
178 document.execCommand("Cut");
180 function cutCommand() {
181 if (commandDelay > 0) {
182 window.setTimeout(execCutCommand, commandCount * commandDelay);
190 //-------------------------------------------------------------------------------------------------------
192 function execCopyCommand() {
193 document.execCommand("Copy");
195 function copyCommand() {
196 if (commandDelay > 0) {
197 window.setTimeout(execCopyCommand, commandCount * commandDelay);
205 //-------------------------------------------------------------------------------------------------------
207 function execPasteCommand() {
208 document.execCommand("Paste");
210 function pasteCommand() {
211 if (commandDelay > 0) {
212 window.setTimeout(execPasteCommand, commandCount * commandDelay);
220 //-------------------------------------------------------------------------------------------------------
222 function execDeleteCommand() {
223 document.execCommand("Delete");
225 function deleteCommand() {
226 if (commandDelay > 0) {
227 window.setTimeout(execDeleteCommand, commandCount * commandDelay);
235 //-------------------------------------------------------------------------------------------------------
237 function runEditingTest() {
238 var elem = document.getElementById("test");
239 var selection = window.getSelection();
240 selection.setPosition(elem, 0);
244 //-------------------------------------------------------------------------------------------------------
246 function execBackColorCommand() {
247 document.execCommand("BackColor", false, "Chartreuse");
249 function backColorCommand() {
250 if (commandDelay > 0) {
251 window.setTimeout(execBackColorCommand, commandCount * commandDelay);
255 execBackColorCommand();
259 //-------------------------------------------------------------------------------------------------------
261 function execForeColorCommand() {
262 document.execCommand("ForeColor", false, "Purple");
264 function foreColorCommand() {
265 if (commandDelay > 0) {
266 window.setTimeout(execForeColorCommand, commandCount * commandDelay);
270 execForeColorCommand();
274 //-------------------------------------------------------------------------------------------------------
276 function execFontNameCommand() {
277 document.execCommand("FontName", false, "Courier");
279 function fontNameCommand() {
280 if (commandDelay > 0) {
281 window.setTimeout(execFontNameCommand, commandCount * commandDelay);
285 execFontNameCommand();
289 //-------------------------------------------------------------------------------------------------------
291 function execFontSizeCommand() {
292 document.execCommand("FontSize", false, "48px");
294 function fontSizeCommand() {
295 if (commandDelay > 0) {
296 window.setTimeout(execFontSizeCommand, commandCount * commandDelay);
300 execFontSizeCommand();