Web Inspector: home button behaviour is wrong in DTE
[WebKit-https.git] / LayoutTests / inspector / editor / text-editor-home-button.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
7 function test()
8 {
9 function foo()
10 {
11     return 42;
12 }
13     var textEditor = InspectorTest.createTestEditor();
14     textEditor.overrideViewportForTest(0, undefined, 3);
15     textEditor.mimeType = "text/javascript";
16     textEditor.setReadOnly(false);
17     textEditor.element.focus();
18
19     textEditor.setText(foo.toString());
20
21     InspectorTest.addResult(textEditor.text());
22
23     function dumpTextEditorWithSelection()
24     {
25         InspectorTest.addResult(InspectorTest.textWithSelection(textEditor.text(), textEditor.selection()));
26     }
27
28     function homeButton(shift)
29     {
30         var key = WebInspector.isMac() ? "leftArrow" : "home";
31         var modifiers = WebInspector.isMac() ? ["metaKey"] : [];
32         if (shift)
33             modifiers.push("shiftKey");
34         eventSender.keyDown(key, modifiers);
35     }
36
37     InspectorTest.runTestSuite([
38         function testFirstNonBlankCharacter(next)
39         {
40             var selection = WebInspector.TextRange.createFromLocation(2, 8);
41             textEditor.setSelection(selection);
42             dumpTextEditorWithSelection();
43             homeButton(false);
44             dumpTextEditorWithSelection();
45             next();
46         },
47
48         function testFirstNonBlankCharacterFromWhitespace(next)
49         {
50             var selection = WebInspector.TextRange.createFromLocation(2, 2);
51             textEditor.setSelection(selection);
52             dumpTextEditorWithSelection();
53             homeButton(false);
54             dumpTextEditorWithSelection();
55             next();
56         },
57
58         function testHomeButtonToggling(next)
59         {
60             var selection = WebInspector.TextRange.createFromLocation(2, 2);
61             textEditor.setSelection(selection);
62             dumpTextEditorWithSelection();
63             homeButton(false);
64             dumpTextEditorWithSelection();
65             homeButton(false);
66             dumpTextEditorWithSelection();
67             homeButton(false);
68             dumpTextEditorWithSelection();
69             next();
70         },
71
72         function testHomeButtonDoesNotChangeCursor(next)
73         {
74             var selection = WebInspector.TextRange.createFromLocation(0, 2);
75             textEditor.setSelection(selection);
76             dumpTextEditorWithSelection();
77             homeButton(false);
78             dumpTextEditorWithSelection();
79             homeButton(false);
80             dumpTextEditorWithSelection();
81             next();
82         },
83
84         function testHomeButtonWithShift(next)
85         {
86             var selection = new WebInspector.TextRange(0, 0, 2, 8);
87             textEditor.setSelection(selection);
88             dumpTextEditorWithSelection();
89             homeButton(true);
90             dumpTextEditorWithSelection();
91             homeButton(true);
92             dumpTextEditorWithSelection();
93             homeButton(true);
94             dumpTextEditorWithSelection();
95             next();
96         },
97
98         function testHomeButtonWithShiftInversed(next)
99         {
100             var selection = new WebInspector.TextRange(3, 1, 2, 8);
101             textEditor.setSelection(selection);
102             dumpTextEditorWithSelection();
103             homeButton(true);
104             dumpTextEditorWithSelection();
105             homeButton(true);
106             dumpTextEditorWithSelection();
107             homeButton(true);
108             dumpTextEditorWithSelection();
109             next();
110         }
111     ]);
112 }
113
114 </script>
115 </head>
116
117 <body onload="runTest();">
118 <p>
119 This test verifies that home button triggers selection between first symbol of the line
120 and first non-blank symbol of the line.
121 </p>
122
123 </body>
124 </html>