summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_no_scalable_with_initial_scale.html
blob: 7280a260068b8c842323b0e41aa8f3e93bb4e597 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, minimum-scale=0.25, initial-scale=0.5, user-scalable=no">
  <title>Tests that the layout viewport is not expanted to the minimum scale size if user-scalable=no is specified</title>
  <script type="application/javascript" src="apz_test_utils.js"></script>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
  <style>
    html,body {
      overflow: hidden;
      margin: 0;
    }
    div {
      position: absolute;
    }
  </style>
</head>
<body>
  <div style="width: 400%; height: 400%; background: red;"></div>
  <div style="width: 100%; height: 100%; background-color: blue"></div>
  <script type="application/javascript">
    const utils = SpecialPowers.getDOMWindowUtils(window);

    async function test(testDriver) {
      utils.scrollToVisual(100, 0, utils.UPDATE_TYPE_MAIN_THREAD,
                           utils.SCROLL_MODE_INSTANT);

      let receivedScrollEvent = false;
      window.visualViewport.addEventListener("scroll", () => {
        receivedScrollEvent = true;
      }, { once: true });

      await waitUntilApzStable();

      // Waits two frames to get a chance to deliver scroll events.
      await promiseFrame();
      await promiseFrame();

      ok(!receivedScrollEvent, "Scroll should never happen");
      is(visualViewport.offsetLeft, 0,
         "The visual viewport offset should not be moved");
    }

    waitUntilApzStable().then(test).then(subtestDone, subtestFailed);
  </script>
</body>
</html>