Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / editing / execCommand / indent-pre-list.html
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../../resources/dump-as-markup.js"></script>
5 <div id="test0" contenteditable>
6 <pre>
7 <ul><li>hello</li></ul></pre>
8 </div>
9
10 <div id="test1" contenteditable>
11 <pre><ul><li>hello
12 world</li>
13 </ul></pre>
14 </div>
15
16 <div id="test2" contenteditable>
17 <ul><li><pre>
18 hello
19 world
20 webkit
21 </pre></li></ul>
22 </div>
23
24 <div id="test3" contenteditable>
25 <ul><li><pre>
26 hello
27 world
28 webkit
29 </pre></li></ul>
30 </div>
31
32 <div id="test4" contenteditable>
33 <ul><li><pre>
34 hello
35 world
36 webkit
37 </pre></li></ul>
38 </div>
39
40 <div id="test5" contenteditable>
41 <ul><li><pre>
42 hello
43 world
44 webkit
45 </pre></li></ul>
46 </div>
47
48 <script>
49
50 function testIndentation(containerId, selector) {
51     var container = document.getElementById(containerId);
52     selector(container);
53     Markup.dump(container, 'Indenting');
54     document.execCommand('indent', false, null);
55     Markup.dump(container, 'yields');
56 }
57
58 function selectAll(container) {
59     window.getSelection().selectAllChildren(container);
60 }
61
62 function selectorForLineN(line) {
63     return function (container) {
64         window.getSelection().collapse(container, 0);
65         for (var i = 0; i < line - 1; i++)
66             window.getSelection().modify('move', 'forward', 'line');
67         window.getSelection().modify('extend', 'forward', 'line');
68         // Avoid including \n at the end of line.
69         window.getSelection().modify('extend', 'backward', 'character');
70     }
71 }
72
73 testIndentation('test0', selectAll);
74 testIndentation('test1', selectAll);
75 testIndentation('test2', selectAll);
76 testIndentation('test3', selectorForLineN(1));
77 testIndentation('test4', selectorForLineN(2));
78 testIndentation('test5', selectorForLineN(3));
79
80 </script>
81 </body>
82 </html>