1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/events/test/test_bug946632.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,139 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=946632 1.8 +--> 1.9 +<head> 1.10 + <title>Test for bug 946632 - propagate mouse-wheel vertical scroll events to container</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 + .scrollable { 1.16 + overflow: scroll; 1.17 + height: 200px; 1.18 + width: 200px; 1.19 + } 1.20 + input { 1.21 + font-size: 72px; 1.22 + height: 20px; 1.23 + width: 20px; 1.24 + } 1.25 + </style> 1.26 +</head> 1.27 +<body> 1.28 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=946632">Mozilla Bug 946632</a> 1.29 +<p id="display"></p> 1.30 +<div id="container" class="scrollable"> 1.31 + <input value="value"> 1.32 + 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> 1.33 + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 1.34 +</div> 1.35 +<div id="content" style="display: none"> 1.36 + 1.37 +</div> 1.38 +<pre id="test"> 1.39 +<script type="application/javascript"> 1.40 + 1.41 +SimpleTest.waitForExplicitFinish(); 1.42 +SimpleTest.waitForFocus(runTests, window); 1.43 + 1.44 +var input = document.querySelector("input"); 1.45 +var container = document.querySelector("#container"); 1.46 + 1.47 +function prepare(check) 1.48 +{ 1.49 + container.scrollTop = 0; 1.50 + container.scrollLeft = 0; 1.51 + input.scrollTop = 0; 1.52 + input.scrollLeft = 0; 1.53 + container.style.display='none'; 1.54 + container.getBoundingClientRect(); 1.55 + container.style.display=''; 1.56 + container.getBoundingClientRect(); 1.57 + scrollHandler = function(event) { 1.58 + window.removeEventListener("scroll", arguments.callee, true); 1.59 + event.stopPropagation(); 1.60 + check(event) 1.61 + setTimeout(nextTest,0); 1.62 + }; 1.63 + window.addEventListener("scroll", scrollHandler, true); 1.64 +} 1.65 + 1.66 +var tests = [ 1.67 + { 1.68 + check: function(event) { 1.69 + is(event.target, container, "<input> vertical line scroll targets container"); 1.70 + ok(container.scrollTop > 0, "<input> vertical line scroll container.scrollTop"); 1.71 + is(container.scrollLeft, 0, "<input> vertical line scroll container.scrollLeft"); 1.72 + is(input.scrollTop, 0, "<input> horizontal line scroll input.scrollTop"); 1.73 + is(input.scrollLeft, 0, "<input> horizontal line scroll input.scrollLeft"); 1.74 + }, 1.75 + test: function() { 1.76 + synthesizeWheel(input, 5, 5, { deltaMode: WheelEvent.DOM_DELTA_LINE, 1.77 + deltaY: 1.0, lineOrPageDeltaY: 1 }); 1.78 + } 1.79 + }, 1.80 + { 1.81 + check: function(event) { 1.82 + is(event.target, input, "<input> horizontal line scroll targets <input>"); 1.83 + is(input.scrollTop, 0, "<input> horizontal line scroll input.scrollTop"); 1.84 + ok(input.scrollLeft > 0, "<input> horizontal line scroll input.scrollLeft"); 1.85 + is(container.scrollTop, 0, "<input> horizontal line scroll container.scrollTop"); 1.86 + is(container.scrollLeft, 0, "<input> horizontal line scroll container.scrollLeft"); 1.87 + }, 1.88 + test: function() { 1.89 + synthesizeWheel(input, 5, 5, { deltaMode: WheelEvent.DOM_DELTA_LINE, 1.90 + deltaX: 1.0, lineOrPageDeltaX: 1 }); 1.91 + } 1.92 + }, 1.93 + { 1.94 + check: function(event) { 1.95 + is(event.target, container, "<input> vertical page scroll targets container"); 1.96 + ok(container.scrollTop > 0, "<input> vertical line scroll container.scrollTop"); 1.97 + is(container.scrollLeft, 0, "<input> vertical line scroll container.scrollLeft"); 1.98 + is(input.scrollTop, 0, "<input> vertical page scroll input.scrollTop"); 1.99 + is(input.scrollLeft, 0, "<input> vertical page scroll input.scrollLeft"); 1.100 + }, 1.101 + test: function() { 1.102 + synthesizeWheel(input, 5, 5, { deltaMode: WheelEvent.DOM_DELTA_PAGE, 1.103 + deltaY: 1.0, lineOrPageDeltaY: 1 }); 1.104 + } 1.105 + }, 1.106 + { 1.107 + check: function(event) { 1.108 + is(event.target, input, "<input> horizontal page scroll targets <input>"); 1.109 + is(input.scrollTop, 0, "<input> horizontal page scroll input.scrollTop"); 1.110 + ok(input.scrollLeft > 0, "<input> horizontal page scroll input.scrollLeft"); 1.111 + is(container.scrollTop, 0, "<input> horizontal page scroll container.scrollTop"); 1.112 + is(container.scrollLeft, 0, "<input> horizontal page scroll container.scrollLeft"); 1.113 + }, 1.114 + test: function() { 1.115 + synthesizeWheel(input, 5, 5, { deltaMode: WheelEvent.DOM_DELTA_PAGE, 1.116 + deltaX: 1.0, lineOrPageDeltaX: 1 }); 1.117 + } 1.118 + }, 1.119 +]; 1.120 + 1.121 +var i = 0; 1.122 +function nextTest() 1.123 +{ 1.124 + if (i == tests.length) { 1.125 + SimpleTest.finish(); 1.126 + return; 1.127 + } 1.128 + var test = tests[i]; 1.129 + ++i; 1.130 + prepare(test.check); 1.131 + test.test(); 1.132 +} 1.133 + 1.134 +function runTests() 1.135 +{ 1.136 + nextTest(); 1.137 +} 1.138 + 1.139 +</script> 1.140 +</pre> 1.141 +</body> 1.142 +</html>