| Index: LayoutTests/accessibility/contenteditable-caret-position.html
|
| diff --git a/LayoutTests/accessibility/contenteditable-caret-position.html b/LayoutTests/accessibility/contenteditable-caret-position.html
|
| index a780c263d4cfe29ee18865a55e85da94791646b6..d5358f8be24f9db28a52ad9767a2a423381ccf30 100644
|
| --- a/LayoutTests/accessibility/contenteditable-caret-position.html
|
| +++ b/LayoutTests/accessibility/contenteditable-caret-position.html
|
| @@ -1,94 +1,156 @@
|
| <!DOCTYPE html>
|
| -<html>
|
| - <head>
|
| - <script src="../resources/js-test.js"></script>
|
| - </head>
|
| - <body>
|
| +<script src="../resources/js-test.js"></script>
|
| +
|
| +<div id="main" role="main">
|
|
|
| <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 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>
|
| + <p id="paragraph1">Line 1<br>Line 2</p>
|
| + <p id="paragraph2">Line 3</p>
|
| </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) {
|
| - var lineOffset = lineNumber * 7;
|
| - // Paragraphs should have an extra blank line between them.
|
| - if (lineNumber == 2)
|
| - lineOffset += 1;
|
| -
|
| - for (var characterOffset = 0; characterOffset < 7; ++characterOffset) {
|
| - caretPosition = lineOffset + characterOffset;
|
| -
|
| - selectionRange.setStart(contenteditableLines[lineNumber], characterOffset);
|
| - selectionRange.setEnd(contenteditableLines[lineNumber], characterOffset);
|
| - selection.removeAllRanges();
|
| - selection.addRange(selectionRange);
|
| -
|
| - shouldBeEqualToNumber("contenteditableAccessible.selectionStart",
|
| - caretPosition);
|
| - shouldBeEqualToNumber("contenteditableAccessible.selectionEnd",
|
| - caretPosition);
|
| - shouldBeEqualToNumber("contenteditableAccessible.selectionStartLineNumber",
|
| - lineNumber);
|
| - shouldBeEqualToNumber("contenteditableAccessible.selectionEndLineNumber",
|
| - lineNumber);
|
| - }
|
| +</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 mainAccessible = accessibilityController.accessibleElementById("main");
|
| + var rootAccessible = accessibilityController.rootElement;
|
| +
|
| + shouldBeZero("mainAccessible.selectionStart");
|
| + shouldBeZero("mainAccessible.selectionEnd");
|
| + shouldBeZero("mainAccessible.selectionStartLineNumber");
|
| + shouldBeZero("mainAccessible.selectionEndLineNumber");
|
| +
|
| + shouldBeNull("rootAccessible.selectionAnchorObject");
|
| + shouldBeEqualToNumber("rootAccessible.selectionAnchorOffset", -1);
|
| + shouldBeNull("rootAccessible.selectionFocusObject");
|
| + shouldBeEqualToNumber("rootAccessible.selectionFocusOffset", -1);
|
| +
|
| + 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");
|
| + var line1Accessible = accessibilityController.accessibleElementById("line1");
|
| + var line1TextAccessible = line1Accessible.getChildAtIndex(0);
|
| +
|
| + selectionRange.setStart(line1.firstChild, 1);
|
| + selectionRange.setEnd(line1.firstChild, 1);
|
| + selection.removeAllRanges();
|
| + selection.addRange(selectionRange);
|
| +
|
| + shouldBeEqualToNumber("textboxAccessible.selectionStart", 1);
|
| + shouldBeEqualToNumber("textboxAccessible.selectionEnd", 1);
|
| +
|
| + shouldBeEqualToNumber("mainAccessible.selectionStart", 1);
|
| + shouldBeEqualToNumber("mainAccessible.selectionEnd", 1);
|
| + shouldBeZero("mainAccessible.selectionStartLineNumber");
|
| + shouldBeZero("mainAccessible.selectionEndLineNumber");
|
| +
|
| + shouldBeEqual("rootAccessible.selectionAnchorObject", "line1TextAccessible");
|
| + shouldBeEqualToNumber("rootAccessible.selectionAnchorOffset", 1);
|
| + shouldBeEqual("rootAccessible.selectionFocusObject", "line1TextAccessible");
|
| + shouldBeEqualToNumber("rootAccessible.selectionFocusOffset", 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");
|
| + shouldBeZero("mainAccessible.selectionStart");
|
| + shouldBeZero("mainAccessible.selectionEnd");
|
| + shouldBeNull("rootAccessible.selectionAnchorObject");
|
| + shouldBeEqualToNumber("rootAccessible.selectionAnchorOffset", -1);
|
| + shouldBeNull("rootAccessible.selectionFocusObject");
|
| + shouldBeEqualToNumber("rootAccessible.selectionFocusOffset", -1);
|
| +
|
| + var line2Accessible = accessibilityController.focusedElement;
|
| + shouldBeZero("line2Accessible.selectionStart");
|
| + shouldBeZero("line2Accessible.selectionEnd");
|
| + line2.setSelectionRange(3, 3);
|
| +
|
| + shouldBeEqualToNumber("line2Accessible.selectionStart", 3);
|
| + shouldBeEqualToNumber("line2Accessible.selectionEnd", 3);
|
| + shouldBeZero("line2Accessible.selectionStartLineNumber");
|
| + shouldBeZero("line2Accessible.selectionEndLineNumber");
|
| +
|
| + shouldBeEqualToNumber("mainAccessible.selectionStart", 3);
|
| + shouldBeEqualToNumber("mainAccessible.selectionEnd", 3);
|
| + shouldBeZero("mainAccessible.selectionStartLineNumber");
|
| + shouldBeZero("mainAccessible.selectionEndLineNumber");
|
| +
|
| + shouldBeEqual("rootAccessible.selectionAnchorObject", "line2Accessible");
|
| + shouldBeEqualToNumber("rootAccessible.selectionAnchorOffset", 1);
|
| + shouldBeEqual("rootAccessible.selectionFocusObject", "line2Accessible");
|
| + shouldBeEqualToNumber("rootAccessible.selectionFocusOffset", 1);
|
| +
|
| +
|
| + var contenteditable = document.getElementById("contenteditable-div");
|
| + contenteditable.focus();
|
| + // The offset from the beginning of the main div to the first character of
|
| + // contenteditable-div. The whole of the textarea is treated as a single embedded object.
|
| + var mainOffset = 9;
|
| + 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) {
|
| + var lineOffset = lineNumber * 7;
|
| + // Paragraphs should have an extra blank line between them.
|
| + if (lineNumber == 2)
|
| + lineOffset += 1;
|
| +
|
| + for (var characterOffset = 0; characterOffset < 7; ++characterOffset) {
|
| + caretPosition = lineOffset + characterOffset;
|
| +
|
| + selectionRange.setStart(contenteditableLines[lineNumber], characterOffset);
|
| + selectionRange.setEnd(contenteditableLines[lineNumber], characterOffset);
|
| + selection.removeAllRanges();
|
| + selection.addRange(selectionRange);
|
| +
|
| + shouldBeEqualToNumber("contenteditableAccessible.selectionStart",
|
| + caretPosition);
|
| + shouldBeEqualToNumber("contenteditableAccessible.selectionEnd",
|
| + caretPosition);
|
| + shouldBeEqualToNumber("contenteditableAccessible.selectionStartLineNumber",
|
| + lineNumber);
|
| + shouldBeEqualToNumber("contenteditableAccessible.selectionEndLineNumber",
|
| + lineNumber);
|
| +
|
| + shouldBeEqualToNumber("mainAccessible.selectionStart",
|
| + mainOffset + caretPosition);
|
| + shouldBeEqualToNumber("mainAccessible.selectionEnd",
|
| + mainOffset + caretPosition);
|
| + shouldBeEqualToNumber("mainAccessible.selectionStartLineNumber",
|
| + lineNumber);
|
| + shouldBeEqualToNumber("mainAccessible.selectionEndLineNumber",
|
| + lineNumber);
|
| +
|
| + shouldBeEqualToString("rootAccessible.selectionAnchorObject.stringValue", "");
|
| + shouldBeEqualToNumber("rootAccessible.selectionAnchorOffset", 1);
|
| + shouldBeEqualToString("rootAccessible.selectionFocusObject.stringValue", "");
|
| + shouldBeEqualToNumber("rootAccessible.selectionFocusOffset", 1);
|
| }
|
| -
|
| }
|
| - </script>
|
|
|
| - </body>
|
| -</html>
|
| + }
|
| +</script>
|
|
|