summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/general/test_focus_scrollchildframe.html
blob: 5bb13002b88057825af617184d085c0e26d40527 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!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>