summaryrefslogtreecommitdiffstats
path: root/gfx/tests/reftest/picture-caching-on-async-zoom.html
blob: f32ab02d3b52eab8172970ffa7556305eae6ee68 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<html class="reftest-wait">
 <head>
  <meta name="viewport" content="width=device-width"/>
  <title>The Grid in an overflowing div</title>
  <style type="text/css">
    html, body {
        padding: 0;
        border: 0;
        margin: 0;
        scrollbar-width: none;
    }
    table {
        padding: 0;
        margin: 0;
        border-top: none;
        border-left: none;
        border-right: 1px solid black;
        border-bottom: 1px solid black;
    }
    tr {
        padding: 0;
        border: 0;
        margin: 0;
    }
    td {
        /* top border counts as part of height, but
           left border doesn't count as part of width.
           go figure.
        */
        min-height: 99px;
        height: 99px;
        max-height: 99px;
        min-width: 99px;
        width: 99px;
        max-width: 99px;
        padding: 0;
        border-left: 1px solid black;
        border-top: 1px solid black;
        border-right: none;
        border-bottom: none;
        margin: 0;
        font-size: 12px;
        text-align: left;
        vertical-align: top;
        font-family: monospace;
    }
  </style>
 </head>
 <body>
  <div style="color: red">this text is above the scrolling div. the div below is 300x400</div>
  <div id="nest" style="overflow: scroll; scrollbar-width: none; height: 400px; width: 300px">
  <table cellspacing="0" cellpadding="0" border="0">
   <script type="text/javascript">
    var PAGE_SIZE = 2000;
    var GRID_SIZE = 100;

    var cnt = (PAGE_SIZE / GRID_SIZE);
    for (var y = 0; y < cnt; y++) {
        document.writeln( "<tr>" );
        for (var x = 0; x < cnt; x++) {
            var color = ((x + y) % 2) ? "blue" : "red";
            document.writeln( "<td style='background-color: " + color + "'></td>" );
        }
        document.writeln( "</tr>" );
    }
   </script>
  </table>
  </div>
  <div style="color: red">this text is below the scrolling div</div>
  <script>
    if (location.search == "?ref") {
        // In the reference case we use a CSS transform so that we don't use
        // the async-zoom codepath (which is handled differently by WR).
        document.documentElement.setAttribute("style", "transform: scale(1.1); transform-origin: top left");
        document.documentElement.classList.remove("reftest-wait");
    } else {
        // In the test case, we want to first paint the unscaled content, so that
        // WR populates the picture cache. Then we apply an async zoom and paint
        // again for the final snapshot. The bug in this case was that WR wasn't
        // properly invalidating the picture cache tiles and so things would
        // appear incorrectly.
        window.addEventListener("MozAfterPaint", () => {
            document.documentElement.setAttribute("reftest-async-zoom", "1.1");
            document.documentElement.classList.remove("reftest-wait");
        });
    }
  </script>
 </body>
</html>