1
0
Fork 0
firefox/dom/tests/mochitest/general/test_focus_scrollchildframe.html
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

32 lines
1.1 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test for using TAB to move focus and scroll into view</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
</head>
<body onload="doTest()">
<p id="display"></p>
<div id="content" style="display: none"></div>
<script>
function doTest() {
var canTabMoveFocusToRootElement =
!SpecialPowers.getBoolPref("dom.disable_tab_focus_to_root_element");
document.getElementById("button").focus();
const iframe = document.querySelector("iframe");
is(window.scrollY, 0, "Scrolled position initially 0");
synthesizeKey("KEY_Tab");
is(document.activeElement, iframe, "Focus moved to the iframe");
if (canTabMoveFocusToRootElement) {
ok(window.scrollY > 200, "Scrolled child frame into view");
} else {
is(window.scrollY, 0, "Scrolled position remained the same");
}
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
</script>
<button id="button">B</button><br><iframe style="margin-top:10000px;height:400px"></iframe>
</body>
</html>