4 <p>This test ensures WebKit does not fire DOM mutation events while execCommand is in progress.
</p>
5 <div id=
"test" contenteditable
></div>
10 testRunner
.dumpAsText();
13 {name
: 'BackColor', value
: 'blue'},
14 {name
: 'CreateLink', value
: 'about:blank'},
15 {name
: 'Delete', value
: null},
16 {name
: 'FontName', value
: 'Arial'},
17 {name
: 'FontSize', value
: '5'},
18 {name
: 'FontSizeDelta', value
: '5'},
19 {name
: 'ForeColor', value
: 'blue'},
20 {name
: 'FormatBlock', value
: 'pre'},
21 {name
: 'ForwardDelete', value
: null},
22 {name
: 'HiliteColor', value
: 'red'},
23 {name
: 'Indent', value
: null},
24 {name
: 'InsertHTML', value
: "<i>hello</i>"},
25 {name
: 'InsertHorizontalRule', value
: null},
26 {name
: 'InsertImage', value
: '../resources/abe.png'},
27 {name
: 'InsertLineBreak', value
: null},
28 {name
: 'InsertNewlineInQuotedContent', value
: null},
29 {name
: 'InsertOrderedList', value
: null},
30 {name
: 'InsertParagraph', value
: null},
31 {name
: 'InsertText', value
: 'webkit'},
32 {name
: 'InsertUnorderedList', value
: null},
33 {name
: 'Italic', value
: null},
34 {name
: 'JustifyCenter', value
: null},
35 {name
: 'JustifyFull', value
: null},
36 {name
: 'JustifyLeft', value
: null},
37 {name
: 'JustifyNone', value
: null},
38 {name
: 'JustifyRight', value
: null},
39 {name
: 'Outdent', value
: null},
40 {name
: 'RemoveFormat', value
: null},
41 {name
: 'Strikethrough', value
: null},
42 {name
: 'Subscript', value
: null},
43 {name
: 'Superscript', value
: null},
44 {name
: 'Transpose', value
: null, selector: function (test
) { window
.getSelection().collapse(test
.firstChild
, 1); }},
45 {name
: 'Underline', value
: null},
46 {name
: 'Unlink', value
: null},
50 'DOMCharacterDataModified': false,
51 'DOMSubtreeModified': false,
52 'DOMNodeInserted': false,
53 'DOMNodeRemoved': false,
54 'DOMNodeRemovedFromDocument': false,
55 'DOMNodeInsertedIntoDocument': true, // this event can never be observed.
63 var test
= document
.getElementById('test');
65 function addEventListeners(node
) {
66 for (var e
in events
) {
67 node
.addEventListener(e
, function (event
) {
68 log
.push(test
.innerHTML
);
69 events
[event
.type
] = true;
74 function isLogConsistent() {
75 for (var i
= 1; i
< log
.length
; i
++) {
76 if (log
[0] != log
[i
]) {
84 addEventListeners(test
);
86 var initial
= 'hello, <input type="text"><blockquote align="right"><u><a href="about:blank">world</a></u></blockquote>';
87 for (var i
= 0; i
< commands
.length
; i
++) {
88 test
.innerHTML
= initial
;
92 if (test
.innerHTML
!= initial
) {
93 document
.write("FAIL: initial innerHTML didn't match");
97 if (commands
[i
].selector
)
98 commands
[i
].selector(test
);
100 document
.getElementsByTagName('input')[0].focus();
101 window
.getSelection().selectAllChildren(test
);
103 addEventListeners(test
.childNodes
[2]);
104 log
= []; // clear log
105 document
.execCommand(commands
[i
].name
, false, commands
[i
].value
);
107 var quotedValue
= commands
[i
].value
? "'" + commands
[i
].value
.replace('<', '<') + "'" : null;
108 var action
= "execCommand('" + commands
[i
].name
+ "', false, " + quotedValue
+ ")";
110 if (test
.innerHTML
== initial
|| log
.length
<= 0)
111 document
.write('FAIL: ' + action
+ ' made no change to the DOM.');
112 else if (!isLogConsistent())
113 document
.write('FAIL: ' + action
+ ' dispatched events before finalizing the DOM tree.');
115 document
.write('PASS: ' + action
);
117 test
.style
.display
= 'none';
119 document
.write('\n');
120 for (var e
in events
) {
122 document
.write('\nWARNING: ' + e
+ ' was never observed.');
125 document
.write('\n\nDONE');