summaryrefslogtreecommitdiff
path: root/dom/events/test/test_bug422132.html
blob: bceeb79e8f5c5888c269d12e4eaa1461f919cfcd (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=422132
-->
<head>
  <title>Test for Bug 422132</title>
  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=422132">Mozilla Bug 422132</a>
<p id="display"></p>
<div id="target" style="font-size: 0; width: 200px; height: 200px; overflow: auto;">
  <div style="width: 1000px; height: 1000px;"></div>
</div>
<div id="content" style="display: none">
  
</div>
<pre id="test">
<script class="testbody" type="text/javascript">

/** Test for Bug 422132 **/

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
  SpecialPowers.pushPrefEnv({
    "set":[["general.smoothScroll", false],
           ["mousewheel.min_line_scroll_amount", 1],
           ["mousewheel.system_scroll_override_on_root_content.enabled", false],
           ["mousewheel.transaction.timeout", 100000]]}, runTests)}, window);

function runTests()
{
  var target = document.getElementById("target");

  var scrollLeft = target.scrollLeft;
  var scrollTop = target.scrollTop;

  var tests = [
    {
      prepare: function() {
        scrollLeft = target.scrollLeft;
        scrollTop = target.scrollTop;
      },
      event: {
        deltaMode: WheelEvent.DOM_DELTA_PIXEL,
        deltaX: 0.5,
        deltaY: 0.5,
        lineOrPageDeltaX: 0,
        lineOrPageDeltaY: 0
      },
    }, {
      event: {
        deltaMode: WheelEvent.DOM_DELTA_PIXEL,
        deltaX: 0.5,
        deltaY: 0.5,
        lineOrPageDeltaX: 0,
        lineOrPageDeltaY: 0
      },
      check: function() {
        is(target.scrollLeft - scrollLeft, 1,
           "not scrolled to right by 0.5px delta value with pending 0.5px delta");
        is(target.scrollTop - scrollTop, 1,
           "not scrolled to bottom by 0.5px delta value with pending 0.5px delta");
      },
    }, {
      prepare: function() {
        scrollLeft = target.scrollLeft;
        scrollTop = target.scrollTop;
      },
      event: {
        deltaMode: WheelEvent.DOM_DELTA_LINE,
        deltaX: 0.5,
        deltaY: 0.5,
        lineOrPageDeltaX: 0,
        lineOrPageDeltaY: 0
      },
    }, {
      event: {
        deltaMode: WheelEvent.DOM_DELTA_LINE,
        deltaX: 0.5,
        deltaY: 0.5,
        lineOrPageDeltaX: 1,
        lineOrPageDeltaY: 1
      },
      check: function() {
        is(target.scrollLeft - scrollLeft, 1,
           "not scrolled to right by 0.5 line delta value with pending 0.5 line delta");
        is(target.scrollTop - scrollTop, 1,
           "not scrolled to bottom by 0.5 line delta value with pending 0.5 line delta");
      }
    }
  ];

  var nextTest = function() {
    var test = tests.shift();
    if (test.prepare) {
      test.prepare();
    }

    sendWheelAndPaint(target, 10, 10, test.event, function() {
      if (test.check) {
        test.check();
      }
      if (tests.length == 0) {
        SimpleTest.finish();
        return;
      }

      setTimeout(nextTest, 0);
    });
  }

  nextTest();
}

</script>
</pre>
</body>
</html>