Files
sousa-gecko/devtools/server/tests/browser/browser_animation_getPlayers.js
T
Nicolas Chevobbe e8fb3ed027 Bug 2001562 - [devtools] Fix AnimationPlayerActor for element with type property. r=devtools-reviewers,bomsy.
In the class, there were a couple places where we would check the animation target
`type` property as a way to detect if the animated element was a pseudo element.
This means that we were considering button elements as pseudo element, and re-assigning
variables with erroneous properties, which would ultimately make the methods throw.
This is also wrong for pseudo elements: the animation target is always the binding
element and we have a `pseudoElement` string property on the animation to detect
if this applies to a pseudo element.

We fix the faulty callsites and add a server test that is covering this.

Differential Revision: https://phabricator.services.mozilla.com/D273546
2025-11-21 17:13:04 +00:00

45 lines
1.6 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Check the output of getAnimationPlayersForNode
add_task(async function () {
const { target, walker, animations } = await initAnimationsFrontForUrl(
MAIN_DOMAIN + "animation.html"
);
await theRightNumberOfPlayersIsReturned(walker, animations);
await target.destroy();
gBrowser.removeCurrentTab();
});
async function theRightNumberOfPlayersIsReturned(walker, animations) {
let node = await walker.querySelector(walker.rootNode, ".not-animated");
let players = await animations.getAnimationPlayersForNode(node);
is(players.length, 0, "0 players were returned for the unanimated node");
node = await walker.querySelector(walker.rootNode, ".simple-animation");
players = await animations.getAnimationPlayersForNode(node);
is(players.length, 1, "One animation player was returned");
node = await walker.querySelector(walker.rootNode, ".multiple-animations");
players = await animations.getAnimationPlayersForNode(node);
is(players.length, 2, "Two animation players were returned");
node = await walker.querySelector(walker.rootNode, ".transition");
players = await animations.getAnimationPlayersForNode(node);
is(
players.length,
1,
"One animation player was returned for the transitioned node"
);
// Asserting fix for Bug 2001562
node = await walker.querySelector(walker.rootNode, ".button-animation");
players = await animations.getAnimationPlayersForNode(node);
is(players.length, 1, "Got an animation player for the animated button");
}