Bug 1425009 - Take into account the possibility that the animation begins at the moment when the animation was detached from the document. r?birtles
MozReview-Commit-ID: wbM5JW7v76
--- a/dom/animation/test/mozilla/file_restyles.html
+++ b/dom/animation/test/mozilla/file_restyles.html
@@ -96,17 +96,17 @@ function waitForWheelEvent(aTarget) {
// refresh rate) then we won't end up restyling in that frame.
function startsRightNow(aAnimation) {
return aAnimation.startTime === aAnimation.timeline.currentTime &&
aAnimation.currentTime === 0;
}
function tweakExpectedRestyleCount(aAnimation, aExpectedRestyleCount) {
// Normally we expect one restyling for each requestAnimationFrame (as
- // called by observeRestyling) PLUS one for the last frame becasue of bug
+ // called by observeRestyling) PLUS one for the last frame because of bug
// 1193394. However, we won't observe that initial restyling unless BOTH of
// the following two conditions hold:
//
// 1. We are running *before* restyling happens.
// 2. The animation actually needs a restyle because it started prior to
// this frame. Even if (1) is true, in some cases due to aligning with
// the refresh driver, the animation fame in which the ready promise is
// resolved happens to coincide perfectly with the start time of the
@@ -936,16 +936,21 @@ waitForAllPaints(() => {
var div = addDiv(null);
var animation = div.animate({ marginLeft: [ '0px', '100px' ] },
100 * MS_PER_SEC);
await animation.ready;
div.remove();
+ // It's possible that the animation begins at this moment. If this is the
+ // case, an additional superfluous restyle request that we will check later
+ // can't be observed.
+ const expectedRestyleCount = tweakExpectedRestyleCount(animation, 1);
+
var markers = await observeStyling(5);
is(markers.length, 0,
'Animation on orphaned element should not cause restyles');
document.body.appendChild(div);
markers = await observeStyling(1);
if (isServo) {
@@ -956,20 +961,20 @@ waitForAllPaints(() => {
// result, the animation is restyled during a second animation restyle in
// the first frame. If we fix the behavior when we attach an orphaned
// element with script animations to a document so that it requests a
// layer restyle (bug 1388557) before fixing important_rules_change in
// compute_style() so that it no longer dispatches a needless standard
// restyle (bug 1388560), we should add a test case that fails if we
// continue to unnecessarily request a standard restyle.
//
- // Bug 1417354: There will be an additional superfluos restyle request
- // whichi results when we detach an element from the document between
+ // Bug 1417354: There will be an additional superfluous restyle request
+ // which results when we detach an element from the document between
// the Animation tick and styling, and then re-attach it.
- is(markers.length, 2,
+ is(markers.length, expectedRestyleCount,
'We should observe one restyle in the first frame right after ' +
're-attaching to the document');
} else {
// Bug 1388557: We should call RequestRestyle(Layer) when an element which
// has running script animations is attached to a document.
todo_is(markers.length, 1,
'Bug 1388557 We should observe one restyle in the first frame ' +
'right after re-attaching to the document');