1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
|
<!doctype html>
<meta charset=utf-8>
<title>Test that execCommand without editable element</title>
<script src=../include/implementation.js></script>
<script>var testsJsLibraryOnly = true</script>
<script src=../include/tests.js></script>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
"use strict";
setup({explicit_done: true});
// This test calls execCommand() without editable element in the document,
// but its parent or child document has editable element and it has focus.
// In most cases, execCommand() should do nothing and return false. However,
// "cut", "copy", "paste" and "selectall" commands should work without DOM tree
// modification for making web apps can implement their own editor without
// editable element.
async function runTests() {
let parentWindow = window;
let parentDocument = document;
let parentSelection = parentDocument.getSelection();
let parentEditor = parentDocument.getElementById("editor");
parentEditor.focus();
let iframe = document.getElementsByTagName("iframe")[0];
let childWindow = iframe.contentWindow;
let childDocument = iframe.contentDocument;
let childSelection = childDocument.getSelection();
let childEditor = childDocument.getElementById("editor");
childEditor.focus();
// execCommand() in child document shouldn't affect to focused parent
// document.
await doTest(parentWindow, parentDocument, parentSelection, parentEditor,
childWindow, childDocument, childSelection, childEditor, false);
// execCommand() in parent document shouldn't affect to focused child
// document but "cut" and "copy" may affect the focused child document.
await doTest(childWindow, childDocument, childSelection, childEditor,
parentWindow, parentDocument, parentSelection, parentEditor, true);
done();
}
async function doTest(aFocusWindow, aFocusDocument, aFocusSelection, aFocusEditor,
aExecWindow, aExecDocument, aExecSelection, aExecEditor,
aExecInParent) {
const kTests = [
/**
* command: The command which you test.
* focusContent: Will be set to innerHTML of div#editor element in focused
* document.
* execContent: Will be set to innerHTML of div#editor element in the
* document whose execCommand() will be called.
* initFunc: [optional] If you need to do something before running the
* test, you can do it with a function.
* expectedFocusContent: Expected content and selection in div#editor in
* focused document after calling execCommand().
* expectedExecContent: Expected content and selection in div#editor in
* the document whose execCommand() is called.
* event: The event which you need to check whether it's fired or not.
* expectedFiredInFocus: true if the event should be fired on the focused
* document node.
* expectedFiredInExec: true if the event should be fired on the document
* node whose execCommand() is called.
* expectedResult: Expected result of execCommand().
*/
{command: "bold", value: "bold",
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "italic", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "underline", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "strikethrough", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "subscript", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "superscript", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
// "cut", "copy" and "paste" command should cause firing corresponding
// events to make web apps be able to implement their own editor even
// if there is no editor and selection is collapsed.
{command: "cut", value: null,
focusContent: "a[b]c", execContent: "ab[]c",
expectedFocusContent: "a[b]c", expectedExecContent: "ab[]c",
event: "cut", expectedFiredInFocus: false, expectedFiredInExec: true,
expectedResult: false,
},
{command: "cut", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "cut", expectedFiredInFocus: false, expectedFiredInExec: true,
expectedResult: false,
},
{command: "copy", value: null,
focusContent: "a[b]c", execContent: "ab[]c",
expectedFocusContent: "a[b]c", expectedExecContent: "ab[]c",
event: "copy", expectedFiredInFocus: false, expectedFiredInExec: true,
expectedResult: false,
},
{command: "copy", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "copy", expectedFiredInFocus: false, expectedFiredInExec: true,
expectedResult: false,
},
{command: "paste", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
initFunc: () => { aFocusDocument.execCommand("copy", false, "b"); },
event: "paste", expectedFiredInFocus: false, expectedFiredInExec: true,
expectedResult: false,
},
{command: "delete", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "forwarddelete", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
// "selectall" command should be available without editable content.
{command: "selectall", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: undefined,
event: "selectionchange", expectedFiredInFocus: false, expectedFiredInExec: true,
expectedResult: true,
},
{command: "undo", value: null,
focusContent: "a[]c", execContent: "a[b]c",
initFunc: () => { aFocusDocument.execCommand("insertText", false, "b"); },
expectedFocusContent: "ab[]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "redo", value: null,
focusContent: "a[]c", execContent: "a[b]c",
initFunc: () => {
aFocusDocument.execCommand("insertText", false, "b");
aFocusDocument.execCommand("undo", false, null);
},
expectedFocusContent: "a[]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "indent", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "outdent", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "backcolor", value: "#000000",
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "forecolor", value: "#F0F0F0",
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "hilitecolor", value: "#FFFF00",
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "fontname", value: "DummyFont",
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "fontsize", value: "5",
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "increasefontsize", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "decreasefontsize", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "inserthorizontalrule", value: null,
focusContent: "a[]bc", execContent: "a[]bc",
expectedFocusContent: "a[]bc", expectedExecContent: "a[]bc",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "createlink", value: "foo.html",
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "insertimage", value: "no-image.png",
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "inserthtml", value: "<b>inserted</b>",
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "inserttext", value: "**inserted**",
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "justifyleft", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "justifyright", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "justifycenter", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "justifyfull", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "removeformat", value: null,
focusContent: "<b>a[b]c</b>", execContent: "<b>a[b]c</b>",
expectedFocusContent: "<b>a[b]c</b>", expectedExecContent: "<b>a[b]c</b>",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "unlink", value: null,
focusContent: "<a href=\"foo.html\">a[b]c</a>", execContent: "<a href=\"foo.html\">a[b]c</a>",
expectedFocusContent: "<a href=\"foo.html\">a[b]c</a>", expectedExecContent: "<a href=\"foo.html\">a[b]c</a>",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "insertorderedlist", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "insertunorderedlist", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "insertparagraph", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "insertlinebreak", value: null,
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "formatblock", value: "div",
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
{command: "heading", value: "h1",
focusContent: "a[b]c", execContent: "a[b]c",
expectedFocusContent: "a[b]c", expectedExecContent: "a[b]c",
event: "input", expectedFiredInFocus: false, expectedFiredInExec: false,
expectedResult: false,
},
/**
* command: The command which you test.
* state: The state which is used with execCommand().
* initState: The state which should be set with execCommand() first.
* focusContent: Will be set to innerHTML of div#editor element in focused
* document.
* execContent: Will be set to innerHTML of div#editor element in the
* document whose execCommand() will be called.
* initFunc: [optional] If you need to do something before running the
* test, you can do it with a function.
* expectedSetStateInFocus: Expected queryCommandState() result in focused
* document.
* expectedSetStateInExec: Expected queryCommandState() result in document
* whose execCommand() is called.
* expectedResult: Expected result of execCommand().
*/
{command: "styleWithCSS", state: "true", initState: "false",
focusContent: "a[b]c", execContent: "a[b]c",
expectedSetStateInFocus: false, expectedSetStateInExec: false,
expectedResult: false,
},
{command: "contentReadOnly", state: "true", initState: "false",
focusContent: "a[b]c", execContent: "a[b]c",
expectedSetStateInFocus: false, expectedSetStateInExec: false,
expectedResult: false,
},
{command: "insertBrOnReturn", state: "true", initState: "false",
focusContent: "a[b]c", execContent: "a[b]c",
expectedSetStateInFocus: false, expectedSetStateInExec: false,
expectedResult: false,
},
{command: "defaultParagraphSeparator", state: "div", initState: "p",
focusContent: "a[b]c", execContent: "a[b]c",
expectedSetStateInFocus: false, expectedSetStateInExec: false,
expectedResult: false,
},
{command: "defaultParagraphSeparator", state: "p", initState: "div",
focusContent: "a[b]c", execContent: "a[b]c",
expectedSetStateInFocus: false, expectedSetStateInExec: false,
expectedResult: false,
},
{command: "enableObjectResizing", state: "true", initState: "false",
focusContent: "a[b]c", execContent: "a[b]c",
expectedSetStateInFocus: false, expectedSetStateInExec: false,
expectedResult: false,
},
{command: "enableInlineTableEditing", state: "true", initState: "false",
focusContent: "a[b]c", execContent: "a[b]c",
expectedSetStateInFocus: false, expectedSetStateInExec: false,
expectedResult: false,
},
{command: "enableAbsolutePositionEditing", state: "true", initState: "false",
focusContent: "a[b]c", execContent: "a[b]c",
expectedSetStateInFocus: false, expectedSetStateInExec: false,
expectedResult: false,
},
];
async function waitForCondition(aCheckFunc) {
let retry = 60;
while (retry--) {
if (aCheckFunc()) {
return;
}
await new Promise(resolve => requestAnimationFrame(resolve));
}
}
for (const kTest of kTests) {
// Skip unsupported command since it's not purpose of this tests whether
// each command is supported on the browser.
if (!aExecDocument.queryCommandSupported(kTest.command)) {
continue;
}
aExecEditor.removeAttribute("contenteditable"); // Disable commands in the exec document.
let points = setupDiv(aFocusEditor, kTest.focusContent);
aFocusSelection.setBaseAndExtent(points[0], points[1], points[2], points[3]);
points = setupDiv(aExecEditor, kTest.execContent);
aExecSelection.setBaseAndExtent(points[0], points[1], points[2], points[3]);
aFocusWindow.focus();
aFocusEditor.focus();
if (kTest.initFunc) {
kTest.initFunc();
}
if (kTest.state === undefined) {
let eventFiredOnFocusDocument = false;
function handlerOnFocusDocument() {
eventFiredOnFocusDocument = true;
}
aFocusDocument.addEventListener(kTest.event, handlerOnFocusDocument, {capture: true});
let eventFiredOnExecDocument = false;
function handlerOnExecDocument() {
eventFiredOnExecDocument = true;
}
aExecDocument.addEventListener(kTest.event, handlerOnExecDocument, {capture: true});
const kDescription = `${aExecInParent ? "Parent" : "Child"}Document.execCommand(${kTest.command}, false, ${kTest.value}) with ${kTest.execContent}`;
test(function () {
let ret = aExecDocument.execCommand(kTest.command, false, kTest.value);
assert_equals(ret, kTest.expectedResult, `execCommand should return ${kTest.expectedResult}`);
}, `${kDescription}: calling execCommand`);
if (kTest.event === "selectionchange") {
test(function () {
assert_false(eventFiredOnFocusDocument,
`"${kTest.event}" event should not be fired synchronously on focused document`);
assert_false(eventFiredOnExecDocument,
`"${kTest.event}" event should not be fired synchronously on executed document`);
}, `${kDescription}: checking unexpected synchronous event`);
await waitForCondition(() => eventFiredOnFocusDocument && eventFiredOnExecDocument);
// TODO: Whether select all changes selection in the focused document depends on the
// implementation of "Select All".
} else {
test(function () {
assert_equals(eventFiredOnFocusDocument, kTest.expectedFiredInFocus,
`"${kTest.event}" event should${kTest.expectedFiredInFocus ? "" : " not"} be fired`);
}, `${kDescription}: checking event on focused document`);
}
test(function () {
assert_equals(eventFiredOnExecDocument, kTest.expectedFiredInExec,
`"${kTest.event}" event should${kTest.expectedFiredInExec ? "" : " not"} be fired`);
}, `${kDescription}: checking event on executed document`);
test(function () {
if (aFocusSelection.rangeCount) {
addBrackets(aFocusSelection.getRangeAt(0));
}
assert_equals(aFocusEditor.innerHTML, kTest.expectedFocusContent);
}, `${kDescription}: checking result content in focused document`);
test(function () {
if (kTest.command === "selectall") {
assert_true(aExecSelection.rangeCount > 0);
assert_equals(
aExecSelection.toString().replace(/[\r\n]/g, ""),
aExecDocument.body.textContent.replace(/[\r\n]/g, "")
);
} else {
if (aExecSelection.rangeCount) {
addBrackets(aExecSelection.getRangeAt(0));
}
assert_equals(aExecEditor.innerHTML, kTest.expectedExecContent);
}
}, `${kDescription}: checking result content in executed document`);
aFocusDocument.removeEventListener(kTest.event, handlerOnFocusDocument, {capture: true});
aExecDocument.removeEventListener(kTest.event, handlerOnExecDocument, {capture: true});
aExecEditor.setAttribute("contenteditable", "");
} else {
const kDescription = `${aExecInParent ? "Parent" : "Child"}Document.execCommand(${kTest.command}, false, ${kTest.state})`;
test(function () {
let ret = aExecDocument.execCommand(kTest.command, false, kTest.initState);
assert_equals(ret, kTest.expectedResult, `execCommand should return ${kTest.expectedResult}`);
}, `${kDescription}: calling execCommand to initialize`);
let hasSetState = false;
test(function () {
hasSetState = aExecDocument.queryCommandState(kTest.command);
assert_equals(hasSetState, kTest.expectedSetStateInExec, `queryCommandState on executed document should return ${kTest.expectedSetState}`);
}, `${kDescription}: calling queryCommandState on executed document after initializing`);
test(function () {
let ret = aFocusDocument.queryCommandState(kTest.command);
assert_equals(ret, kTest.expectedSetStateInFocus, `queryCommandState on focus document should return ${kTest.expectedSetState}`);
}, `${kDescription}: calling queryCommandState on focus document after initializing`);
if (hasSetState) {
test(function () {
let ret = aExecDocument.queryCommandValue(kTest.command);
assert_equals(ret, kTest.initState, `queryCommandValue on executed document should return ${kTest.initState}`);
}, `${kDescription}: calling queryCommandValue on executed document after initializing`);
}
test(function () {
let ret = aExecDocument.execCommand(kTest.command, false, kTest.state);
assert_equals(ret, kTest.expectedResult, `execCommand should return ${kTest.expectedResult}`);
}, `${kDescription}: calling execCommand to set state`);
test(function () {
hasSetState = aExecDocument.queryCommandState(kTest.command);
assert_equals(hasSetState, kTest.expectedSetStateInExec, `queryCommandState should return ${kTest.expectedSetState}`);
}, `${kDescription}: calling queryCommandState on executed document`);
test(function () {
let ret = aFocusDocument.queryCommandState(kTest.command);
assert_equals(ret, kTest.expectedSetStateInFocus, `queryCommandState should return ${kTest.expectedSetState}`);
}, `${kDescription}: calling queryCommandState on focused document`);
if (hasSetState) {
test(function () {
let ret = aExecDocument.queryCommandValue(kTest.command);
assert_equals(ret, kTest.state, `queryCommandValue should return ${kTest.initState}`);
}, `${kDescription}: calling queryCommandValue on executed document`);
}
aExecEditor.setAttribute("contenteditable", "");
test(function () {
let ret = aExecDocument.queryCommandState(kTest.command);
assert_equals(ret, kTest.expectedSetStateInExec, `queryCommandState should return ${kTest.expectedSetState}`);
}, `${kDescription}: calling queryCommandState on executed document after making executed document editable`);
}
}
}
window.addEventListener("load", runTests, {once: true});
</script>
<body>
<div contenteditable id="editor">abc</div>
<iframe srcdoc="<div contenteditable id='editor'>def</div><span>ghi</span>"></iframe>
</body>
|