4 <script src=
"../../resources/dump-as-markup.js"></script>
5 <div id=
"test0" contenteditable
>
6 <div>hello
</div><div>world
</div><div>WebKit
</div>
8 <div id=
"test1" contenteditable
>
9 <p>hello
</p><p>world
</p>
11 <div id=
"test2" contenteditable
>
12 <div>hello
<pre>world
</pre></div>
14 <div id=
"test3" contenteditable
>
15 <h1>hello
</h1><div><h2>world
</h2><h3>WebKit
</h3></div>
17 <div id=
"test4" contenteditable
>
18 <div>hello
<p>world
</p>webkit
</div>
20 <div id=
"test5" contenteditable
>
26 <div id=
"test6" contenteditable
>
32 <div id=
"test7" contenteditable
>
33 hello
<p>world
</p><p>webkit
</p>
36 <div id=
"test8" contenteditable
>
37 <div>hello
</div><div>world
</div><div>webkit
</div>
39 <div id=
"test9" contenteditable
>
40 <ul><li>hello
</li><li>world
</li></ul>
44 Markup
.description('This tests ensures formatBlock do not make multiple elements when formatting multiple paragraphs.')
46 function testIndentation(containerId
, selector
, value
) {
47 var container
= document
.getElementById(containerId
);
49 Markup
.dump(container
, 'Formatting');
50 document
.execCommand('FormatBlock', false, value
);
51 Markup
.dump(container
, 'by ' + value
+ ' yields');
54 function selectAll(container
) {
55 window
.getSelection().selectAllChildren(container
);
58 function selectorForLines(first
, last
) {
59 return function (container
) {
60 window
.getSelection().collapse(container
, 0);
61 for (var i
= 0; i
< first
- 1; i
++)
62 window
.getSelection().modify('move', 'forward', 'line');
63 for (var i
= 0; i
< Math
.abs(last
- first
, 0) + 1; i
++)
64 window
.getSelection().modify('extend', 'forward', 'line');
65 window
.getSelection().modify('extend', 'backward', 'character');
69 testIndentation('test0', selectAll
, 'p');
70 testIndentation('test1', selectAll
, 'blockquote');
71 testIndentation('test2', selectAll
, 'p');
72 testIndentation('test3', selectAll
, 'pre');
73 testIndentation('test4', selectorForLines(2, 3), 'h1');
74 testIndentation('test5', selectorForLines(1, 2), 'blockquote');
75 testIndentation('test6', selectorForLines(2, 3), 'blockquote');
76 testIndentation('test7', selectorForLines(1, 2), 'pre');
77 testIndentation('test8', selectorForLines(2, 3), 'pre');
78 testIndentation('test9', selectAll
, 'blockquote');