|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=511075 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 511075</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 #scroller { |
|
13 border: 1px solid black; |
|
14 } |
|
15 </style> |
|
16 </head> |
|
17 <body onload="runTests()"> |
|
18 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=511075">Mozilla Bug 511075</a> |
|
19 <p id="display"></p> |
|
20 <div id="content" style="display: none"> |
|
21 |
|
22 </div> |
|
23 <pre id="test"> |
|
24 <script type="application/javascript"> |
|
25 |
|
26 /** Test for Bug 511075 **/ |
|
27 |
|
28 SimpleTest.waitForExplicitFinish(); |
|
29 |
|
30 var tests = [ |
|
31 function() { |
|
32 ok(true, "Setting location.hash should scroll."); |
|
33 nextTest(); |
|
34 // Click the top scroll arrow. |
|
35 var x = scroller.getBoundingClientRect().width - 5; |
|
36 var y = 5; |
|
37 // On MacOSX the top scroll arrow can be below the slider just above |
|
38 // the bottom scroll arrow. |
|
39 if (navigator.platform.indexOf("Mac") >= 0) |
|
40 y = scroller.getBoundingClientRect().height - 40; |
|
41 synthesizeMouse(scroller, x, y, { type : "mousedown" }, window); |
|
42 synthesizeMouse(scroller, x, y, { type: "mouseup" }, window); |
|
43 }, |
|
44 function() { |
|
45 ok(true, "Clicking the top scroll arrow should scroll."); |
|
46 nextTest(); |
|
47 // Click the bottom scroll arrow. |
|
48 var x = scroller.getBoundingClientRect().width - 5; |
|
49 var y = scroller.getBoundingClientRect().height - 25; |
|
50 synthesizeMouse(scroller, x, y, { type : "mousedown" }, window); |
|
51 synthesizeMouse(scroller, x, y, { type: "mouseup" }, window); |
|
52 }, |
|
53 function() { |
|
54 ok(true, "Clicking the bottom scroll arrow should scroll."); |
|
55 nextTest(); |
|
56 // Click the scrollbar. |
|
57 var x = scroller.getBoundingClientRect().width - 5; |
|
58 synthesizeMouse(scroller, x, 40, { type : "mousedown" }, window); |
|
59 synthesizeMouse(scroller, x, 40, { type: "mouseup" }, window); |
|
60 }, |
|
61 function() { |
|
62 ok(true, "Clicking the scrollbar should scroll"); |
|
63 nextTest(); |
|
64 // Click the scrollbar. |
|
65 var x = scroller.getBoundingClientRect().width - 5; |
|
66 var y = scroller.getBoundingClientRect().height - 50; |
|
67 synthesizeMouse(scroller, x, y, { type : "mousedown" }, window); |
|
68 synthesizeMouse(scroller, x, y, { type: "mouseup" }, window); |
|
69 }, |
|
70 function() { |
|
71 scroller.onscroll = null; |
|
72 ok(true, "Clicking the scrollbar should scroll"); |
|
73 finish(); |
|
74 } |
|
75 ]; |
|
76 |
|
77 document.onmousedown = function () { return false; }; |
|
78 document.onmouseup = function () { return true; }; |
|
79 |
|
80 |
|
81 var scroller; |
|
82 var timer = 0; |
|
83 |
|
84 function failure() { |
|
85 ok(false, scroller.onscroll + " did not run!"); |
|
86 scroller.onscroll = null; |
|
87 finish(); |
|
88 } |
|
89 |
|
90 function nextTest() { |
|
91 clearTimeout(timer); |
|
92 scroller.onscroll = tests.shift(); |
|
93 timer = setTimeout(failure, 2000); |
|
94 } |
|
95 |
|
96 function runTests() { |
|
97 scroller = document.getElementById("scroller"); |
|
98 nextTest(); |
|
99 window.location.hash = "initialPosition"; |
|
100 } |
|
101 |
|
102 function finish() { |
|
103 document.onmousedown = null; |
|
104 document.onmouseup = null; |
|
105 clearTimeout(timer); |
|
106 window.location.hash = "topPosition"; |
|
107 SimpleTest.finish(); |
|
108 } |
|
109 |
|
110 |
|
111 </script> |
|
112 </pre> |
|
113 <div id="scroller" style="overflow: scroll; width: 100px; height: 150px;"> |
|
114 <a id="topPosition" name="topPosition">top</a> |
|
115 <div style="width: 20000px; height: 20000px;"></div> |
|
116 <a id="initialPosition" name="initialPosition">initialPosition</a> |
|
117 <div style="width: 20000px; height: 20000px;"></div> |
|
118 </div> |
|
119 </body> |
|
120 </html> |