mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Bug 1110762 - Add a setCurrentTime method to the animation actor; r=past
--HG-- extra : rebase_source : e0e0eef2b1b35a4f8c23f905b3603e2a009a05c7
This commit is contained in:
parent
a779113067
commit
02d6847dd7
@ -43,7 +43,7 @@ const PLAYER_DEFAULT_AUTO_REFRESH_TIMEOUT = 500; // ms
|
||||
* Since the state of a player changes as the animation progresses it is often
|
||||
* useful to call getCurrentState at regular intervals to get the current state.
|
||||
*
|
||||
* This actor also allows playing and pausing the animation.
|
||||
* This actor also allows playing, pausing and seeking the animation.
|
||||
*/
|
||||
let AnimationPlayerActor = ActorClass({
|
||||
typeName: "animationplayer",
|
||||
@ -283,6 +283,18 @@ let AnimationPlayerActor = ActorClass({
|
||||
}, {
|
||||
request: {},
|
||||
response: {}
|
||||
}),
|
||||
|
||||
/**
|
||||
* Set the current time of the animation player.
|
||||
*/
|
||||
setCurrentTime: method(function(currentTime) {
|
||||
this.player.currentTime = currentTime;
|
||||
}, {
|
||||
request: {
|
||||
currentTime: Arg(0, "number")
|
||||
},
|
||||
response: {}
|
||||
})
|
||||
});
|
||||
|
||||
|
@ -25,6 +25,7 @@ support-files =
|
||||
[browser_animation_actors_08.js]
|
||||
[browser_animation_actors_09.js]
|
||||
[browser_animation_actors_10.js]
|
||||
[browser_animation_actors_11.js]
|
||||
[browser_navigateEvents.js]
|
||||
[browser_storage_dynamic_windows.js]
|
||||
[browser_storage_listings.js]
|
||||
|
@ -0,0 +1,49 @@
|
||||
/* 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 currentTime 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.setCurrentTime, "Player has the setCurrentTime method");
|
||||
|
||||
info("Set the current time to currentTime + 5s");
|
||||
yield player.setCurrentTime(player.initialState.currentTime + 5000);
|
||||
|
||||
// We're not really interested in making sure the currentTime is set precisely
|
||||
// and doing this could lead to intermittents, so only check that the new time
|
||||
// is now above the initial time.
|
||||
let state = yield player.getCurrentState();
|
||||
ok(state.currentTime > player.initialState.currentTime,
|
||||
"The currentTime was updated to +5s");
|
||||
|
||||
info("Set the current time to currentTime - 2s");
|
||||
yield player.setCurrentTime(state.currentTime - 2000);
|
||||
|
||||
let newState = yield player.getCurrentState();
|
||||
ok(newState.currentTime < state.currentTime,
|
||||
"The currentTime was updated to -2s");
|
||||
|
||||
yield closeDebuggerClient(client);
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
Loading…
Reference in New Issue
Block a user