Bug 511075 - The arrows of the scrollbars don't work in hotmail (event.preventDefault() causes clicks on scrollbars to be ignored), r=enn, sr=neil

This commit is contained in:
Olli Pettay 2010-04-12 16:59:16 +03:00
parent 2cba11e996
commit 337d16116e
4 changed files with 126 additions and 2 deletions

View File

@ -74,7 +74,11 @@ nsScrollbarButtonFrame::HandleEvent(nsPresContext* aPresContext,
nsEventStatus* aEventStatus)
{
NS_ENSURE_ARG_POINTER(aEventStatus);
if (nsEventStatus_eConsumeNoDefault == *aEventStatus) {
// If a web page calls event.preventDefault() we still want to
// scroll when scroll arrow is clicked. See bug 511075.
if (!mContent->IsInNativeAnonymousSubtree() &&
nsEventStatus_eConsumeNoDefault == *aEventStatus) {
return NS_OK;
}

View File

@ -454,7 +454,11 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext,
nsEventStatus* aEventStatus)
{
NS_ENSURE_ARG_POINTER(aEventStatus);
if (nsEventStatus_eConsumeNoDefault == *aEventStatus) {
// If a web page calls event.preventDefault() we still want to
// scroll when scroll arrow is clicked. See bug 511075.
if (!mContent->IsInNativeAnonymousSubtree() &&
nsEventStatus_eConsumeNoDefault == *aEventStatus) {
return NS_OK;
}

View File

@ -51,6 +51,7 @@ _TEST_FILES = test_bug381167.xhtml \
window_resizer_element.xul \
test_bug477754.xul \
test_stack.xul \
test_bug511075.html \
test_splitter.xul \
$(NULL)

View File

@ -0,0 +1,115 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=511075
-->
<head>
<title>Test for Bug 511075</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<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();
var tests = [
function() {
ok(true, "Setting location.hash should scroll.");
nextTest();
// Click the top scroll arrow.
var x = scroller.getBoundingClientRect().width - 5;
synthesizeMouse(scroller, x, 5, { type : "mousedown" }, window);
synthesizeMouse(scroller, x, 5, { 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 - 60;
synthesizeMouse(scroller, x, y, { type : "mousedown" }, window);
synthesizeMouse(scroller, x, y, { type: "mouseup" }, window);
},
function() {
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>