Refactoring: Pull all fullscreen code out of Document and into its own helper class
[WebKit-https.git] / LayoutTests / accessibility / textarea-insertion-point-line-number.html
1 <html>
2 <script src="../resources/js-test.js"></script>
3 <body>
4     <div id="console"></div>
5     <textarea name="area1" id="area1" rows="5" cols="40">
6 line 1
7 line 2
8 line 3
9     </textarea>
10
11     <textarea name="area2" id="area2" rows="5" cols="40"></textarea>
12
13
14     <div id="contenteditable-div" role="textbox" contenteditable="true" tabindex="0">
15       <div id="contenteditable-line1">Line1</div>
16       <textarea id="contenteditable-line2" rows="1" cols="40">Line2</textarea>
17       <div id="contenteditable-line3">Line3</div>
18     </div>
19     <script>
20         description("This tests that lineNumberForPosition is reported correctly for textarea and contenteditable elements.");
21
22         if (window.accessibilityController) {
23             var console = document.getElementById("console");
24
25             var area1 = document.getElementById("area1");
26             area1.focus();
27             var area1AXUIElement = accessibilityController.focusedElement;
28             var lineNumber = -2;
29
30             for (var currentLine = 0; currentLine < 3; currentLine++ ) {
31                 shouldBe("area1.selectionStart = (" + (currentLine * 7) + "); " +
32                          "area1.selectionEnd = (" + (currentLine * 7) +"); " +
33                          "area1AXUIElement.insertionPointLineNumber;", "currentLine");
34             }
35
36             var area2 = document.getElementById("area2");
37             shouldBe("area2.focus(); area1AXUIElement.insertionPointLineNumber;", "-1");
38
39             var contenteditableDiv = document.getElementById("contenteditable-div");
40             contenteditableDiv.focus();
41             var contenteditableAXUIElement = accessibilityController.focusedElement;
42
43             var contenteditableLine1 = document.getElementById("contenteditable-line1");
44             shouldBe("window.getSelection().setBaseAndExtent(contenteditableLine1, 1, contenteditableLine1, 1); " +
45                      "contenteditableAXUIElement.insertionPointLineNumber;", "0");
46
47             var contenteditableLine2 = document.getElementById("contenteditable-line2");
48             shouldBe("contenteditableLine2.selectionStart = 1; contenteditableLine2.selectionEnd = 1;" +
49                      "contenteditableAXUIElement.insertionPointLineNumber;", "-1");
50
51             var contenteditableLine3 = document.getElementById("contenteditable-line3");
52             shouldBe("window.getSelection().setBaseAndExtent(contenteditableLine3, 1, contenteditableLine3, 1); " +
53                      "contenteditableAXUIElement.insertionPointLineNumber;", "2");
54
55             contenteditableLine2.focus();
56             var textareaAXUIElement = accessibilityController.focusedElement;
57             shouldBe("textareaAXUIElement.insertionPointLineNumber", "0");
58         }
59     </script>
60 </body>
61 </html>