Bug 1120339 - Add setPlaybackRate method to AnimationPlayerActor; r=past

This commit is contained in:
Patrick Brosset 2015-03-25 18:56:54 +01:00
parent a992e81184
commit cd371edc97
4 changed files with 65 additions and 0 deletions

View File

@ -208,6 +208,7 @@ let AnimationPlayerActor = ActorClass({
startTime: this.player.startTime,
currentTime: this.player.currentTime,
playState: this.player.playState,
playbackRate: this.player.playbackRate,
name: this.player.source.effect.name,
duration: this.getDuration(),
delay: this.getDelay(),
@ -296,6 +297,18 @@ let AnimationPlayerActor = ActorClass({
currentTime: Arg(0, "number")
},
response: {}
}),
/**
* Set the playback rate of the animation player.
*/
setPlaybackRate: method(function(playbackRate) {
this.player.playbackRate = playbackRate;
}, {
request: {
currentTime: Arg(0, "number")
},
response: {}
})
});
@ -332,6 +345,7 @@ let AnimationPlayerFront = FrontClass(AnimationPlayerActor, {
startTime: this._form.startTime,
currentTime: this._form.currentTime,
playState: this._form.playState,
playbackRate: this._form.playbackRate,
name: this._form.name,
duration: this._form.duration,
delay: this._form.delay,

View File

@ -26,6 +26,7 @@ support-files =
[browser_animation_actors_09.js]
[browser_animation_actors_10.js]
[browser_animation_actors_11.js]
[browser_animation_actors_12.js]
[browser_canvasframe_helper_01.js]
[browser_canvasframe_helper_02.js]
[browser_canvasframe_helper_03.js]

View File

@ -34,6 +34,7 @@ function* playerHasAnInitialState(walker, front) {
ok("startTime" in player.initialState, "Player's state has startTime");
ok("currentTime" in player.initialState, "Player's state has currentTime");
ok("playState" in player.initialState, "Player's state has playState");
ok("playbackRate" in player.initialState, "Player's state has playbackRate");
ok("name" in player.initialState, "Player's state has name");
ok("duration" in player.initialState, "Player's state has duration");
ok("delay" in player.initialState, "Player's state has delay");
@ -50,6 +51,7 @@ function* playerStateIsCorrect(walker, front) {
// null = infinite count
is(state.iterationCount, null, "Iteration count is correct");
is(state.playState, "running", "PlayState is correct");
is(state.playbackRate, 1, "PlaybackRate is correct");
info("Checking the state of the transition");
@ -59,6 +61,7 @@ function* playerStateIsCorrect(walker, front) {
// transitions run only once
is(state.iterationCount, 1, "Transition iteration count is correct");
is(state.playState, "running", "Transition playState is correct");
is(state.playbackRate, 1, "Transition playbackRate is correct");
info("Checking the state of one of multiple animations on a node");
@ -68,6 +71,7 @@ function* playerStateIsCorrect(walker, front) {
is(state.duration, 1000, "The 2nd animation's duration is correct");
is(state.iterationCount, 5, "The 2nd animation's iteration count is correct");
is(state.playState, "running", "The 2nd animation's playState is correct");
is(state.playbackRate, 1, "The 2nd animation's playbackRate is correct");
info("Checking the state of an animation with delay");

View File

@ -0,0 +1,46 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Check that a player's playbackRate can be changed.
const {AnimationsFront} = require("devtools/server/actors/animation");
const {InspectorFront} = require("devtools/server/actors/inspector");
add_task(function*() {
let doc = yield addTab(MAIN_DOMAIN + "animation.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
let form = yield connectDebuggerClient(client);
let inspector = InspectorFront(client, form);
let walker = yield inspector.getWalker();
let animations = AnimationsFront(client, form);
info("Retrieve an animated node");
let node = yield walker.querySelector(walker.rootNode, ".simple-animation");
info("Retrieve the animation player for the node");
let [player] = yield animations.getAnimationPlayersForNode(node);
ok(player.setPlaybackRate, "Player has the setPlaybackRate method");
info("Change the rate to 10");
yield player.setPlaybackRate(10);
info("Query the state again");
let state = yield player.getCurrentState();
is(state.playbackRate, 10, "The playbackRate was updated");
info("Change the rate back to 1");
yield player.setPlaybackRate(1);
info("Query the state again");
state = yield player.getCurrentState();
is(state.playbackRate, 1, "The playbackRate was changed back");
yield closeDebuggerClient(client);
gBrowser.removeCurrentTab();
});