Bug 1463372 - Part 2: Test for createdTime based keyframes progress bar. r?pbro draft
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Fri, 25 May 2018 17:33:29 +0900
changeset 799728 ad7f48eda2fb46cf472ad68ce5b8dbf6731717df
parent 799724 5b1817d545c8061a9ee245f4ee532ca843940dd5
child 799735 13f04a5f751b5d0f9cd42931f57d164ead717b8b
push id111152
push userbmo:dakatsuka@mozilla.com
push dateFri, 25 May 2018 08:34:23 +0000
reviewerspbro
bugs1463372
milestone62.0a1
Bug 1463372 - Part 2: Test for createdTime based keyframes progress bar. r?pbro MozReview-Commit-ID: IDMU37WdMM1
devtools/client/inspector/animation/test/browser.ini
devtools/client/inspector/animation/test/browser_animation_keyframes-progress-bar_after-resuming.js
--- a/devtools/client/inspector/animation/test/browser.ini
+++ b/devtools/client/inspector/animation/test/browser.ini
@@ -34,16 +34,17 @@ support-files =
 [browser_animation_current-time-scrubber.js]
 [browser_animation_current-time-scrubber_each-different-creation-time-animations.js]
 [browser_animation_empty_on_invalid_nodes.js]
 [browser_animation_inspector_exists.js]
 [browser_animation_keyframes-graph_computed-value-path.js]
 [browser_animation_keyframes-graph_computed-value-path_easing-hint.js]
 [browser_animation_keyframes-graph_keyframe-marker.js]
 [browser_animation_keyframes-progress-bar.js]
+[browser_animation_keyframes-progress-bar_after-resuming.js]
 [browser_animation_logic_auto-stop.js]
 [browser_animation_logic_avoid-updating-during-hiding.js]
 [browser_animation_logic_mutations.js]
 [browser_animation_pause-resume-button.js]
 [browser_animation_pause-resume-button_end-time.js]
 [browser_animation_pause-resume-button_respectively.js]
 [browser_animation_pause-resume-button_spacebar.js]
 [browser_animation_playback-rate-selector.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/animation/test/browser_animation_keyframes-progress-bar_after-resuming.js
@@ -0,0 +1,42 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Test whether keyframes progress bar moves correctly after resuming the animation.
+
+add_task(async function() {
+  await addTab(URL_ROOT + "doc_simple_animation.html");
+  await removeAnimatedElementsExcept([".animated"]);
+  const { animationInspector, panel } = await openAnimationInspector();
+
+  const scrubberPositions = [0, 0.25, 0.5, 0.75];
+  const expectedPositions = [0, 0.25, 0.5, 0.75];
+
+  info("Check whether the keyframes progress bar position was correct");
+  await assertPosition(panel, scrubberPositions, expectedPositions, animationInspector);
+
+  info("Check whether the keyframes progress bar position was correct " +
+       "after a bit time passed and resuming");
+  await wait(500);
+  await clickOnPauseResumeButton(animationInspector, panel);
+  await assertPosition(panel, scrubberPositions, expectedPositions, animationInspector);
+});
+
+async function assertPosition(panel, scrubberPositions,
+                              expectedPositions, animationInspector) {
+  const areaEl = panel.querySelector(".keyframes-progress-bar-area");
+  const barEl = areaEl.querySelector(".keyframes-progress-bar");
+  const controllerBounds = areaEl.getBoundingClientRect();
+
+  for (let i = 0; i < scrubberPositions.length; i++) {
+    info(`Scrubber position is ${ scrubberPositions[i] }`);
+    await clickOnCurrentTimeScrubberController(animationInspector,
+                                               panel, scrubberPositions[i]);
+    const barBounds = barEl.getBoundingClientRect();
+    const barX = barBounds.x + barBounds.width / 2 - controllerBounds.x;
+    const expected = controllerBounds.width * expectedPositions[i];
+    ok(expected - 1 < barX && barX < expected + 1,
+       `Position should apploximately be ${ expected } (x of bar is ${ barX })`);
+  }
+}