--- a/dom/animation/test/chrome/test_restyles.html
+++ b/dom/animation/test/chrome/test_restyles.html
@@ -55,16 +55,25 @@ function observeStyling(frameCount, onFr
function ensureElementRemoval(aElement) {
return new Promise(function(resolve) {
aElement.remove();
waitForAllPaintsFlushed(resolve);
});
}
+function waitForWheelEvent(aTarget, centerX, centerY) {
+ return new Promise(function(resolve, reject) {
+ sendWheelAndPaintNoFlush(aTarget, centerX, centerY,
+ { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
+ deltaY: 100 },
+ resolve);
+ });
+}
+
SimpleTest.expectAssertions(0, 1); // bug 1332970
SimpleTest.waitForExplicitFinish();
var omtaEnabled = isOMTAEnabled();
var isAndroid = !!navigator.userAgent.includes("Android");
var isServo = isStyledByServo();
var offscreenThrottlingEnabled =
@@ -300,25 +309,20 @@ waitForAllPaints(function() {
is(markers.length, 0,
'Animations running on the main-thread for elements ' +
'which are scrolled out should never cause restyles');
var parentRect = parentElement.getBoundingClientRect();
var centerX = parentRect.left + parentRect.width / 2;
var centerY = parentRect.top + parentRect.height / 2;
- var markers = await observeStyling(1, function() {
- // We can't use synthesizeWheel here since synthesizeWheel causes
- // layout flush.
- synthesizeWheelAtPoint(centerX, centerY,
- { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaY: 100 });
- });
+ await waitForWheelEvent(parentElement, centerX, centerY);
- is(markers.length, 1,
+ markers = await observeStyling(5);
+ is(markers.length, 5,
'Animations running on the main-thread which were in scrolled out ' +
'elements should update restyling soon after the element moved in ' +
'view by scrolling');
await ensureElementRemoval(parentElement);
});
add_task(async function restyling_main_thread_animations_in_nested_scrolled_out_element() {
@@ -353,26 +357,20 @@ waitForAllPaints(function() {
is(markers.length, 0,
'Animations running on the main-thread which are in nested elements ' +
'which are scrolled out should never cause restyles');
var parentRect = grandParent.getBoundingClientRect();
var centerX = parentRect.left + parentRect.width / 2;
var centerY = parentRect.top + parentRect.height / 2;
- var markers = await observeStyling(1, function() {
- // We can't use synthesizeWheel here since synthesizeWheel causes
- // layout flush.
- synthesizeWheelAtPoint(centerX, centerY,
- { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaY: 100 });
- });
+ await waitForWheelEvent(grandParent, centerX, centerY);
- // FIXME: We should reduce a redundant restyle here.
- ok(markers.length >= 1,
+ markers = await observeStyling(5);
+ is(markers.length, 5,
'Animations running on the main-thread which were in nested scrolled ' +
'out elements should update restyle soon after the element moved ' +
'in view by scrolling');
await ensureElementRemoval(grandParent);
});
add_task_if_omta_enabled(async function no_restyling_compositor_animations_in_visiblily_hidden_element() {
@@ -415,21 +413,17 @@ waitForAllPaints(function() {
var animation = div.getAnimations()[0];
var parentRect = parentElement.getBoundingClientRect();
var centerX = parentRect.left + parentRect.width / 2;
var centerY = parentRect.top + parentRect.height / 2;
await animation.ready;
- // We can't use synthesizeWheel here since synthesizeWheel causes
- // layout flush.
- synthesizeWheelAtPoint(centerX, centerY,
- { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaY: 200 });
+ await waitForWheelEvent(parentElement, centerX, centerY);
var markers = await observeStyling(5);
// FIXME: We should reduce a redundant restyle here.
ok(markers.length >= 0,
'Animations running on the main-thread which are in scrolled out ' +
'elements should throttle restyling');