2012-09-05 14:29:15 +04:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=785588
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 785588 --- ordering of scroll-related events</title>
|
2019-04-16 06:50:44 +03:00
|
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
2012-09-05 14:29:15 +04:00
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=785588">Mozilla Bug 785588</a>
|
|
|
|
<div id="content">
|
|
|
|
<div id="d" style="border:2px solid black; width:100px; height:100px; overflow:auto">
|
|
|
|
<div id="inner" style="height:200px;">Hello</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script>
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
var smoothScrollPref = "general.smoothScroll";
|
|
|
|
|
|
|
|
var d = document.getElementById("d");
|
|
|
|
d.scrollTop = 0;
|
|
|
|
var inner = document.getElementById("inner");
|
|
|
|
|
|
|
|
var state = "initial";
|
|
|
|
|
|
|
|
function onFrame() {
|
2018-01-30 02:22:47 +03:00
|
|
|
is(state, "didOnScroll", "Must have got scroll event already");
|
2012-09-05 14:29:15 +04:00
|
|
|
state = "didOnFrame";
|
2018-01-30 02:22:47 +03:00
|
|
|
SimpleTest.finish();
|
2012-09-05 14:29:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function onScroll() {
|
2018-01-30 02:22:47 +03:00
|
|
|
is(state, "initial", "Must be in initial state");
|
2012-09-05 14:29:15 +04:00
|
|
|
ok(d.scrollTop > 0, "Must have scrolled by some amount (got " + d.scrollTop + ")");
|
2018-01-30 02:22:47 +03:00
|
|
|
state = "didOnScroll";
|
2012-09-05 14:29:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function doTest() {
|
|
|
|
window.getSelection().collapse(inner.firstChild, 0);
|
2015-07-14 22:28:58 +03:00
|
|
|
window.requestAnimationFrame(onFrame);
|
2012-09-05 14:29:15 +04:00
|
|
|
d.onscroll = onScroll;
|
2020-09-08 11:12:25 +03:00
|
|
|
d.scroll(0, 100);
|
2012-09-05 14:29:15 +04:00
|
|
|
}
|
|
|
|
|
2015-04-21 19:44:43 +03:00
|
|
|
function prepareTest() {
|
|
|
|
// Start the test after we've gotten at least one rAF callback, to make sure
|
|
|
|
// that rAF is no longer throttled. (See bug 1145439.)
|
2015-07-14 22:28:58 +03:00
|
|
|
window.requestAnimationFrame(function() {
|
2015-04-21 19:44:43 +03:00
|
|
|
SpecialPowers.pushPrefEnv({"set":[[smoothScrollPref, false]]}, doTest);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForFocus(prepareTest);
|
|
|
|
|
2012-09-05 14:29:15 +04:00
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|