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
|
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=511075
-->
<head>
<title>Test for Bug 511075</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style>
#scroller {
border: 1px solid black;
}
</style>
</head>
<body onload="runTests()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=511075">Mozilla Bug 511075</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 511075 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
var tests = [
function() {
ok(true, "Setting location.hash should scroll.");
nextTest();
// Click the top scroll arrow.
var x = scroller.getBoundingClientRect().width - 5;
var y = 5;
// On MacOSX the top scroll arrow can be below the slider just above
// the bottom scroll arrow.
if (navigator.platform.indexOf("Mac") >= 0)
y = scroller.getBoundingClientRect().height - 40;
synthesizeMouse(scroller, x, y, { type : "mousedown" }, window);
synthesizeMouse(scroller, x, y, { type: "mouseup" }, window);
},
function() {
ok(true, "Clicking the top scroll arrow should scroll.");
nextTest();
// Click the bottom scroll arrow.
var x = scroller.getBoundingClientRect().width - 5;
var y = scroller.getBoundingClientRect().height - 25;
synthesizeMouse(scroller, x, y, { type : "mousedown" }, window);
synthesizeMouse(scroller, x, y, { type: "mouseup" }, window);
},
function() {
ok(true, "Clicking the bottom scroll arrow should scroll.");
nextTest();
// Click the scrollbar.
var x = scroller.getBoundingClientRect().width - 5;
synthesizeMouse(scroller, x, 40, { type : "mousedown" }, window);
synthesizeMouse(scroller, x, 40, { type: "mouseup" }, window);
},
function() {
ok(true, "Clicking the scrollbar should scroll");
nextTest();
// Click the scrollbar.
var x = scroller.getBoundingClientRect().width - 5;
var y = scroller.getBoundingClientRect().height - 50;
synthesizeMouse(scroller, x, y, { type : "mousedown" }, window);
synthesizeMouse(scroller, x, y, { type: "mouseup" }, window);
},
function() {
scroller.onscroll = null;
ok(true, "Clicking the scrollbar should scroll");
finish();
}
];
document.onmousedown = function () { return false; };
document.onmouseup = function () { return true; };
var scroller;
var timer = 0;
function failure() {
ok(false, scroller.onscroll + " did not run!");
scroller.onscroll = null;
finish();
}
function nextTest() {
clearTimeout(timer);
scroller.onscroll = tests.shift();
timer = setTimeout(failure, 2000);
}
function runTests() {
scroller = document.getElementById("scroller");
nextTest();
window.location.hash = "initialPosition";
}
function finish() {
document.onmousedown = null;
document.onmouseup = null;
clearTimeout(timer);
window.location.hash = "topPosition";
SimpleTest.finish();
}
</script>
</pre>
<div id="scroller" style="overflow: scroll; width: 100px; height: 150px;">
<a id="topPosition" name="topPosition">top</a>
<div style="width: 20000px; height: 20000px;"></div>
<a id="initialPosition" name="initialPosition">initialPosition</a>
<div style="width: 20000px; height: 20000px;"></div>
</div>
</body>
</html>
|