Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=946632
5 -->
6 <head>
7 <title>Test for bug 946632 - propagate mouse-wheel vertical scroll events to container</title>
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11 <style>
12 .scrollable {
13 overflow: scroll;
14 height: 200px;
15 width: 200px;
16 }
17 input {
18 font-size: 72px;
19 height: 20px;
20 width: 20px;
21 }
22 </style>
23 </head>
24 <body>
25 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=946632">Mozilla Bug 946632</a>
26 <p id="display"></p>
27 <div id="container" class="scrollable">
28 <input value="value">
29 x<br>x<br>x<br>x<br>x<br>x<br>x<br>x<br>x<br>x<br>x<br>x<br>x<br>x<br>x<br>x<br>x<br>x<br>
30 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
31 </div>
32 <div id="content" style="display: none">
34 </div>
35 <pre id="test">
36 <script type="application/javascript">
38 SimpleTest.waitForExplicitFinish();
39 SimpleTest.waitForFocus(runTests, window);
41 var input = document.querySelector("input");
42 var container = document.querySelector("#container");
44 function prepare(check)
45 {
46 container.scrollTop = 0;
47 container.scrollLeft = 0;
48 input.scrollTop = 0;
49 input.scrollLeft = 0;
50 container.style.display='none';
51 container.getBoundingClientRect();
52 container.style.display='';
53 container.getBoundingClientRect();
54 scrollHandler = function(event) {
55 window.removeEventListener("scroll", arguments.callee, true);
56 event.stopPropagation();
57 check(event)
58 setTimeout(nextTest,0);
59 };
60 window.addEventListener("scroll", scrollHandler, true);
61 }
63 var tests = [
64 {
65 check: function(event) {
66 is(event.target, container, "<input> vertical line scroll targets container");
67 ok(container.scrollTop > 0, "<input> vertical line scroll container.scrollTop");
68 is(container.scrollLeft, 0, "<input> vertical line scroll container.scrollLeft");
69 is(input.scrollTop, 0, "<input> horizontal line scroll input.scrollTop");
70 is(input.scrollLeft, 0, "<input> horizontal line scroll input.scrollLeft");
71 },
72 test: function() {
73 synthesizeWheel(input, 5, 5, { deltaMode: WheelEvent.DOM_DELTA_LINE,
74 deltaY: 1.0, lineOrPageDeltaY: 1 });
75 }
76 },
77 {
78 check: function(event) {
79 is(event.target, input, "<input> horizontal line scroll targets <input>");
80 is(input.scrollTop, 0, "<input> horizontal line scroll input.scrollTop");
81 ok(input.scrollLeft > 0, "<input> horizontal line scroll input.scrollLeft");
82 is(container.scrollTop, 0, "<input> horizontal line scroll container.scrollTop");
83 is(container.scrollLeft, 0, "<input> horizontal line scroll container.scrollLeft");
84 },
85 test: function() {
86 synthesizeWheel(input, 5, 5, { deltaMode: WheelEvent.DOM_DELTA_LINE,
87 deltaX: 1.0, lineOrPageDeltaX: 1 });
88 }
89 },
90 {
91 check: function(event) {
92 is(event.target, container, "<input> vertical page scroll targets container");
93 ok(container.scrollTop > 0, "<input> vertical line scroll container.scrollTop");
94 is(container.scrollLeft, 0, "<input> vertical line scroll container.scrollLeft");
95 is(input.scrollTop, 0, "<input> vertical page scroll input.scrollTop");
96 is(input.scrollLeft, 0, "<input> vertical page scroll input.scrollLeft");
97 },
98 test: function() {
99 synthesizeWheel(input, 5, 5, { deltaMode: WheelEvent.DOM_DELTA_PAGE,
100 deltaY: 1.0, lineOrPageDeltaY: 1 });
101 }
102 },
103 {
104 check: function(event) {
105 is(event.target, input, "<input> horizontal page scroll targets <input>");
106 is(input.scrollTop, 0, "<input> horizontal page scroll input.scrollTop");
107 ok(input.scrollLeft > 0, "<input> horizontal page scroll input.scrollLeft");
108 is(container.scrollTop, 0, "<input> horizontal page scroll container.scrollTop");
109 is(container.scrollLeft, 0, "<input> horizontal page scroll container.scrollLeft");
110 },
111 test: function() {
112 synthesizeWheel(input, 5, 5, { deltaMode: WheelEvent.DOM_DELTA_PAGE,
113 deltaX: 1.0, lineOrPageDeltaX: 1 });
114 }
115 },
116 ];
118 var i = 0;
119 function nextTest()
120 {
121 if (i == tests.length) {
122 SimpleTest.finish();
123 return;
124 }
125 var test = tests[i];
126 ++i;
127 prepare(test.check);
128 test.test();
129 }
131 function runTests()
132 {
133 nextTest();
134 }
136 </script>
137 </pre>
138 </body>
139 </html>