Bug 1122437 - 2 - Make sure animationplayer widgets display the right initial time when created; r=miker

This commit is contained in:
Patrick Brosset 2015-01-23 17:50:14 +01:00
parent e3b8926193
commit 38a781c5c7
3 changed files with 36 additions and 4 deletions

View File

@ -254,9 +254,9 @@ PlayerWidget.prototype = {
} }
}); });
let max = state.duration; // Infinite iterations. let max = state.duration;
if (state.iterationCount) { if (state.iterationCount) {
// Finite iterations. // If there's a finite nb of iterations.
max = state.iterationCount * state.duration; max = state.iterationCount * state.duration;
} }
@ -285,10 +285,11 @@ PlayerWidget.prototype = {
"class": "time-display" "class": "time-display"
} }
}); });
this.timeDisplayEl.textContent = L10N.getFormatStr("player.timeLabel",
this.getFormattedTime(0));
this.containerEl.appendChild(this.el); this.containerEl.appendChild(this.el);
// Show the initial time.
this.displayTime(state.currentTime);
}, },
/** /**

View File

@ -13,6 +13,7 @@ support-files =
[browser_animation_playerWidgets_destroy.js] [browser_animation_playerWidgets_destroy.js]
[browser_animation_playerWidgets_disables_on_finished.js] [browser_animation_playerWidgets_disables_on_finished.js]
[browser_animation_playerWidgets_meta_data.js] [browser_animation_playerWidgets_meta_data.js]
[browser_animation_playerWidgets_state_after_pause.js]
[browser_animation_refresh_when_active.js] [browser_animation_refresh_when_active.js]
[browser_animation_same_nb_of_playerWidgets_and_playerFronts.js] [browser_animation_same_nb_of_playerWidgets_and_playerFronts.js]
[browser_animation_shows_player_on_valid_node.js] [browser_animation_shows_player_on_valid_node.js]

View File

@ -0,0 +1,30 @@
/* 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";
// Test that once an animation is paused and its widget is refreshed, the right
// initial time is displayed.
add_task(function*() {
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
let {inspector, panel} = yield openAnimationInspector();
info("Selecting the test node");
yield selectNode(".animated", inspector);
info("Pausing the animation by using the widget");
let widget = panel.playerWidgets[0];
yield widget.pause();
info("Selecting another node and then the same node again to refresh the widget");
yield selectNode(".still", inspector);
yield selectNode(".animated", inspector);
widget = panel.playerWidgets[0];
ok(widget.el.classList.contains("paused"), "The widget is still in paused mode");
is(widget.timeDisplayEl.textContent,
widget.getFormattedTime(widget.player.state.currentTime) + "s",
"The initial time has been set to the player's");
});