Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / editor / text-editor-block-indent.html
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="editor-test.js"></script>
5 <script>
6 function codeSnippet() {
7     return document.getElementById("codeSnippet").textContent;
8 }
9
10 function test()
11 {
12     var textEditor = InspectorTest.createTestEditor();
13     textEditor.setMimeType("text/javascript");
14     textEditor.setReadOnly(false);
15     textEditor.element.focus();
16     InspectorTest.evaluateInPage("codeSnippet();", onCodeSnippet);
17     var codeSnippetText;
18
19     function onCodeSnippet(result)
20     {
21         codeSnippetText = result.value;
22         InspectorTest.runTestSuite(testSuite);
23     }
24
25     function dumpAndNext(next)
26     {
27         function innerDumpAndNext()
28         {
29             InspectorTest.dumpTextWithSelection(textEditor, true);
30             next();
31         }
32         return innerDumpAndNext;
33     }
34
35     var testSuite = [
36         function testSimpleCollapsedBlockExpanding(next)
37         {
38             textEditor.setText(codeSnippetText);
39             InspectorTest.setLineSelections(textEditor, [
40                 {line: 0, column: 1}
41             ]);
42             InspectorTest.fakeKeyEvent(textEditor, "enter", [], dumpAndNext(next));
43         },
44
45         function testMulticursorCollapsedBlockExpanding(next)
46         {
47             textEditor.setText(codeSnippetText);
48             InspectorTest.setLineSelections(textEditor, [
49                 {line: 0, column: 1},
50                 {line: 0, column: 4},
51                 {line: 1, column: 3}
52             ]);
53             InspectorTest.fakeKeyEvent(textEditor, "enter", [], dumpAndNext(next));
54         },
55
56         function testMulticursorCollapsedBlockNotExpanding(next)
57         {
58             textEditor.setText(codeSnippetText);
59             InspectorTest.setLineSelections(textEditor, [
60                 {line: 0, column: 1},
61                 {line: 1, column: 2}
62             ]);
63             InspectorTest.fakeKeyEvent(textEditor, "enter", [], dumpAndNext(next));
64         },
65
66         function testSingleCursorClosingBracketIndent(next)
67         {
68             textEditor.setText(codeSnippetText);
69             InspectorTest.setLineSelections(textEditor, [
70                 {line: 3, column: 0}
71             ]);
72             InspectorTest.fakeKeyEvent(textEditor, "}", [], dumpAndNext(next));
73         },
74
75         function testMulticursorClosingBracketIndent(next)
76         {
77             textEditor.setText(codeSnippetText);
78             InspectorTest.setLineSelections(textEditor, [
79                 {line: 3, column: 5},
80                 {line: 5, column: 9}
81             ]);
82             InspectorTest.fakeKeyEvent(textEditor, "}", [], dumpAndNext(next));
83         },
84
85         function testMulticursorClosingBracketIndentNotExecuted(next)
86         {
87             textEditor.setText(codeSnippetText);
88             InspectorTest.setLineSelections(textEditor, [
89                 {line: 3, column: 5},
90                 {line: 4, column: 5}
91             ]);
92             InspectorTest.fakeKeyEvent(textEditor, "}", [], dumpAndNext(next));
93         }
94     ];
95 }
96
97 </script>
98 </head>
99
100 <body onload="runTest();">
101 <p>
102 This test verifies applied indentation whenever you hit enter in "{|}" or type in "}" while inside opened block.
103 </p>
104
105 <pre id="codeSnippet">
106 {} {}
107   {}
108   {
109     
110     {
111         
112 </pre>
113
114 </body>
115 </html>