Source code
Revision control
Copy as Markdown
Other Tools
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Tests that zoomToFocuedInput doesn't reset the scroll position for nested position:fixed element</title>
  <script src="apz_test_native_event_utils.js"></script>
  <script src="apz_test_utils.js"></script>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
  <style>
  .container, textarea {
    bottom: 10px;
    height: 100px;
    width: calc(100% - 30px);
    position: fixed;
  }
  html {
    height: 500vh;
  }
  </style>
</head>
<body>
<div class="container">
  <textarea></textarea>
</div>
<script>
async function test() {
  window.scrollTo(0, document.documentElement.scrollHeight);
  const expectedScrollPosition = window.scrollY;
  document.querySelector("textarea").focus();
  is(window.scrollY, expectedScrollPosition);
  SpecialPowers.DOMWindowUtils.zoomToFocusedInput();
  await promiseApzFlushedRepaints();
  is(window.scrollY, expectedScrollPosition);
}
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
</script>
</body>
</html>