<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<p id="para">This is a test</p>
<script>
test(() =>
{
let para = document.getElementById('para');
let selectstartCount = 0;
para.addEventListener('selectstart', (e) => {
selectstartCount++;
if (selectstartCount === 1)
e.preventDefault();
}, true);
let axPara = accessibilityController.accessibleElementById('para');
assert_false(axPara.setSelection(axPara, 0, axPara, 1));
assert_true(axPara.setSelection(axPara, 0, axPara, 1));
}, 'Test that setting the selection via the accessibility API can be canceled by JavaScript running on the page.');
</script>