summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/test_bug1277814.html
blob: 8772864688dd751b4bfa72151394d004ee33bd78 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1277814
-->
<head>
  <meta charset="utf-8">
  <title>Test for Bug 1277814</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
  <script type="application/javascript" src="apz_test_utils.js"></script>
  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <script type="application/javascript">
    function* test(testDriver) {
      // Trigger the buggy scenario
      var subframe = document.getElementById('bug1277814-div');
      subframe.classList.add('a');

      // The transform change is animated, so let's step through 1s of animation
      var utils = SpecialPowers.getDOMWindowUtils(window);
      for (var i = 0; i < 60; i++) {
        utils.advanceTimeAndRefresh(16);
      }
      utils.restoreNormalRefresh();

      // Wait for the layer tree with any updated dispatch-to-content region to
      // get pushed over to the APZ
      yield waitForAllPaints(function() {
        flushApzRepaints(testDriver);
      });

      // Trigger layerization of the subframe by scrolling the wheel over it
      yield moveMouseAndScrollWheelOver(subframe, 10, 10, testDriver);

      // Give APZ the chance to compute a displayport, and content
      // to render based on it.
      yield waitForApzFlushedRepaints(testDriver);

      // Examine the content-side APZ test data
      var contentTestData = utils.getContentAPZTestData();

      // Test that the scroll frame for the div 'bug1277814-div' appears in
      // the APZ test data. The bug this test is for causes the displayport
      // calculation for this scroll frame to go wrong, causing it not to
      // become layerized.
      contentTestData = convertTestData(contentTestData);
      var foundIt = false;
      for (var seqNo in contentTestData.paints) {
        var paint = contentTestData.paints[seqNo];
        for (var scrollId in paint) {
          var scrollFrame = paint[scrollId];
          if ('contentDescription' in scrollFrame &&
              scrollFrame['contentDescription'].includes('bug1277814-div')) {
            foundIt = true;
          }
        }
      }
      SimpleTest.ok(foundIt, "expected to find APZ test data for bug1277814-div");
    }

    if (isApzEnabled()) {
      SimpleTest.waitForExplicitFinish();

      pushPrefs([["apz.test.logging_enabled", true]])
        .then(waitUntilApzStable)
        .then(runContinuation(test))
        .then(SimpleTest.finish);
    }
  </script>
  <style>
    #bug1277814-div
    {
      position: absolute;
      left: 0;
      top: 0;
      padding: .5em;
      overflow: auto;
      color: white;
      background: green;
      max-width: 30em;
      max-height: 6em;
      visibility: hidden;
      transform: scaleY(0);
      transition: transform .15s ease-out, visibility 0s ease .15s;
    }
    #bug1277814-div.a
    {
      visibility: visible;
      transform: scaleY(1);
      transition: transform .15s ease-out;
    }
  </style>
</head>
<body>
  <!-- Use a unique id because we'll be checking for it in the content
       description logged in the APZ test data -->
  <div id="bug1277814-div">
    CoolCmd<br>CoolCmd<br>CoolCmd<br>CoolCmd<br>
    CoolCmd<br>CoolCmd<br>CoolCmd<br>CoolCmd<br>
    CoolCmd<br>CoolCmd<br>CoolCmd<br>CoolCmd<br>
    CoolCmd<br>CoolCmd<br>CoolCmd<br>CoolCmd<br>
    CoolCmd<br>CoolCmd<br>CoolCmd<br>CoolCmd<br>
  <button>click me</button>
</body>
</html>