summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/visual-viewport/helper-resize-event-on-load-overflowing-page.html
blob: c036b16ec87bc7e562c4040ad1923c5a8b483cec (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
<!doctype html>
<html>
    <head>
        <title>Viewport: Resize Event On Load Overflowing Page</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, minimum-scale=1">
        <script>
            var opener = window.opener;
            var numViewResizes = 0;
            window.visualViewport.addEventListener('resize', function() {
                numViewResizes++;
            });

            window.addEventListener('load', function() {
              requestAnimationFrame(function() {
                requestAnimationFrame(
                    opener.t.step_func_done(function() {
                        var isOverlay = opener.calculateScrollbarThickness() == 0;
                        opener.assert_equals(numViewResizes, isOverlay ? 0 : 1);
                    }));
                });
            });
        </script>
        <style>
          html {
            height: 100%;
          }
          body {
              /* Ensure overflow */
              height: 200%;
          }
          #log {
              overflow: auto;
          }
        </style>
    </head>
    <body>
    <h1>Viewport: Resize Event On Load Overflowing Page</h1>
    <h4>
        Test Description: This test ensures that we fire a resize event against
        window.visualViewport if the page has overflow (since this creates a scrollbar
        and thus changes the viewport size).
    </h4>
    <div id="log"></div>
    </body>
</html>