browser_animation_actor-lifetime.js (2600B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test for Bug 1247243 7 8 add_task(async function () { 9 info("Setting up inspector and animation actors."); 10 const { animations, walker } = await initAnimationsFrontForUrl( 11 MAIN_DOMAIN + "animation-data.html" 12 ); 13 14 info("Testing animated node actor"); 15 const animatedNodeActor = await walker.querySelector( 16 walker.rootNode, 17 ".animated" 18 ); 19 await animations.getAnimationPlayersForNode(animatedNodeActor); 20 21 await assertNumberOfAnimationActors( 22 1, 23 "AnimationActor have 1 AnimationPlayerActors" 24 ); 25 26 info("Testing AnimationPlayerActors release"); 27 const stillNodeActor = await walker.querySelector(walker.rootNode, ".still"); 28 await animations.getAnimationPlayersForNode(stillNodeActor); 29 await assertNumberOfAnimationActors( 30 0, 31 "AnimationActor does not have any AnimationPlayerActors anymore" 32 ); 33 34 info("Testing multi animated node actor"); 35 const multiNodeActor = await walker.querySelector(walker.rootNode, ".multi"); 36 await animations.getAnimationPlayersForNode(multiNodeActor); 37 await assertNumberOfAnimationActors( 38 2, 39 "AnimationActor has now 2 AnimationPlayerActors" 40 ); 41 42 info("Testing single animated node actor"); 43 await animations.getAnimationPlayersForNode(animatedNodeActor); 44 await assertNumberOfAnimationActors( 45 1, 46 "AnimationActor has only one AnimationPlayerActors" 47 ); 48 49 info("Testing AnimationPlayerActors release again"); 50 await animations.getAnimationPlayersForNode(stillNodeActor); 51 await assertNumberOfAnimationActors( 52 0, 53 "AnimationActor does not have any AnimationPlayerActors anymore" 54 ); 55 56 async function assertNumberOfAnimationActors(expected, message) { 57 const actors = await SpecialPowers.spawn( 58 gBrowser.selectedBrowser, 59 [[animations.actorID]], 60 function (actorID) { 61 const { require } = ChromeUtils.importESModule( 62 "resource://devtools/shared/loader/Loader.sys.mjs" 63 ); 64 const { 65 DevToolsServer, 66 } = require("resource://devtools/server/devtools-server.js"); 67 // Convert actorID to current compartment string otherwise 68 // searchAllConnectionsForActor is confused and won't find the actor. 69 actorID = String(actorID); 70 const animationActors = 71 DevToolsServer.searchAllConnectionsForActor(actorID); 72 if (!animationActors) { 73 return 0; 74 } 75 return animationActors.actors.length; 76 } 77 ); 78 is(actors, expected, message); 79 } 80 });