Bug 1197100 - 1 - Add getFrames method to the AnimationPlayerActor; r=miker

This commit is contained in:
Patrick Brosset 2015-09-29 14:53:15 +02:00
parent 74f841a8a1
commit 0504434ab1
4 changed files with 59 additions and 1 deletions

View File

@ -89,7 +89,9 @@ var getServerTraits = Task.async(function*(target) {
{ name: "hasTargetNode", actor: "domwalker",
method: "getNodeFromActor" },
{ name: "hasSetCurrentTimes", actor: "animations",
method: "setCurrentTimes" }
method: "setCurrentTimes" },
{ name: "hasGetFrames", actor: "animationplayer",
method: "getFrames" }
];
let traits = {};

View File

@ -414,6 +414,20 @@ var AnimationPlayerActor = ActorClass({
currentTime: Arg(0, "number")
},
response: {}
}),
/**
* Get data about the keyframes of this animation player.
* @return {Object} Returns a list of frames, each frame containing the list
* animated properties as well as the frame's offset.
*/
getFrames: method(function() {
return this.player.effect.getFrames();
}, {
request: {},
response: {
frames: RetVal("json")
}
})
});

View File

@ -37,6 +37,7 @@ skip-if = e10s # Bug 1183605 - devtools/server/tests/browser/ tests are still di
[browser_animation_actors_14.js]
[browser_animation_actors_15.js]
[browser_animation_actors_16.js]
[browser_animation_actors_17.js]
[browser_canvasframe_helper_01.js]
skip-if = e10s # Bug 1183605 - devtools/server/tests/browser/ tests are still disabled in E10S
[browser_canvasframe_helper_02.js]

View File

@ -0,0 +1,41 @@
/* 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 the AnimationPlayerActor exposes a getFrames method that returns
// the list of keyframes in the animation.
const {AnimationsFront} = require("devtools/server/actors/animation");
const {InspectorFront} = require("devtools/server/actors/inspector");
const URL = MAIN_DOMAIN + "animation.html";
add_task(function*() {
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 front = AnimationsFront(client, form);
info("Get the test node and its animation front");
let node = yield walker.querySelector(walker.rootNode, ".simple-animation");
let [player] = yield front.getAnimationPlayersForNode(node);
ok(player.getFrames, "The front has the getFrames method");
let frames = yield player.getFrames();
is(frames.length, 2, "The correct number of keyframes was retrieved");
ok(frames[0].transform, "Frame 0 has the transform property");
ok(frames[1].transform, "Frame 1 has the transform property");
// Note that we don't really test the content of the frame object here on
// purpose. This object comes straight out of the web animations API
// unmodified.
yield closeDebuggerClient(client);
gBrowser.removeCurrentTab();
});