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
|
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/dump-as-markup.js"></script>
<div id="test" contenteditable>
<pre>
hello
world
webkit
</pre>
</div>
<script>
Markup.description('This tests ensures formatBlock removes a pre when formatting multiple paragraphs inside the pre.');
var test = document.getElementById('test');
var original = test.innerHTML;
window.getSelection().selectAllChildren(test);
document.execCommand('formatBlock', false, 'h3');
Markup.dump(test, 'Formatting all paragraphs by h3 yields');
document.execCommand('undo', false, null);
Markup.dump(test, 'Undo yields');
window.getSelection().collapse(test, 0);
window.getSelection().modify('extend', 'forward', 'line');
window.getSelection().modify('extend', 'forward', 'line');
window.getSelection().modify('extend', 'forward', 'line');
window.getSelection().modify('extend', 'forward', 'line');
document.execCommand('formatBlock', false, 'h3');
Markup.dump(test, 'Formatting all but the last paragraph by h3 yields');
document.execCommand('undo', false, null);
Markup.dump(test, 'Undo yields');
window.getSelection().collapse(test, 0);
window.getSelection().modify('move', 'forward', 'line');
window.getSelection().modify('extend', 'forward', 'line');
window.getSelection().modify('extend', 'forward', 'line');
window.getSelection().modify('extend', 'forward', 'line');
window.getSelection().modify('extend', 'forward', 'line');
document.execCommand('formatBlock', false, 'h3');
Markup.dump(test, 'Formatting all but the first paragraph by h3 yields');
</script>
</body>
</html>
|