summaryrefslogtreecommitdiffstats
path: root/devtools/client/animationinspector/test/browser_animation_ui_updates_when_animation_data_changes.js
blob: aa71fd9af3a8d71833124494d5acdfa0792136be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

requestLongerTimeout(2);

// Verify that if the animation's duration, iterations or delay change in
// content, then the widget reflects the changes.

add_task(function* () {
  yield addTab(URL_ROOT + "doc_simple_animation.html");
  let {panel, controller, inspector} = yield openAnimationInspector();

  info("Select the test node");
  yield selectNodeAndWaitForAnimations(".animated", inspector);

  let animation = controller.animationPlayers[0];
  yield setStyle(animation, panel, "animationDuration", "5.5s");
  yield setStyle(animation, panel, "animationIterationCount", "300");
  yield setStyle(animation, panel, "animationDelay", "45s");

  let animationsEl = panel.animationsTimelineComponent.animationsEl;
  let timeBlockEl = animationsEl.querySelector(".time-block");

  // 45s delay + (300 * 5.5)s duration
  let expectedTotalDuration = 1695 * 1000;

  // XXX: the nb and size of each iteration cannot be tested easily (displayed
  // using a linear-gradient background and capped at 2px wide). They should
  // be tested in bug 1173761.
  let delayWidth = parseFloat(timeBlockEl.querySelector(".delay").style.width);
  is(Math.round(delayWidth * expectedTotalDuration / 100), 45 * 1000,
    "The timeline has the right delay");
});

function* setStyle(animation, panel, name, value) {
  info("Change the animation style via the content DOM. Setting " +
    name + " to " + value);

  let onAnimationChanged = once(animation, "changed");
  yield executeInContent("devtools:test:setStyle", {
    selector: ".animated",
    propertyName: name,
    propertyValue: value
  });
  yield onAnimationChanged;

  // Also wait for the target node previews to be loaded if the panel got
  // refreshed as a result of this animation mutation.
  yield waitForAllAnimationTargets(panel);
}