blob: bb1a28ff8a7783aeb6c95e98a10d11956acbf349 [file] [log] [blame] [edit]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/accessibility-helper.js"></script>
<script src="../resources/js-test.js"></script>
</head>
<body>
<input id="text-input" type="text" value="fooooooooooooooooooooooooooooooooooo"/>
<script>
var output = "This test ensures that hit testing a text input yields the text input, not any element within it (e.g. those rendered in the user-agent shadow tree created by the text input).\n\n";
// This behavior is important because ATs like HoverText won't highlight the text inside the input if we return the wrong
// element (e.g. a div inside the UA shadow tree created by <input type="text">).
if (window.accessibilityController) {
window.jsTestIsAsync = true;
var hitTestResult;
setTimeout(async function() {
var rootElement = accessibilityController.rootElement;
await waitForFrameGeometryReady();
const rect = document.getElementById("text-input").getBoundingClientRect();
const horizontalMidpoint = rect.left + rect.width / 2;
const verticalMidpoint = rect.top + rect.height / 2;
hitTestResult = accessibilityController.elementAtPoint(horizontalMidpoint, verticalMidpoint);
output += expect("hitTestResult.role.toLowerCase().includes('textfield')", "true");
debug(output);
finishJSTest();
}, 0);
}
</script>
</body>
</html>