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