Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Errors
- This test failed 5 times in the preceding 30 days. quicksearch this test
- Manifest: dom/tests/mochitest/general/mochitest.toml
<!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>