Skip to content

Commit

Permalink
Bug 1950378 - Don't wait for multiple paints after reftest-wait has b…
Browse files Browse the repository at this point in the history
…een removed. r=jgraham,webdriver-reviewers

If reftest-wait has been removed, it's a strong signal that the
screenshot should be taken. Wait for the next paint, but not more than
that.

This prevents issues with a few view-transition tests that have very
long-running opacity animations, causing timeouts, see
https://hg.mozilla.org/try/rev/ef7d1b85f7c253b38772169a61e61410f0722ef9.

Differential Revision: https://phabricator.services.mozilla.com/D239583
  • Loading branch information
emilio committed Feb 26, 2025
1 parent e33c8fa commit 08b6977
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions remote/marionette/actors/MarionetteReftestChild.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ export class MarionetteReftestChild extends JSWindowActorChild {
documentElement.dispatchEvent(event);
lazy.logger.info("Emitted TestRendered event");
await this.reftestWaitRemoved();
await this.paintComplete({ useRemote, ignoreThrottledAnimations: false });
await this.paintComplete({
useRemote,
ignoreThrottledAnimations: false,
once: true,
});
}
if (
options.warnOnOverflow &&
Expand All @@ -121,9 +125,10 @@ export class MarionetteReftestChild extends JSWindowActorChild {
return true;
}

paintComplete({ useRemote, ignoreThrottledAnimations }) {
paintComplete({ useRemote, ignoreThrottledAnimations, once }) {
lazy.logger.debug("Waiting for rendering");
let windowUtils = this.document.defaultView.windowUtils;
let painted = false;
return new Promise(resolve => {
let maybeResolve = () => {
this.flushRendering({ ignoreThrottledAnimations });
Expand All @@ -133,11 +138,14 @@ export class MarionetteReftestChild extends JSWindowActorChild {
windowUtils.updateLayerTree();
}

if (windowUtils.isMozAfterPaintPending) {
if (windowUtils.isMozAfterPaintPending && (!once || !painted)) {
lazy.logger.debug("isMozAfterPaintPending: true");
this.document.defaultView.addEventListener(
"MozAfterPaint",
maybeResolve,
() => {
painted = true;
maybeResolve();
},
{
once: true,
}
Expand Down

0 comments on commit 08b6977

Please sign in to comment.