Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / editing / execCommand / format-block-multiple-paragraphs.html
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../../resources/dump-as-markup.js"></script>
5 <div id="test0" contenteditable>
6 <div>hello</div><div>world</div><div>WebKit</div>
7 </div>
8 <div id="test1" contenteditable>
9 <p>hello</p><p>world</p>
10 </div>
11 <div id="test2" contenteditable>
12 <div>hello<pre>world</pre></div>
13 </div>
14 <div id="test3" contenteditable>
15 <h1>hello</h1><div><h2>world</h2><h3>WebKit</h3></div>
16 </div>
17 <div id="test4" contenteditable>
18 <div>hello<p>world</p>webkit</div>
19 </div>
20 <div id="test5" contenteditable>
21 <pre>hello
22 world
23 webkit
24 </pre>
25 </div>
26 <div id="test6" contenteditable>
27 <pre>hello
28 world
29 webkit
30 </pre>
31 </div>
32 <div id="test7" contenteditable>
33 hello<p>world</p><p>webkit</p>
34 </pre>
35 </div>
36 <div id="test8" contenteditable>
37 <div>hello</div><div>world</div><div>webkit</div>
38 </div>
39 <div id="test9" contenteditable>
40 <ul><li>hello</li><li>world</li></ul>
41 </div>
42 <script>
43
44 Markup.description('This tests ensures formatBlock do not make multiple elements when formatting multiple paragraphs.')
45
46 function testIndentation(containerId, selector, value) {
47     var container = document.getElementById(containerId);
48     selector(container);
49     Markup.dump(container, 'Formatting');
50     document.execCommand('FormatBlock', false, value);
51     Markup.dump(container, 'by ' + value + ' yields');
52 }
53
54 function selectAll(container) {
55     window.getSelection().selectAllChildren(container);
56 }
57
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');
66     }
67 }
68
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');
79
80 </script>
81 </body>
82 </html>