blob: b4a8eab5aa3968b07cc21ef4b90fc7ea4d0562da [file] [log] [blame]
<!DOCTYPE HTML>
<html>
<head>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body id="static_eventTarget">
<div id="ariaTextbox" role="textbox" tabIndex="0">
<p>Before</p>
<p id="p">One paragraph in an ARIA textbox</p>
<p>After</p>
</div>
<div id="console"></div>
<script>
async_test((t) => {
// This forces building the accessibility tree, because selection change
// events only fire on elements that already exist.
accessibilityController.accessibleElementById('dummy');
var element = document.getElementById('ariaTextbox');
element.focus();
var axElement = accessibilityController.accessibleElementById('ariaTextbox');
axElement.addNotificationListener(t.step_func((notification) => {
// Focus notification will come asynchronously after layout
if (notification == 'Focus')
return;
if (notification == 'SelectedTextChanged') {
axElement.removeNotificationListener();
t.done();
return;
};
assert_unreached('Unexpected notification: ' + notification);
}));
var p = document.getElementById('p');
var range = document.createRange();
range.setStart(p.firstChild, 0);
range.setEnd(p.firstChild, 1);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
}, "Tests that a 'selected text changed' notification fires on a focusable element with role=textbox when the user moves the cursor within it.");
</script>
</body>
</html>