Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: third_party/WebKit/LayoutTests/accessibility/set-selection-child-offset.html

Issue 2339093003: Support child-based node offsets when setting accessible selections (Closed)
Patch Set: Correct the 0-child case. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4
5 <div role="region">
6 <span role="presentation" id="span1">this is a<a id="link" href="#1">test</a ></span>
7 <span role="presentation" id="span2">of selection</span>
8 </div>
9
10 <script>
11 var sel = null;
12 function updateSelectedRangeFromPage() {
13 sel = window.getSelection().getRangeAt(0);
14 }
15
16 // The accessibility tree contains a region with 3 children, select each.
17 test(function()
18 {
19 assert_not_equals(window.accessibilityController, undefined, 'This test requires accessibilityController');
20
21 var axRegion = accessibilityController.accessibleElementById("link").par entElement();
22 assert_equals(axRegion.role, "AXRole: AXRegion");
23
24 // An insertion point before the first child.
25 axRegion.setSelection(axRegion, 0, axRegion, 0);
26 updateSelectedRangeFromPage();
27 assert_equals(sel.toString(), "");
28 assert_true(sel.collapsed);
29 assert_equals(sel.startContainer.constructor, Text);
30 assert_equals(sel.startOffset, 0);
31 assert_equals(sel.startContainer.textContent, "this is a");
32
33 // A straight-forward selection of the first child.
34 axRegion.setSelection(axRegion, 0, axRegion, 1);
35 updateSelectedRangeFromPage();
36 assert_equals(sel.toString(), "this is a");
37 assert_false(sel.collapsed);
38 assert_equals(sel.startContainer.constructor, Text);
39 assert_equals(sel.endContainer.constructor, Text);
40 assert_equals(sel.startOffset, 0);
41 assert_equals(sel.startContainer.textContent, "this is a");
42 assert_equals(sel.endOffset, 9);
43 assert_equals(sel.endContainer.textContent, "this is a");
44
45 // Another insertion point after the first child, before the second.
46 axRegion.setSelection(axRegion, 1, axRegion, 1);
47 updateSelectedRangeFromPage();
48 assert_equals(sel.toString(), "");
49 assert_true(sel.collapsed);
50 assert_equals(sel.startContainer.constructor, Text);
51 assert_equals(sel.startOffset, 9);
52 assert_equals(sel.startContainer.textContent, "this is a");
53
54 // Select the second child.
55 axRegion.setSelection(axRegion, 1, axRegion, 2);
56 updateSelectedRangeFromPage();
57 assert_equals(sel.toString(), "test\n");
58 assert_false(sel.collapsed);
59 assert_equals(sel.startContainer.constructor, Text);
60 assert_equals(sel.endContainer.constructor, Text);
61 assert_equals(sel.startOffset, 0);
62 assert_equals(sel.startContainer.textContent, "test");
63 assert_equals(sel.startContainer.compareDocumentPosition(sel.endContaine r), 4 /* before */);
64 assert_equals(sel.endOffset, 1);
65 assert_equals(sel.endContainer.textContent, "\n ");
66
67 // Next, another insertion point between second and third child.
68 axRegion.setSelection(axRegion, 2, axRegion, 2);
69 updateSelectedRangeFromPage();
70 assert_equals(sel.toString(), "");
71 assert_true(sel.collapsed);
72 assert_equals(sel.startContainer.constructor, Text);
73 assert_equals(sel.startOffset, 1);
74 assert_equals(sel.startContainer.textContent, "\n ");
75
76 // Select the third child.
77 axRegion.setSelection(axRegion, 2, axRegion, 3);
78 updateSelectedRangeFromPage();
79 assert_equals(sel.toString(), "of selection");
80 assert_false(sel.collapsed);
81 assert_equals(sel.startContainer.constructor, Text);
82 assert_equals(sel.endContainer.constructor, Text);
83 assert_equals(sel.startOffset, 0);
84 assert_equals(sel.startContainer.textContent, "of selection");
85 assert_equals(sel.endOffset, 12);
86 assert_equals(sel.endContainer.textContent, "of selection");
87
88 // Select the first and second children.
89 axRegion.setSelection(axRegion, 0, axRegion, 2);
90 updateSelectedRangeFromPage();
91 assert_equals(sel.toString(), "this is atest\n");
92 assert_false(sel.collapsed);
93 assert_equals(sel.startContainer.constructor, Text);
94 assert_equals(sel.endContainer.constructor, Text);
95 assert_equals(sel.startOffset, 0);
96 assert_equals(sel.startContainer.textContent, "this is a");
97 assert_equals(sel.endOffset, 1);
98 assert_equals(sel.endContainer.textContent, "\n ");
99
100 // Select the second and third children.
101 axRegion.setSelection(axRegion, 1, axRegion, 3);
102 updateSelectedRangeFromPage();
103 assert_equals(sel.toString(), "test\n of selection");
104 assert_false(sel.collapsed);
105 assert_equals(sel.startContainer.constructor, Text);
106 assert_equals(sel.endContainer.constructor, Text);
107 assert_equals(sel.startOffset, 0);
108 assert_equals(sel.startContainer.textContent, "test");
109 assert_equals(sel.endOffset, 12);
110 assert_equals(sel.endContainer.textContent, "of selection");
111
112 // Select everything.
113 axRegion.setSelection(axRegion, 0, axRegion, 3);
114 updateSelectedRangeFromPage();
115 assert_equals(sel.toString(), "this is atest\n of selection");
116 assert_false(sel.collapsed);
117 assert_equals(sel.startContainer.constructor, Text);
118 assert_equals(sel.endContainer.constructor, Text);
119 assert_equals(sel.startOffset, 0);
120 assert_equals(sel.startContainer.textContent, "this is a");
121 assert_equals(sel.endOffset, 12);
122 assert_equals(sel.endContainer.textContent, "of selection");
123
124 // Last, the insertion point after third child.
125 axRegion.setSelection(axRegion, 3, axRegion, 3);
126 updateSelectedRangeFromPage();
127 assert_equals(sel.toString(), "");
128 assert_true(sel.collapsed);
129 assert_equals(sel.startContainer.constructor, Text);
130 assert_equals(sel.startOffset, 12);
131 assert_equals(sel.startContainer.textContent, "of selection");
132 }, "Select child node at index.");
133 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698