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

Unified Diff: LayoutTests/accessibility/contenteditable-caret-position.html

Issue 1056763002: Reland: Made content editables report the caret and text selection by treating them as text controls (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Merged with master. Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/accessibility/contenteditable-caret-position-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/accessibility/contenteditable-caret-position.html
diff --git a/LayoutTests/accessibility/contenteditable-caret-position.html b/LayoutTests/accessibility/contenteditable-caret-position.html
new file mode 100644
index 0000000000000000000000000000000000000000..16531a58f8acbc3bcc8eee3d60ca03edbe94cfe3
--- /dev/null
+++ b/LayoutTests/accessibility/contenteditable-caret-position.html
@@ -0,0 +1,90 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src="../resources/js-test.js"></script>
+ </head>
+ <body>
+
+ <div id="contenteditable-textbox" role="textbox" contenteditable="true">
+ <div id="contenteditable-line1">Line 1</div>
+ <textarea id="contenteditable-line2" rows="1" cols="40">Line 2</textarea>
+ </div>
+
+ <div id="contenteditable-div" contenteditable>
+ <p id="paragraph1">Line 1<br>Line 2</p>
+ <p id="paragraph2">Line 3</p>
+ </div>
+
+ <p id="description"></p>
+ <div id="console"></div>
+
+ <script>
+ description("This tests that caret position is reported correctly for contenteditable elements.");
+
+ if (window.accessibilityController) {
+ var selection = window.getSelection();
+ var selectionRange = document.createRange();
+
+ var textbox = document.getElementById("contenteditable-textbox");
+ textbox.focus();
+ var textboxAccessible =
+ accessibilityController.accessibleElementById(
+ 'contenteditable-textbox');
+
+ shouldBeZero("textboxAccessible.selectionStart");
+ shouldBeZero("textboxAccessible.selectionEnd");
+
+ var line1 = document.getElementById("contenteditable-line1");
+ selectionRange.setStart(line1.firstChild, 1);
+ selectionRange.setEnd(line1.firstChild, 1);
+ selection.removeAllRanges();
+ selection.addRange(selectionRange);
+ shouldBeEqualToNumber("textboxAccessible.selectionStart", 1);
+ shouldBeEqualToNumber("textboxAccessible.selectionEnd", 1);
+
+ var line2 = document.getElementById("contenteditable-line2");
+ line2.focus();
+ // The selection should have been removed from the line1 div.
+ shouldBeZero("textboxAccessible.selectionStart");
+ shouldBeZero("textboxAccessible.selectionEnd");
+
+ var line2Accessible = accessibilityController.focusedElement;
+ shouldBeZero("line2Accessible.selectionStart");
+ shouldBeZero("line2Accessible.selectionEnd");
+ line2.setSelectionRange(3, 3);
+ shouldBeEqualToNumber("line2Accessible.selectionStart", 3);
+ shouldBeEqualToNumber("line2Accessible.selectionEnd", 3);
+
+ var contenteditable = document.getElementById('contenteditable-div');
+ contenteditable.focus();
+ var line1 = document.getElementById('paragraph1').firstChild;
+ var line2 = document.getElementById('paragraph1').lastChild;
+ var line3 = document.getElementById('paragraph2').firstChild;
+ var contenteditableLines = [ line1, line2, line3 ];
+ var contenteditableAccessible =
+ accessibilityController.accessibleElementById(
+ 'contenteditable-div');
+
+ for (var lineNumber = 0; lineNumber < 3; ++lineNumber) {
+ // Place the caret at the end of each line.
+ var caretPosition = lineNumber * 7 + 6;
+ // Paragraphs should have an extra blank line between them.
+ if (lineNumber == 2)
+ caretPosition += 1;
+
+ selectionRange.setStart(contenteditableLines[lineNumber], 6);
+ selectionRange.setEnd(contenteditableLines[lineNumber], 6);
+ selection.removeAllRanges();
+ selection.addRange(selectionRange);
+
+ shouldBeEqualToNumber("contenteditableAccessible.selectionStart",
+ caretPosition);
+ shouldBeEqualToNumber("contenteditableAccessible.selectionEnd",
+ caretPosition);
+ }
+
+ }
+ </script>
+
+ </body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/accessibility/contenteditable-caret-position-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698