summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/test_smoothness.html
blob: 88373957a77a493f71d4c788a90c4a97208760b1 (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
<html>
<head>
  <title>Test Frame Uniformity While Scrolling</title>
  <script type="text/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
  <script type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>

  <style>
  #content {
    height: 5000px;
    background: repeating-linear-gradient(#EEE, #EEE 100px, #DDD 100px, #DDD 200px);
  }
  </style>
  <script type="text/javascript">
    var scrollEvents = 100;
    var i = 0;
    var testPref = "gfx.vsync.collect-scroll-transforms";
    // Scroll points
    var x = 100;
    var y = 150;

    SimpleTest.waitForExplicitFinish();
    var utils = _getDOMWindowUtils(window);

    function sendScrollEvent(aRafTimestamp) {
      var scrollDiv = document.getElementById("content");

      if (i < scrollEvents) {
        i++;
        // Scroll diff
        var dx = 0;
        var dy = -10; // Negative to scroll down
        synthesizeNativeWheelAndWaitForWheelEvent(scrollDiv, x, y, dx, dy);
        window.requestAnimationFrame(sendScrollEvent);
      } else {
        // Locally, with silk and apz + e10s, retina 15" mbp usually get ~1.0 - 1.5
        // w/o silk + e10s + apz, I get up to 7. Lower is better.
        // Windows, I get ~3. Values are not valid w/o hardware vsync
        var uniformities = _getDOMWindowUtils().getFrameUniformityTestData();
        for (var j = 0; j < uniformities.layerUniformities.length; j++) {
          var layerResult = uniformities.layerUniformities[j];
          var layerAddr = layerResult.layerAddress;
          var uniformity = layerResult.frameUniformity;
          var msg = "Layer: " + layerAddr.toString(16) + " Uniformity: " + uniformity;
          SimpleTest.ok((uniformity >= 0) && (uniformity < 4.0), msg);
        }
        SimpleTest.finish();
      }
    }

    function startTest() {
      window.requestAnimationFrame(sendScrollEvent);
    }

    window.onload = function() {
      var apzEnabled = SpecialPowers.getBoolPref("layers.async-pan-zoom.enabled");
      if (!apzEnabled) {
        SimpleTest.ok(true, "APZ not enabled, skipping test");
        SimpleTest.finish();
      }

      SpecialPowers.pushPrefEnv({
        "set" : [
          [testPref, true]
        ]
      }, startTest);
    }
    </script>
</head>

<body>
  <div id="content">
  </div>
</body>
</html>