1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/xul/test/test_bug511075.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,120 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=511075 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 511075</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.14 + <style> 1.15 + #scroller { 1.16 + border: 1px solid black; 1.17 + } 1.18 + </style> 1.19 +</head> 1.20 +<body onload="runTests()"> 1.21 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=511075">Mozilla Bug 511075</a> 1.22 +<p id="display"></p> 1.23 +<div id="content" style="display: none"> 1.24 + 1.25 +</div> 1.26 +<pre id="test"> 1.27 +<script type="application/javascript"> 1.28 + 1.29 +/** Test for Bug 511075 **/ 1.30 + 1.31 +SimpleTest.waitForExplicitFinish(); 1.32 + 1.33 +var tests = [ 1.34 + function() { 1.35 + ok(true, "Setting location.hash should scroll."); 1.36 + nextTest(); 1.37 + // Click the top scroll arrow. 1.38 + var x = scroller.getBoundingClientRect().width - 5; 1.39 + var y = 5; 1.40 + // On MacOSX the top scroll arrow can be below the slider just above 1.41 + // the bottom scroll arrow. 1.42 + if (navigator.platform.indexOf("Mac") >= 0) 1.43 + y = scroller.getBoundingClientRect().height - 40; 1.44 + synthesizeMouse(scroller, x, y, { type : "mousedown" }, window); 1.45 + synthesizeMouse(scroller, x, y, { type: "mouseup" }, window); 1.46 + }, 1.47 + function() { 1.48 + ok(true, "Clicking the top scroll arrow should scroll."); 1.49 + nextTest(); 1.50 + // Click the bottom scroll arrow. 1.51 + var x = scroller.getBoundingClientRect().width - 5; 1.52 + var y = scroller.getBoundingClientRect().height - 25; 1.53 + synthesizeMouse(scroller, x, y, { type : "mousedown" }, window); 1.54 + synthesizeMouse(scroller, x, y, { type: "mouseup" }, window); 1.55 + }, 1.56 + function() { 1.57 + ok(true, "Clicking the bottom scroll arrow should scroll."); 1.58 + nextTest(); 1.59 + // Click the scrollbar. 1.60 + var x = scroller.getBoundingClientRect().width - 5; 1.61 + synthesizeMouse(scroller, x, 40, { type : "mousedown" }, window); 1.62 + synthesizeMouse(scroller, x, 40, { type: "mouseup" }, window); 1.63 + }, 1.64 + function() { 1.65 + ok(true, "Clicking the scrollbar should scroll"); 1.66 + nextTest(); 1.67 + // Click the scrollbar. 1.68 + var x = scroller.getBoundingClientRect().width - 5; 1.69 + var y = scroller.getBoundingClientRect().height - 50; 1.70 + synthesizeMouse(scroller, x, y, { type : "mousedown" }, window); 1.71 + synthesizeMouse(scroller, x, y, { type: "mouseup" }, window); 1.72 + }, 1.73 + function() { 1.74 + scroller.onscroll = null; 1.75 + ok(true, "Clicking the scrollbar should scroll"); 1.76 + finish(); 1.77 + } 1.78 +]; 1.79 + 1.80 +document.onmousedown = function () { return false; }; 1.81 +document.onmouseup = function () { return true; }; 1.82 + 1.83 + 1.84 +var scroller; 1.85 +var timer = 0; 1.86 + 1.87 +function failure() { 1.88 + ok(false, scroller.onscroll + " did not run!"); 1.89 + scroller.onscroll = null; 1.90 + finish(); 1.91 +} 1.92 + 1.93 +function nextTest() { 1.94 + clearTimeout(timer); 1.95 + scroller.onscroll = tests.shift(); 1.96 + timer = setTimeout(failure, 2000); 1.97 +} 1.98 + 1.99 +function runTests() { 1.100 + scroller = document.getElementById("scroller"); 1.101 + nextTest(); 1.102 + window.location.hash = "initialPosition"; 1.103 +} 1.104 + 1.105 +function finish() { 1.106 + document.onmousedown = null; 1.107 + document.onmouseup = null; 1.108 + clearTimeout(timer); 1.109 + window.location.hash = "topPosition"; 1.110 + SimpleTest.finish(); 1.111 +} 1.112 + 1.113 + 1.114 +</script> 1.115 +</pre> 1.116 +<div id="scroller" style="overflow: scroll; width: 100px; height: 150px;"> 1.117 +<a id="topPosition" name="topPosition">top</a> 1.118 +<div style="width: 20000px; height: 20000px;"></div> 1.119 +<a id="initialPosition" name="initialPosition">initialPosition</a> 1.120 +<div style="width: 20000px; height: 20000px;"></div> 1.121 +</div> 1.122 +</body> 1.123 +</html>