blob: acec61fefdb28a8c79222abcb0ca70c792e7e299 [file] [log] [blame]
<!DOCTYPE HTML>
<html>
<head>
<script src="../resources/js-test.js"></script>
</head>
<body>
<div id="textbox" contentEditable="true">First<p>Second</p></div>
<div id="console"></div>
<script>
description("This test ensures that moving the cursor in a contentEditable sends a selected text change notification, and typing in a contentEditable sends both a value changed and selected text changed notification - both on the root element that's marked as contentEditable.");
window.jsTestIsAsync = true;
if (window.testRunner && window.accessibilityController) {
testRunner.dumpAsText();
// Focus the contenteditable text box and move the cursor to the end.
var textbox = document.getElementById("textbox");
textbox.focus();
eventSender.keyDown("downArrow", []);
eventSender.keyDown("downArrow", []);
var axTextBox = accessibilityController.focusedElement;
var valueChangedCount = 0;
var selectedTextChangedCount = 0;
// Defer the main part of the test so that the notification listener
// doesn't catch any notifications still in the queue from loading the
// page and initially setting focus.
window.setTimeout(function() {
axTextBox.addNotificationListener(function(notification) {
testPassed("Got notification: " + notification);
if (notification == "ValueChanged")
valueChangedCount++;
else if (notification == "SelectedTextChanged")
selectedTextChangedCount++;
if (valueChangedCount == 8 && selectedTextChangedCount == 6) {
textbox.style.display = "none";
finishJSTest();
}
});
eventSender.keyDown("leftArrow", []);
eventSender.keyDown("leftArrow", []);
eventSender.keyDown("w", []);
eventSender.keyDown("x", []);
eventSender.keyDown("y", []);
eventSender.keyDown("z", []);
}, 0);
}
</script>
</body>
</html>