Refactoring: Pull all fullscreen code out of Document and into its own helper class
[WebKit-https.git] / LayoutTests / accessibility / set-selected-text-range-contenteditable.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <script src="../resources/js-test-pre.js"></script>
6 </head>
7 <body id="body">
8
9 <div contenteditable id="content" tabindex="0">hello <b>world</b> test</div>
10
11 <p id="description"></p>
12 <div id="console"></div>
13
14 <script>
15
16     description("This tests that selected text ranges can be set on a contenteditable element.");
17
18
19     if (window.accessibilityController) {
20         window.jsTestIsAsync = true;
21
22         document.getElementById("content").focus();
23         var sel = window.getSelection();
24         var range = document.createRange();
25         range.setStart(sel.anchorNode, 1);
26         range.setEnd(sel.anchorNode, 1);
27         sel.removeAllRanges();
28         sel.addRange(range);
29
30         var content = accessibilityController.accessibleElementById("content");
31         debug("Initial selected range: " + content.selectedTextRange);
32
33         debug("\nSet range: {3, 0}");
34         content.setSelectedTextRange(3, 0);
35         shouldBecomeEqual("content.selectedTextRange", "'{3, 0}'", function() {
36             debug("\nSet range: {100, 0}");
37             content.setSelectedTextRange(100, 0);
38             shouldBecomeEqual("content.selectedTextRange", "'{16, 0}'", function() {
39                 debug("\nSet range: {0, 0}");
40                 content.setSelectedTextRange(0, 0);
41                 shouldBecomeEqual("content.selectedTextRange", "'{0, 0}'", function() {
42                     debug("\nSet range: {1, 12}");
43                     content.setSelectedTextRange(1, 12);
44                     shouldBecomeEqual("content.selectedTextRange", "'{1, 12}'", function() {
45                         debug("\nSet range: {-1, 0}");
46                         content.setSelectedTextRange(-1, 0);
47
48                         // In ATK, -1 is used as an alias for the final offset.
49                         expectations = accessibilityController.platformName == "atk" ? "'{16, 0}'" : "'{0, 0}'";
50
51                         shouldBecomeEqual("content.selectedTextRange", expectations, function() {
52                             debug("\nSet range: {7, 3}");
53                             content.setSelectedTextRange(7, 3);
54                             shouldBecomeEqual("content.selectedTextRange", "'{7, 3}'", finishJSTest);
55                         });
56                     });
57                 });
58             });
59         }); 
60     }
61
62 </script>
63
64 <script src="../resources/js-test-post.js"></script>
65 </body>
66 </html>