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