browser_animation_indication-bar.js (1646B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test whether the indication bar of both scrubber and progress bar indicates correct 7 // progress after resizing animation inspector. 8 9 add_task(async function () { 10 await pushPref("devtools.inspector.three-pane-enabled", false); 11 await addTab(URL_ROOT + "doc_simple_animation.html"); 12 await removeAnimatedElementsExcept([".animated"]); 13 const { animationInspector, inspector, panel } = 14 await openAnimationInspector(); 15 16 info("Checking timeline tick item elements after enlarge sidebar width"); 17 clickOnCurrentTimeScrubberController(animationInspector, panel, 0.5); 18 await waitUntilAnimationsPlayState(animationInspector, "paused"); 19 await setSidebarWidth("100%", inspector); 20 assertPosition(".current-time-scrubber", panel, 0.5); 21 assertPosition(".keyframes-progress-bar", panel, 0.5); 22 }); 23 24 /** 25 * Assert indication bar position. 26 * 27 * @param {string} indicationBarSelector 28 * @param {Element} panel 29 * @param {number} expectedPositionRate 30 */ 31 function assertPosition(indicationBarSelector, panel, expectedPositionRate) { 32 const barEl = panel.querySelector(indicationBarSelector); 33 const parentEl = barEl.parentNode; 34 const rectBar = barEl.getBoundingClientRect(); 35 const rectParent = parentEl.getBoundingClientRect(); 36 const barX = rectBar.x + rectBar.width * 0.5 - rectParent.x; 37 const expectedPosition = rectParent.width * expectedPositionRate; 38 ok( 39 expectedPosition - 1 <= barX && barX <= expectedPosition + 1, 40 `Indication bar position should be approximately ${expectedPosition}` 41 ); 42 }