Commit cfd37ea8 authored by Hiroyuki Ikezoe's avatar Hiroyuki Ikezoe
Browse files

Bug 1520455 - Don't use the minimum scale size on fullscreen state to avoid...

Bug 1520455 - Don't use the minimum scale size on fullscreen state to avoid the layout viewport gets larger than the visual viewport. r=botond

This is a workaround. To properly fix the issue we need to fix both of bug
1516377 and bug 1508177.

Differential Revision: https://phabricator.services.mozilla.com/D17103

--HG--
extra : moz-landing-system : lando
parent a0eb07ee
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width; initial-scale=1.0">
  <title>Tests that layout viewport is not larger than visual viewport on fullscreen</title>
  <script type="application/javascript" src="apz_test_utils.js"></script>
  <script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
  <style>
    body {
      margin: 0;
      padding: 0;
      overflow-x: hidden;
    }
  </style>
</head>
<body>
  <div style="background: blue; width: 100%; height: 100%;"></div>
  <div style="background: red; width: 200%; height: 100px;">overflowed element</div>
  <div id="target" style="background: green; width: 100px; height: 100px;"></div>
  <script type="application/javascript">
    function waitForFullscreenChange() {
      return new Promise(resolve => {
        document.addEventListener("fullscreenchange", resolve);
      });
    }

    async function test(testDriver) {
      target.requestFullscreen();

      await waitForFullscreenChange();

      is(document.fullscreenElement, target,
         "The target element should have been fullscreen-ed");

      // Try to move rightward, but it should NOT happen.
      SpecialPowers.getDOMWindowUtils(window).scrollToVisual(200, 0);

      await waitUntilApzStable();

      is(visualViewport.offsetLeft, 0,
         "The visual viewport offset should never be moved");

      document.exitFullscreen();
    }

    waitUntilApzStable().then(test).then(subtestDone);
  </script>
</body>
</html>
+2 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@
[test_bug1304689-2.html]
[test_bug1464568.html]
[test_frame_reconstruction.html]
[test_fullscreen.html]
  run-if = (os == 'android')
[test_group_mouseevents.html]
  skip-if = (toolkit == 'android') # mouse events not supported on mobile
[test_group_pointerevents.html]
+33 −0
Original line number Diff line number Diff line
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript" src="apz_test_utils.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <script type="application/javascript">
    if (isApzEnabled()) {
      SimpleTest.waitForExplicitFinish();

      const subtests = [
        { file: "helper_fullscreen.html",
          prefs: [
            ["apz.test.logging_enabled", true],
            ["full-screen-api.allow-trusted-requests-only", false],
            ["dom.visualviewport.enabled", true],
          ],
        },
      ];
      // Run the actual test in its own window, because it requires that the
      // root APZC be scrollable. Mochitest pages themselves often run
      // inside an iframe which means we have no control over the root APZC.
      window.onload = () => {
        runSubtestsSeriallyInFreshWindows(subtests)
        .then(SimpleTest.finish, SimpleTest.finish);
      };
    }
  </script>
</head>
<body>
</body>
</html>
+6 −0
Original line number Diff line number Diff line
@@ -5493,6 +5493,12 @@ void ScrollFrameHelper::UpdateMinimumScaleSize(

  Document* doc = pc->Document();
  MOZ_ASSERT(doc, "The document should be valid");
  if (doc->GetFullscreenElement()) {
    // Don't use the minimum scale size in the case of fullscreen state.
    // FIXME: 1508177: We will no longer need this.
    return;
  }

  nsViewportInfo viewportInfo = doc->GetViewportInfo(displaySize);
  // FIXME: Bug 1520081 - Drop this check. We should use the minimum-scale size
  // even if the minimum-scale size is greater than 1.0.