blob: 46c883b5604c755fbce68980acced2d3f36a8fb8 [file] [log] [blame]
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../resources/run-after-layout-and-paint.js"></script>
<div id="contentEditable" contentEditable="true">
<p>Before</p>
<p id="p">One paragraph in a contentEditable</p>
<p>After</p>
</div>
<script>
'use strict';
// Wait until layout has settled to avoid notification spam.
async_test_after_layout_and_paint((t) => {
const axElement = accessibilityController.accessibleElementById('contentEditable');
axElement.setNotificationListener(t.step_func((notification, intents) => {
// Focus notification will come asynchronously.
if (notification == 'Focus')
return;
if (notification == 'SelectedTextChanged') {
assert_array_equals(intents,
['AXEventIntent(setSelection,none,character,forward)']);
axElement.unsetNotificationListener();
t.done();
return;
}
assert_unreached('Unexpected notification: ' + notification);
}));
const element = document.getElementById('contentEditable');
element.focus();
const p = document.getElementById('p');
const range = document.createRange();
range.setStart(p.firstChild, 0);
range.setEnd(p.firstChild, 1);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
});
</script>