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

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

Issue 1942953003: Accessible setSelection function should use VisiblePositions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test for selecting whole element Created 4 years, 7 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/core/editing/EditingUtilities.h » ('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 id="main" role="main">
6
7 <div id="editable1" contenteditable="true">Hello1</div>
8
9 <div id="editable2" contenteditable="true"> Hello2 </div>
10
11 <h2 id="heading"> Hello2 </h2>
12
13 </div>
14
15 <script>
16 test(function()
17 {
18 var axEditable1 = accessibilityController.accessibleElementById("editabl e1");
19 var axTextNode1 = axEditable1.childAtIndex(0);
20 assert_equals(axTextNode1.name, "Hello1");
21 axTextNode1.setSelectedTextRange(0, 6);
22
23 var selection = window.getSelection();
24 var range = selection.getRangeAt(0);
25 assert_equals(range.toString(), "Hello1");
26
27 var editable1 = document.getElementById("editable1");
28 var textNode1 = editable1.firstChild;
29 assert_equals(range.startContainer, textNode1);
30 assert_equals(range.startOffset, 0);
31 assert_equals(range.endContainer, textNode1);
32 assert_equals(range.endOffset, 6);
33 }, "Using accessible APIs to set selection works when there's no extra white space.");
34
35 test(function()
36 {
37 var axEditable2 = accessibilityController.accessibleElementById("editabl e2");
38 var axTextNode2 = axEditable2.childAtIndex(0);
39 assert_equals(axTextNode2.name, "Hello2");
40 axTextNode2.setSelectedTextRange(0, 6);
41
42 var selection = window.getSelection();
43 var range = selection.getRangeAt(0);
44 assert_equals(range.toString(), "Hello2");
45
46 var editable2 = document.getElementById("editable2");
47 var textNode2 = editable2.firstChild;
48 assert_equals(range.startContainer, textNode2);
49 assert_equals(range.startOffset, 2);
50 assert_equals(range.endContainer, textNode2);
51 assert_equals(range.endOffset, 8);
52 }, "Using accessible APIs to set selection works even with non-visible white space.");
53 </script>
54
55 <script>
56 test(function()
57 {
58 var axHeading = accessibilityController.accessibleElementById("heading") ;
59 axHeading.setSelectedTextRange(0, 1); // Should select the whole elemen t.
60
61 var selection = window.getSelection();
62 var range = selection.getRangeAt(0);
63 assert_equals(range.toString(), "Hello2");
64
65 var heading = document.getElementById("heading");
66 var textNode = heading.firstChild;
67 assert_equals(range.startContainer, textNode);
68 assert_equals(range.startOffset, 2);
69 assert_equals(range.endContainer, textNode);
70 assert_equals(range.endOffset, 8);
71 }, "Use accessible APIs to set selection on element rather than static text node.");
72 </script>
73
74 <script>
75 if (window.testRunner)
76 document.getElementById("main").style.display = "none";;
77 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/EditingUtilities.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698