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

Unified Diff: LayoutTests/accessibility/contenteditable-selection.html

Issue 1185343003: Implements the ability to get and set the caret position and the current selection from anywhere in… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Moved layout tests to another CL. Created 5 years, 5 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
Index: LayoutTests/accessibility/contenteditable-selection.html
diff --git a/LayoutTests/accessibility/contenteditable-selection.html b/LayoutTests/accessibility/contenteditable-selection.html
deleted file mode 100644
index c9e29bd13de85dd4009a3906d19e282d64b40dc3..0000000000000000000000000000000000000000
--- a/LayoutTests/accessibility/contenteditable-selection.html
+++ /dev/null
@@ -1,129 +0,0 @@
-<!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>
-
- <script>
- description("This tests that text selection is reported correctly for contenteditable elements.");
-
- if (window.accessibilityController) {
- var selection = window.getSelection();
- var selectionRange = document.createRange();
-
- var textbox = document.getElementById("contenteditable-textbox");
- var textboxAccessible =
- accessibilityController.accessibleElementById(
- 'contenteditable-textbox');
-
- var contenteditable = document.getElementById('contenteditable-div');
- var contenteditableAccessible =
- accessibilityController.accessibleElementById(
- 'contenteditable-div');
-
-
- // 1. Test the selectNodeContents method.
-
- // Select the entire contents of the ARIA textbox.
- // These include a text node and a textarea element taking up two lines.
- textbox.focus();
- selectionRange.selectNodeContents(textbox);
- selection.removeAllRanges();
- selection.addRange(selectionRange);
- shouldBeZero("textboxAccessible.selectionStart");
- // 7 for the "Line 1" text div + 1 for the textarea node.
- shouldBeEqualToNumber("textboxAccessible.selectionEnd", 8);
- shouldBeZero("textboxAccessible.selectionStartLineNumber");
- shouldBeEqualToNumber("textboxAccessible.selectionEndLineNumber", 1);
-
- // Select the entire contents of the content editable.
- contenteditable.focus();
- selectionRange.selectNodeContents(contenteditable);
- selection.removeAllRanges();
- selection.addRange(selectionRange);
- shouldBeZero("contenteditableAccessible.selectionStart");
- shouldBeEqualToNumber("contenteditableAccessible.selectionEnd", 21);
- shouldBeZero("contenteditableAccessible.selectionStartLineNumber");
- shouldBeEqualToNumber("contenteditableAccessible.selectionEndLineNumber", 2);
-
-
- // 2. Test the setStart and setEnd methods.
-
- // Select only the first line of the textbox.
- var line1 = document.getElementById("contenteditable-line1");
- selectionRange.setStart(line1.firstChild, 0);
- selectionRange.setEnd(line1.firstChild, 6);
- selection.removeAllRanges();
- selection.addRange(selectionRange);
- shouldBeZero("textboxAccessible.selectionStart");
- shouldBeEqualToNumber("textboxAccessible.selectionEnd", 6);
- shouldBeZero("textboxAccessible.selectionStartLineNumber");
- shouldBeZero("textboxAccessible.selectionEndLineNumber");
-
-
- // 3. Test the effect of the textarea.setSelectionRange method.
-
- // Select only the second line, that is, the one found in the textarea.
- 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;
- line2.setSelectionRange(0, line2.textLength);
- shouldBeZero("line2Accessible.selectionStart");
- shouldBeEqualToNumber("line2Accessible.selectionEnd", line2.textLength);
- shouldBeZero("line2Accessible.selectionStartLineNumber");
- shouldBeZero("line2Accessible.selectionEndLineNumber");
-
-
- // 4. Test the selectNode method.
-
- // Select entire lines in the content editable.
- var line1 = document.getElementById('paragraph1').firstChild;
- var line2 = document.getElementById('paragraph1').lastChild;
- var line3 = document.getElementById('paragraph2');
- var contenteditableLines = [ line1, line2, line3 ];
-
- for (var testCase = 0; testCase < 2; ++testCase) {
-
- for (var i = 0; i < contenteditableLines.length; ++i) {
- var start = i * 7;
- var end = i * 7 + 6;
- if (i == 2) {
- // Paragraphs have a blank line between them.
- ++start;
- ++end;
- }
-
- selectionRange.selectNode(contenteditableLines[i]);
- selection.removeAllRanges();
- selection.addRange(selectionRange);
-
- shouldBeEqualToNumber("contenteditableAccessible.selectionStart", start);
- shouldBeEqualToNumber("contenteditableAccessible.selectionEnd", end);
- shouldBeEqualToNumber("contenteditableAccessible.selectionStartLineNumber", i);
- shouldBeEqualToNumber("contenteditableAccessible.selectionEndLineNumber", i);
- }
-
- // For a sanity check, try the same tests with contenteditable="false".
- contenteditable.contenteditable = false;
- }
-
- }
- </script>
-
- </body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698