Bug 1172648 - Full-stack APZ mochitest for bug 1151667. r=kats

--HG--
extra : rebase_source : fbdd34c96aee64b0d8c3effc1c8ba39f7ae33418
This commit is contained in:
Botond Ballo 2015-06-08 10:55:38 -04:00
Родитель 753923ab23
Коммит 3bc2b3696f
4 изменённых файлов: 83 добавлений и 2 удалений

Просмотреть файл

@ -65,10 +65,22 @@ function synthesizeNativeWheelAndWaitForObserver(aElement, aX, aY, aDeltaX, aDel
// Synthesizes a native mousewheel event and invokes the callback once the
// wheel event is dispatched to the window. See synthesizeNativeWheel for
// details on the parameters.
function synthesizeNativeWheelAndWaitForEvent(aElement, aX, aY, aDeltaX, aDeltaY, aCallback) {
function synthesizeNativeWheelAndWaitForWheelEvent(aElement, aX, aY, aDeltaX, aDeltaY, aCallback) {
window.addEventListener("wheel", function wheelWaiter(e) {
window.removeEventListener("wheel", wheelWaiter);
setTimeout(aCallback, 0);
});
return synthesizeNativeWheel(aElement, aX, aY, aDeltaX, aDeltaY);
}
// Synthesizes a native mousewheel event and invokes the callback once the
// first resulting scroll event is dispatched to the window.
// See synthesizeNativeWheel for details on the parameters.
function synthesizeNativeWheelAndWaitForScrollEvent(aElement, aX, aY, aDeltaX, aDeltaY, aCallback) {
var useCapture = true; // scroll events don't always bubble
window.addEventListener("scroll", function scrollWaiter(e) {
window.removeEventListener("scroll", scrollWaiter, useCapture);
setTimeout(aCallback, 0);
}, useCapture);
return synthesizeNativeWheel(aElement, aX, aY, aDeltaX, aDeltaY);
}

Просмотреть файл

@ -11,3 +11,5 @@ skip-if = toolkit != 'gonk' # bug 991198
skip-if = toolkit != 'gonk' # bug 991198
[test_wheel_scroll.html]
skip-if = (os == 'android') || (os == 'b2g') || (buildapp == 'mulet') # wheel events not supported on mobile; see bug 1164274 for mulet
[test_bug1151667.html]
skip-if = (os == 'android') || (os == 'b2g') # wheel events not supported on mobile

Просмотреть файл

@ -0,0 +1,67 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1151667
-->
<head>
<title>Test for Bug 1151667</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="apz_test_native_event_utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style>
#subframe {
margin-top: 100px;
height: 500px;
width: 500px;
overflow: scroll;
}
#subframe-content {
height: 1000px;
width: 500px;
/* the background is so that we can see it scroll*/
background: repeating-linear-gradient(#EEE, #EEE 100px, #DDD 100px, #DDD 200px);
}
#page-content {
height: 5000px;
width: 500px;
}
</style>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1151667">Mozilla Bug 1151667</a>
<p id="display"></p>
<div id="subframe">
<!-- This makes sure the subframe is scrollable -->
<div id="subframe-content"></div>
</div>
<!-- This makes sure the page is also scrollable, so it (rather than the subframe)
is considered the primary async-scrollable frame, and so the subframe isn't
layerized upon page load. -->
<div id="page-content"></div>
<pre id="test">
<script type="application/javascript;version=1.7">
function startTest() {
var subframe = document.getElementById('subframe');
var scale = window.devicePixelRatio;
var rect = subframe.getBoundingClientRect();
var x = (rect.left + 100) * scale;
var y = (rect.top + 150) * scale;
synthesizeNativeWheelAndWaitForScrollEvent(subframe, x, y, 0, -10, continueTest);
}
function continueTest() {
var subframe = document.getElementById('subframe');
is(subframe.scrollTop > 0, true, "We should have scrolled the subframe down");
is(document.documentElement.scrollTop, 0, "We should not have scrolled the page");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(startTest, window);
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -78,7 +78,7 @@ document.getElementById("scrollbox").addEventListener("wheel", function (e) {
function* runTest() {
var content = document.getElementById('content');
for (i = 0; i < 300; i++) { // enough iterations that we would scroll to the bottom of 'content'
yield synthesizeNativeWheelAndWaitForEvent(content, 100, 150, 0, -5, continueTest);
yield synthesizeNativeWheelAndWaitForWheelEvent(content, 100, 150, 0, -5, continueTest);
}
var scrollbox = document.getElementById('scrollbox');
is(content.scrollTop > 0, true, "We should have scrolled down somewhat");