browser_animation_logic_auto-stop.js (3261B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Animation inspector makes the current time to stop 7 // after end of animation duration except iterations infinity. 8 // Test followings: 9 // * state of animations and UI components after end of animation duration 10 // * state of animations and UI components after end of animation duration 11 // but iteration count is infinity 12 13 add_task(async function () { 14 await addTab(URL_ROOT + "doc_simple_animation.html"); 15 await removeAnimatedElementsExcept([".compositor-all", ".long"]); 16 const { animationInspector, inspector, panel } = 17 await openAnimationInspector(); 18 19 info("Checking state after end of animation duration"); 20 await selectNode(".long", inspector); 21 await waitUntil(() => panel.querySelectorAll(".animation-item").length === 1); 22 const pixelsData = getDurationAndRate(animationInspector, panel, 5); 23 clickOnCurrentTimeScrubberController( 24 animationInspector, 25 panel, 26 1 - pixelsData.rate 27 ); 28 await waitUntilAnimationsPlayState(animationInspector, "paused"); 29 clickOnPauseResumeButton(animationInspector, panel); 30 await assertStates(animationInspector, panel, false); 31 32 info( 33 "Checking state after end of animation duration and infinity iterations" 34 ); 35 clickOnPauseResumeButton(animationInspector, panel); 36 await waitUntilAnimationsPlayState(animationInspector, "paused"); 37 await selectNode(".compositor-all", inspector); 38 await waitUntil(() => panel.querySelectorAll(".animation-item").length === 1); 39 clickOnCurrentTimeScrubberController(animationInspector, panel, 1); 40 await waitUntilAnimationsPlayState(animationInspector, "paused"); 41 clickOnPauseResumeButton(animationInspector, panel); 42 await assertStates(animationInspector, panel, true); 43 }); 44 45 async function assertStates(animationInspector, panel, shouldRunning) { 46 const buttonEl = panel.querySelector(".pause-resume-button"); 47 const labelEl = panel.querySelector(".current-time-label"); 48 const scrubberEl = panel.querySelector(".current-time-scrubber"); 49 50 const previousLabelContent = labelEl.textContent; 51 const previousScrubberX = scrubberEl.getBoundingClientRect().x; 52 53 await waitUntilAnimationsPlayState( 54 animationInspector, 55 shouldRunning ? "running" : "paused" 56 ); 57 58 const currentLabelContent = labelEl.textContent; 59 const currentScrubberX = scrubberEl.getBoundingClientRect().x; 60 61 if (shouldRunning) { 62 isnot( 63 previousLabelContent, 64 currentLabelContent, 65 "Current time label content should change" 66 ); 67 isnot( 68 previousScrubberX, 69 currentScrubberX, 70 "Current time scrubber position should change" 71 ); 72 ok( 73 !buttonEl.classList.contains("paused"), 74 "State of button should be running" 75 ); 76 assertAnimationsRunning(animationInspector); 77 } else { 78 is( 79 previousLabelContent, 80 currentLabelContent, 81 "Current time label Content should not change" 82 ); 83 is( 84 previousScrubberX, 85 currentScrubberX, 86 "Current time scrubber position should not change" 87 ); 88 ok( 89 buttonEl.classList.contains("paused"), 90 "State of button should be paused" 91 ); 92 assertAnimationsPausing(animationInspector); 93 } 94 }