Bug 1433019 - Dispatch scroll events before dispatching animation events. r?mstange,botond
See 7.6. in the section '8.1.4.2 Processing model';
https://html.spec.whatwg.org/multipage/webappapis.html#processing-model-8
Note that this dispatching scroll events should be done after we process
WillRefresh() for FlushType::Style observers since main-thread scroll
animations is one of the FlushType::Style observers, that means it affects
scroll events.
Also test_scroll_event_ordering.html was modified to check scroll events happen
before requestAnimationFrame callbacks.
MozReview-Commit-ID: LuV157XoRkJ
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -1891,20 +1891,20 @@ nsRefreshDriver::Tick(int64_t aNowEpoch,
StopTimer();
return;
}
}
if (i == 1) {
// This is the FlushType::Style case.
+ DispatchScrollEvents();
DispatchAnimationEvents();
DispatchPendingEvents();
RunFrameRequestCallbacks(aNowTime);
- DispatchScrollEvents();
if (mPresContext && mPresContext->GetPresShell()) {
AutoTArray<nsIPresShell*, 16> observers;
observers.AppendElements(mStyleFlushObservers);
for (uint32_t j = observers.Length();
j && mPresContext && mPresContext->GetPresShell(); --j) {
// Make sure to not process observers which might have been removed
// during previous iterations.
--- a/layout/base/tests/test_scroll_event_ordering.html
+++ b/layout/base/tests/test_scroll_event_ordering.html
@@ -24,25 +24,25 @@ var smoothScrollPref = "general.smoothSc
var d = document.getElementById("d");
d.scrollTop = 0;
var inner = document.getElementById("inner");
var state = "initial";
function onFrame() {
- is(state, "initial", "Must be in initial state");
- ok(d.scrollTop > 0, "Must have scrolled by some amount (got " + d.scrollTop + ")");
+ is(state, "didOnScroll", "Must have got scroll event already");
state = "didOnFrame";
+ SimpleTest.finish();
}
function onScroll() {
- is(state, "didOnFrame", "Must have got requestAnimationFrame callback already");
+ is(state, "initial", "Must be in initial state");
ok(d.scrollTop > 0, "Must have scrolled by some amount (got " + d.scrollTop + ")");
- SimpleTest.finish();
+ state = "didOnScroll";
}
function doTest() {
window.getSelection().collapse(inner.firstChild, 0);
window.requestAnimationFrame(onFrame);
d.onscroll = onScroll;
sendKey("DOWN");
}
deleted file mode 100644
--- a/testing/web-platform/meta/html/webappapis/scripting/event-loops/microtask_after_raf.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[microtask_after_raf.html]
- [Microtask execute immediately after script]
- expected: FAIL
-