Files
sousa-gecko/devtools/server/tests/browser/browser_animation_keepFinished.js
T
Nicolas Chevobbe f67101d76f Bug 1149501 - [devtools] Update server code to simply refer to Animation instead of Animation Player. r=devtools-reviewers,devtools-backward-compat-reviewers,jdescottes.
The player word is a relic of a past implementation of the Animation API that doesn't
exist anymore.
This patch removes/renames references to player that are easy to handle.
Renaming RDP methods / fronts will be done later in following commits.

Differential Revision: https://phabricator.services.mozilla.com/D289496
2026-04-10 08:24:48 +00:00

56 lines
1.7 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable mozilla/no-arbitrary-setTimeout */
"use strict";
// Test that the AnimationsActor doesn't report finished animations as removed.
// Indeed, animations that only have the "finished" playState can be modified
// still, so we want the AnimationsActor to preserve the corresponding
// AnimationActor.
add_task(async function () {
const { target, walker, animations } = await initAnimationsFrontForUrl(
MAIN_DOMAIN + "animation.html"
);
info("Retrieve a non-animated node");
const node = await walker.querySelector(walker.rootNode, ".not-animated");
info("Retrieve the animation player for the node");
let players = await animations.getAnimationPlayersForNode(node);
is(players.length, 0, "The node has no animation players");
info("Listen for new animations");
let reportedMutations = [];
function onMutations(mutations) {
reportedMutations = [...reportedMutations, ...mutations];
}
animations.on("mutations", onMutations);
info("Add a short animation on the node");
await node.modifyAttributes([
{ attributeName: "class", newValue: "short-animation" },
]);
info("Wait for longer than the animation's duration");
await wait(2000);
players = await animations.getAnimationPlayersForNode(node);
is(players.length, 0, "The added animation is surely finished");
is(reportedMutations.length, 1, "Only one mutation was reported");
is(reportedMutations[0].type, "added", "The mutation was an addition");
animations.off("mutations", onMutations);
await target.destroy();
gBrowser.removeCurrentTab();
});
function wait(ms) {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
}