Bug 1407900 - Part 2: Add test for hidden panel. r?pbro
MozReview-Commit-ID: 2ied0w6KY14
--- a/devtools/client/animationinspector/animation-controller.js
+++ b/devtools/client/animationinspector/animation-controller.js
@@ -230,17 +230,18 @@ var AnimationsController = {
onNewNodeFront: Task.async(function* () {
// Ignore if the panel isn't visible.
// Or the node selection hasn't changed and no animation mutations event occurs during
// hidden.
if (!this.isPanelVisible() || (this.nodeFront === gInspector.selection.nodeFront &&
!this.mutationsDetectedWhileHidden)) {
return;
}
- this.isMutationsEventOccuredDuringHidden = false;
+
+ this.mutationsDetectedWhileHidden = false;
this.nodeFront = gInspector.selection.nodeFront;
let done = gInspector.updating("animationscontroller");
if (!gInspector.selection.isConnected() ||
!gInspector.selection.isElementNode()) {
this.destroyAnimationPlayers();
this.emit(this.PLAYERS_UPDATED_EVENT);
--- a/devtools/client/animationinspector/test/browser.ini
+++ b/devtools/client/animationinspector/test/browser.ini
@@ -43,16 +43,17 @@ skip-if = os == "linux" && !debug # Bug
[browser_animation_playerFronts_are_refreshed.js]
[browser_animation_playerWidgets_appear_on_panel_init.js]
[browser_animation_playerWidgets_target_nodes.js]
[browser_animation_pseudo_elements.js]
[browser_animation_refresh_on_added_animation.js]
[browser_animation_refresh_on_removed_animation.js]
skip-if = os == "linux" && !debug # Bug 1227792
[browser_animation_refresh_when_active.js]
+[browser_animation_refresh_when_active_after_mutations.js]
[browser_animation_running_on_compositor.js]
[browser_animation_same_nb_of_playerWidgets_and_playerFronts.js]
[browser_animation_shows_player_on_valid_node.js]
[browser_animation_spacebar_toggles_animations.js]
[browser_animation_spacebar_toggles_node_animations.js]
[browser_animation_summarygraph_for_multiple_easings.js]
[browser_animation_target_highlight_select.js]
[browser_animation_target_highlighter_lock.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/animationinspector/test/browser_animation_refresh_when_active_after_mutations.js
@@ -0,0 +1,54 @@
+/* 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);
+
+// Test that refresh animation UI while the panel is hidden.
+
+const EXPECTED_GRAPH_PATH_SEGMENTS = [{ x: 0, y: 0 },
+ { x: 49999, y: 0.0 },
+ { x: 50000, y: 0.5 },
+ { x: 99999, y: 0.5 },
+ { x: 100000, y: 0 }];
+
+add_task(function* () {
+ info("Open animation inspector once so that activate animation mutations listener");
+ yield addTab("data:text/html;charset=utf8,<div id='target'>test</div>");
+ const { controller, inspector, panel } = yield openAnimationInspector();
+
+ info("Select other tool to hide animation inspector");
+ yield inspector.sidebar.select("ruleview");
+
+ // Count players-updated event in controller.
+ let updatedEventCount = 0;
+ controller.on("players-updated", () => {
+ updatedEventCount += 1;
+ });
+
+ info("Make animation by eval in content");
+ yield evalInDebuggee(gBrowser.selectedBrowser.messageManager,
+ `document.querySelector('#target').animate(
+ { transform: 'translate(100px)' },
+ { duration: 100000, easing: 'steps(2)' });`);
+ info("Wait for animation mutations event");
+ yield controller.animationsFront.once("mutations");
+ info("Check players-updated events count");
+ is(updatedEventCount, 0, "players-updated event shoud not be fired");
+
+ info("Re-select animation inspector and check the UI");
+ yield inspector.sidebar.select("animationinspector");
+ yield waitForAnimationTimelineRendering(panel);
+
+ const timeBlocks = getAnimationTimeBlocks(panel);
+ is(timeBlocks.length, 1, "One animation should display");
+ const timeBlock = timeBlocks[0];
+ const state = timeBlock.animation.state;
+ const effectEl = timeBlock.containerEl.querySelector(".effect-easing");
+ ok(effectEl, "<g> element for effect easing should exist");
+ const pathEl = effectEl.querySelector("path");
+ ok(pathEl, "<path> element for effect easing should exist");
+ assertPathSegments(pathEl, state.duration, false, EXPECTED_GRAPH_PATH_SEGMENTS);
+});