Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / editor / text-editor-enter-behaviour.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 function testFunction()
13 {
14     var a = 100;
15     var b = 200;
16     var c = (a + b) / 2;
17     console.log(a);
18     console.log(b);
19     console.log(c);
20     if (a > b) {
21         console.log(a);
22     }
23     return c;
24 }
25     var textEditor = InspectorTest.createTestEditor();
26     textEditor.setMimeType("text/javascript");
27     textEditor.setReadOnly(false);
28     textEditor.element.focus();
29
30     InspectorTest.runTestSuite([
31         function testEnterInTheLineEnd(next)
32         {
33             textEditor.setText(testFunction.toString());
34             var line = textEditor.line(2);
35             textEditor.setSelection(WebInspector.TextRange.createFromLocation(2, line.length));
36             hitEnterDumpTextAndNext(next);
37         },
38
39         function testEnterAfterOpenCurlyBrace(next)
40         {
41             textEditor.setText(testFunction.toString());
42             var line = textEditor.line(1);
43             textEditor.setSelection(WebInspector.TextRange.createFromLocation(1, line.length));
44             hitEnterDumpTextAndNext(next);
45         },
46
47         function testEnterInTheMiddleOfLine(next)
48         {
49             textEditor.setText(testFunction.toString());
50             var line = textEditor.line(2);
51             textEditor.setSelection(WebInspector.TextRange.createFromLocation(2, line.length / 2));
52             hitEnterDumpTextAndNext(next);
53         },
54
55         function testEnterInTheBeginningOfTheLine(next)
56         {
57             textEditor.setText(testFunction.toString());
58             textEditor.setSelection(WebInspector.TextRange.createFromLocation(2, 0));
59             hitEnterDumpTextAndNext(next);
60         },
61
62         function testEnterWithTheSelection(next)
63         {
64             textEditor.setText(testFunction.toString());
65             textEditor.setSelection(new WebInspector.TextRange(2, 2, 2, 4));
66             hitEnterDumpTextAndNext(next);
67         },
68
69         function testEnterWithReversedSelection(next)
70         {
71             textEditor.setText(testFunction.toString());
72             textEditor.setSelection(new WebInspector.TextRange(2, 4, 2, 2));
73             hitEnterDumpTextAndNext(next);
74         },
75
76         function testEnterWithTheMultiLineSelection(next)
77         {
78             textEditor.setText(testFunction.toString());
79             textEditor.setSelection(new WebInspector.TextRange(2, 0, 8, 4));
80             hitEnterDumpTextAndNext(next);
81         },
82
83         function testEnterWithFullLineSelection(next)
84         {
85             textEditor.setText(testFunction.toString());
86             textEditor.setSelection(new WebInspector.TextRange(2, 0, 3, 0));
87             hitEnterDumpTextAndNext(next);
88         },
89
90         function testEnterBeforeOpenBrace(next)
91         {
92             textEditor.setText(testFunction.toString());
93             textEditor.setSelection(new WebInspector.TextRange(8, 0, 8, 0));
94             hitEnterDumpTextAndNext(next);
95         },
96
97         function testEnterMultiCursor(next)
98         {
99             textEditor.setText(testFunction.toString());
100             InspectorTest.setLineSelections(textEditor, [
101                 { line: 3, column: 0 },
102                 { line: 5, column: 1 },
103                 { line: 6, column: 2 },
104             ]);
105             hitEnterDumpTextAndNext(next);
106         }
107     ]);
108
109     function hitEnterDumpTextAndNext(next)
110     {
111         InspectorTest.fakeKeyEvent(textEditor, "enter", null, step2);
112         function step2()
113         {
114             InspectorTest.dumpTextWithSelection(textEditor, true);
115             next();
116         }
117     }
118 }
119
120 </script>
121 </head>
122
123 <body onload="runTest();">
124 <p>
125 This test checks text editor enter behaviour.
126 </p>
127 </body>
128 </html>