Bug 1490583: Remove actor related code that no longer used. r=pbro

Differential Revision: https://phabricator.services.mozilla.com/D5842

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Daisuke Akatsuka 2018-09-18 12:41:53 +00:00
Родитель 1b004c7ba6
Коммит 55701049ee
14 изменённых файлов: 52 добавлений и 350 удалений

Просмотреть файл

@ -416,76 +416,6 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
}
},
/**
* Pause the player.
*/
pause: function() {
this.player.pause();
return this.player.ready;
},
/**
* Play the player.
* This method only returns when the animation has left its pending state.
*/
play: function() {
this.player.play();
return this.player.ready;
},
/**
* Simply exposes the player ready promise.
*
* When an animation is created/paused then played, there's a short time
* during which its playState is pending, before being set to running.
*
* If you either created a new animation using the Web Animations API or
* paused/played an existing one, and then want to access the playState, you
* might be interested to call this method.
* This is especially important for tests.
*/
ready: function() {
return this.player.ready;
},
/**
* Set the current time of the animation player.
*/
setCurrentTime: function(currentTime) {
// The spec is that the progress of animation is changed
// if the time of setCurrentTime is during the endDelay.
// We should prevent the time
// to make the same animation behavior as the original.
// Likewise, in case the time is less than 0.
const timing = this.player.effect.getComputedTiming();
if (timing.delay < 0) {
currentTime += timing.delay;
}
if (currentTime < 0) {
currentTime = 0;
} else if (currentTime * this.player.playbackRate > timing.endTime) {
currentTime = timing.endTime;
}
this.player.currentTime = currentTime * this.player.playbackRate;
},
/**
* Set the playback rate of the animation player.
*/
setPlaybackRate: function(playbackRate) {
this.player.updatePlaybackRate(playbackRate);
return this.player.ready;
},
/**
* 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: function() {
return this.player.effect.getKeyframes();
},
/**
* Get data about the animated properties of this animation player.
* @return {Array} Returns a list of animated properties.
@ -809,53 +739,6 @@ exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, {
}
},
/**
* Pause all animations in the current targetActor's frames.
*/
pauseAll: function() {
// Until the WebAnimations API provides a way to play/pause via the document
// timeline, we have to iterate through the whole DOM to find all players.
for (const player of
this.getAllAnimations(this.targetActor.window.document, true)) {
this.pauseSync(player);
}
this.allAnimationsPaused = true;
},
/**
* Play all animations in the current targetActor's frames.
* This method only returns when animations have left their pending states.
*/
playAll: function() {
// Until the WebAnimations API provides a way to play/pause via the document
// timeline, we have to iterate through the whole DOM to find all players.
for (const player of
this.getAllAnimations(this.targetActor.window.document, true)) {
this.playSync(player);
}
this.allAnimationsPaused = false;
},
toggleAll: function() {
if (this.allAnimationsPaused) {
this.playAll();
} else {
this.pauseAll();
}
},
/**
* Toggle (play/pause) several animations at the same time.
* @param {Array} players A list of AnimationPlayerActor objects.
* @param {Boolean} shouldPause If set to true, the players will be paused,
* otherwise they will be played.
*/
toggleSeveral: function(players, shouldPause) {
return Promise.all(players.map(player => {
return shouldPause ? player.pause() : player.play();
}));
},
/**
* Pause given animations.
*
@ -887,19 +770,8 @@ exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, {
* @param {Array} players A list of AnimationPlayerActor.
* @param {Number} time The new currentTime.
* @param {Boolean} shouldPause Should the players be paused too.
* @param {Object} options
* - relativeToCreatedTime: Set current path with createdTime.
*/
setCurrentTimes: function(players, time, shouldPause, options) {
// For backward compatibility for old animation inspector.
// We can drop following procedures after dropping old one.
if (!options.relativeToCreatedTime) {
return Promise.all(players.map(player => {
const pause = shouldPause ? player.pause() : Promise.resolve();
return pause.then(() => player.setCurrentTime(time));
}));
}
setCurrentTimes: function(players, time, shouldPause) {
for (const actor of players) {
const player = actor.player;
@ -915,13 +787,14 @@ exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, {
/**
* Set the playback rate of several animations at the same time.
* @param {Array} players A list of AnimationPlayerActor.
* @param {Array} actors A list of AnimationPlayerActor.
* @param {Number} rate The new rate.
*/
setPlaybackRates: function(players, rate) {
return Promise.all(
players.map(player => player.setPlaybackRate(rate))
);
return Promise.all(players.map(({ player }) => {
player.updatePlaybackRate(rate);
return player.ready;
}));
},
/**

Просмотреть файл

@ -40,7 +40,6 @@ support-files =
[browser_accessibility_walker.js]
[browser_actor_error.js]
[browser_animation_emitMutations.js]
[browser_animation_getFrames.js]
[browser_animation_getProperties.js]
[browser_animation_getMultipleStates.js]
[browser_animation_getPlayers.js]

Просмотреть файл

@ -1,30 +0,0 @@
/* 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.
add_task(async function() {
const {client, walker, animations} =
await initAnimationsFrontForUrl(MAIN_DOMAIN + "animation.html");
info("Get the test node and its animation front");
const node = await walker.querySelector(walker.rootNode, ".simple-animation");
const [player] = await animations.getAnimationPlayersForNode(node);
ok(player.getFrames, "The front has the getFrames method");
const frames = await 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.
await client.close();
gBrowser.removeCurrentTab();
});

Просмотреть файл

@ -43,7 +43,6 @@ async function getAnimationStateForNode(walker, animations, selector, playerInde
const node = await walker.querySelector(walker.rootNode, selector);
const players = await animations.getAnimationPlayersForNode(node);
const player = players[playerIndex];
await player.ready();
const state = await player.getCurrentState();
return state;
}

Просмотреть файл

@ -11,7 +11,6 @@ add_task(async function() {
await initAnimationsFrontForUrl(MAIN_DOMAIN + "animation.html");
await theRightNumberOfPlayersIsReturned(walker, animations);
await playersCanBePausedAndResumed(walker, animations);
await client.close();
gBrowser.removeCurrentTab();
@ -38,26 +37,3 @@ async function theRightNumberOfPlayersIsReturned(walker, animations) {
is(players.length, 1,
"One animation player was returned for the transitioned node");
}
async function playersCanBePausedAndResumed(walker, animations) {
const node = await walker.querySelector(walker.rootNode, ".simple-animation");
const [player] = await animations.getAnimationPlayersForNode(node);
await player.ready();
ok(player.initialState,
"The player has an initialState");
ok(player.getCurrentState,
"The player has the getCurrentState method");
is(player.initialState.playState, "running",
"The animation is currently running");
await player.pause();
let state = await player.getCurrentState();
is(state.playState, "paused",
"The animation is now paused");
await player.play();
state = await player.getCurrentState();
is(state.playState, "running",
"The animation is now running again");
}

Просмотреть файл

@ -22,22 +22,27 @@ add_task(async function() {
const nodeInFrame2 = await getNodeInFrame(walker, "#i2", ".simple-animation");
info("Pause all animations in the test document");
await animations.pauseAll();
await checkState(animations, nodeInFrame1, "paused");
await checkState(animations, nodeInFrame2, "paused");
await toggleAndCheckStates(animations, nodeInFrame1, "paused");
await toggleAndCheckStates(animations, nodeInFrame2, "paused");
info("Play all animations in the test document");
await animations.playAll();
await checkState(animations, nodeInFrame1, "running");
await checkState(animations, nodeInFrame2, "running");
await toggleAndCheckStates(animations, nodeInFrame1, "running");
await toggleAndCheckStates(animations, nodeInFrame2, "running");
await client.close();
gBrowser.removeCurrentTab();
});
async function checkState(animations, nodeFront, playState) {
info("Getting the AnimationPlayerFront for the test node");
async function toggleAndCheckStates(animations, nodeFront, playState) {
const [player] = await animations.getAnimationPlayersForNode(nodeFront);
if (playState === "paused") {
await animations.pauseSome([player]);
} else {
await animations.playSome([player]);
}
info("Getting the AnimationPlayerFront for the test node");
await player.ready;
const state = await player.getCurrentState();
is(state.playState, playState,

Просмотреть файл

@ -4,8 +4,7 @@
"use strict";
// Check that the AnimationsActor can pause/play all animations at once, and
// check that it can also pause/play a given list of animations at once.
// Check that the AnimationsActor can pause/play a given list of animations at once.
// List of selectors that match "all" animated nodes in the test page.
// This list misses a bunch of animated nodes on purpose. Only the ones that
@ -20,62 +19,30 @@ add_task(async function() {
await initAnimationsFrontForUrl(MAIN_DOMAIN + "animation.html");
info("Pause all animations in the test document");
await animations.pauseAll();
await checkStates(walker, animations, ALL_ANIMATED_NODES, "paused");
await toggleAndCheckStates(walker, animations, ALL_ANIMATED_NODES, "paused");
info("Play all animations in the test document");
await animations.playAll();
await checkStates(walker, animations, ALL_ANIMATED_NODES, "running");
info("Pause all animations in the test document using toggleAll");
await animations.toggleAll();
await checkStates(walker, animations, ALL_ANIMATED_NODES, "paused");
info("Play all animations in the test document using toggleAll");
await animations.toggleAll();
await checkStates(walker, animations, ALL_ANIMATED_NODES, "running");
info("Play all animations from multiple animated node using toggleSeveral");
const players = await getPlayersFor(walker, animations,
[".multiple-animations"]);
is(players.length, 2, "Node has 2 animation players");
await animations.toggleSeveral(players, false);
let state1 = await players[0].getCurrentState();
is(state1.playState, "running",
"The playState of the first player is running");
let state2 = await players[1].getCurrentState();
is(state2.playState, "running",
"The playState of the second player is running");
info("Pause one animation from a multiple animated node using toggleSeveral");
await animations.toggleSeveral([players[0]], true);
state1 = await players[0].getCurrentState();
is(state1.playState, "paused", "The playState of the first player is paused");
state2 = await players[1].getCurrentState();
is(state2.playState, "running",
"The playState of the second player is running");
info("Play the same animation");
await animations.toggleSeveral([players[0]], false);
state1 = await players[0].getCurrentState();
is(state1.playState, "running",
"The playState of the first player is running");
state2 = await players[1].getCurrentState();
is(state2.playState, "running",
"The playState of the second player is running");
await toggleAndCheckStates(walker, animations, ALL_ANIMATED_NODES, "running");
await client.close();
gBrowser.removeCurrentTab();
});
async function checkStates(walker, animations, selectors, playState) {
async function toggleAndCheckStates(walker, animations, selectors, playState) {
info("Checking the playState of all the nodes that have infinite running " +
"animations");
for (const selector of selectors) {
const players = await getPlayersFor(walker, animations, selector);
if (playState === "paused") {
await animations.pauseSome(players);
} else {
await animations.playSome(players);
}
info("Getting the AnimationPlayerFront for node " + selector);
const [player] = await getPlayersFor(walker, animations, selector);
await player.ready();
const player = players[0];
await checkPlayState(player, selector, playState);
}
}

Просмотреть файл

@ -73,8 +73,10 @@ async function playerStateIsCorrect(walker, animations) {
is(state.playState, "running", "Transition playState is correct");
is(state.playbackRate, 1, "Transition playbackRate is correct");
is(state.type, "csstransition", "Transition type is correct");
// chech easing in keyframe
let keyframes = await player.getFrames();
// check easing in properties
let properties = await player.getProperties();
is(properties.length, 1, "Length of animated properties is correct");
let keyframes = properties[0].values;
is(keyframes.length, 2, "Transition length of keyframe is correct");
is(keyframes[0].easing,
"ease-out", "Transition kerframes's easing is correct");
@ -94,7 +96,8 @@ async function playerStateIsCorrect(walker, animations) {
is(state.playState, "running", "The 2nd animation's playState is correct");
is(state.playbackRate, 1, "The 2nd animation's playbackRate is correct");
// chech easing in keyframe
keyframes = await player.getFrames();
properties = await player.getProperties();
keyframes = properties[0].values;
is(keyframes.length, 2, "The 2nd animation's length of keyframe is correct");
is(keyframes[0].easing,
"ease-out", "The 2nd animation's easing of kerframes is correct");
@ -118,6 +121,5 @@ async function getAnimationPlayerForNode(walker, animations, nodeSelector, index
const node = await walker.querySelector(walker.rootNode, nodeSelector);
const players = await animations.getAnimationPlayersForNode(node);
const player = players[index];
await player.ready();
return player;
}

Просмотреть файл

@ -20,7 +20,6 @@ add_task(async function() {
async function playerHasCompleteStateAtAllTimes(walker, animations) {
const node = await walker.querySelector(walker.rootNode, ".simple-animation");
const [player] = await animations.getAnimationPlayersForNode(node);
await player.ready();
// Get the list of state key names from the initialstate.
const keys = Object.keys(player.initialState);

Просмотреть файл

@ -4,53 +4,18 @@
"use strict";
// Check that a player's currentTime can be changed and that the AnimationsActor
// allows changing many players' currentTimes at once.
// Check that the AnimationsActor allows changing many players' currentTimes at once.
add_task(async function() {
const {client, walker, animations} =
await initAnimationsFrontForUrl(MAIN_DOMAIN + "animation.html");
await testSetCurrentTime(walker, animations);
await testSetCurrentTimes(walker, animations);
await client.close();
gBrowser.removeCurrentTab();
});
async function testSetCurrentTime(walker, animations) {
info("Retrieve an animated node");
const node = await walker.querySelector(walker.rootNode, ".simple-animation");
info("Retrieve the animation player for the node");
const [player] = await animations.getAnimationPlayersForNode(node);
ok(player.setCurrentTime, "Player has the setCurrentTime method");
info("Check that the setCurrentTime method can be called");
// Note that we don't check that it sets the animation to the right time here,
// this is too prone to intermittent failures, we'll do this later after
// pausing the animation. Here we merely test that the method doesn't fail.
await player.setCurrentTime(player.initialState.currentTime + 1000);
info("Pause the animation so we can really test if setCurrentTime works");
await player.pause();
const pausedState = await player.getCurrentState();
info("Set the current time to currentTime + 5s");
await player.setCurrentTime(pausedState.currentTime + 5000);
const updatedState1 = await player.getCurrentState();
is(Math.round(updatedState1.currentTime - pausedState.currentTime), 5000,
"The currentTime was updated to +5s");
info("Set the current time to currentTime - 2s");
await player.setCurrentTime(updatedState1.currentTime - 2000);
const updatedState2 = await player.getCurrentState();
is(Math.round(updatedState2.currentTime - updatedState1.currentTime), -2000,
"The currentTime was updated to -2s");
}
async function testSetCurrentTimes(walker, animations) {
ok(animations.setCurrentTimes, "The AnimationsActor has the right method");
@ -63,12 +28,15 @@ async function testSetCurrentTimes(walker, animations) {
ok(players.length > 1, "Node has more than 1 animation player");
info("Try to set multiple current times at once");
await animations.setCurrentTimes(players, 500, true);
// Assume that all animations were created at same time.
const createdTime = players[1].state.createdTime;
await animations.setCurrentTimes(players, createdTime + 500, true);
info("Get the states of players and verify their correctness");
for (let i = 0; i < players.length; i++) {
const state = await players[i].getCurrentState();
is(state.playState, "paused", `Player ${i + 1} is paused`);
is(state.currentTime, 500, `Player ${i + 1} has the right currentTime`);
is(parseInt(state.currentTime.toPrecision(6), 10), 500,
`Player ${i + 1} has the right currentTime`);
}
}

Просмотреть файл

@ -17,17 +17,15 @@ add_task(async function() {
info("Retrieve the animation player for the node");
const [player] = await animations.getAnimationPlayersForNode(node);
ok(player.setPlaybackRate, "Player has the setPlaybackRate method");
info("Change the rate to 10");
await player.setPlaybackRate(10);
await animations.setPlaybackRates([player], 10);
info("Query the state again");
let state = await player.getCurrentState();
is(state.playbackRate, 10, "The playbackRate was updated");
info("Change the rate back to 1");
await player.setPlaybackRate(1);
await animations.setPlaybackRates([player], 1);
info("Query the state again");
state = await player.getCurrentState();

Просмотреть файл

@ -13,9 +13,11 @@ add_task(async function() {
ok(animations, "The AnimationsFront was created");
ok(animations.getAnimationPlayersForNode,
"The getAnimationPlayersForNode method exists");
ok(animations.toggleAll, "The toggleAll method exists");
ok(animations.playAll, "The playAll method exists");
ok(animations.pauseAll, "The pauseAll method exists");
ok(animations.pauseSome, "The pauseSome method exists");
ok(animations.playSome, "The playSome method exists");
ok(animations.setCurrentTimes, "The setCurrentTimes method exists");
ok(animations.setPlaybackRates, "The setPlaybackRates method exists");
ok(animations.setWalkerActor, "The setWalkerActor method exists");
let didThrow = false;
try {

Просмотреть файл

@ -24,7 +24,6 @@ async function playStateIsUpdatedDynamically(walker, animations) {
info("Getting the animation player front for this node");
const [player] = await animations.getAnimationPlayersForNode(node);
await player.ready();
let state = await player.getCurrentState();
is(state.playState, "running",
@ -34,7 +33,7 @@ async function playStateIsUpdatedDynamically(walker, animations) {
"it to finish");
const onFinished = waitForAnimationPlayState(player, "finished");
// Set the currentTime to 98s, knowing that the animation lasts for 100s.
await player.setCurrentTime(98 * 1000);
await animations.setCurrentTimes([player], 98 * 1000, false);
state = await onFinished;
is(state.playState, "finished",
"The animation has ended and the state has been updated");

Просмотреть файл

@ -5,7 +5,6 @@
const {
Arg,
Option,
RetVal,
generateActorSpec,
types
@ -40,36 +39,6 @@ const animationPlayerSpec = generateActorSpec({
data: RetVal("json")
}
},
pause: {
request: {},
response: {}
},
play: {
request: {},
response: {}
},
ready: {
request: {},
response: {}
},
setCurrentTime: {
request: {
currentTime: Arg(0, "number")
},
response: {}
},
setPlaybackRate: {
request: {
currentTime: Arg(0, "number")
},
response: {}
},
getFrames: {
request: {},
response: {
frames: RetVal("json")
}
},
getProperties: {
request: {},
response: {
@ -114,29 +83,6 @@ const animationsSpec = generateActorSpec({
players: RetVal("array:animationplayer")
}
},
stopAnimationPlayerUpdates: {
request: {},
response: {}
},
pauseAll: {
request: {},
response: {}
},
playAll: {
request: {},
response: {}
},
toggleAll: {
request: {},
response: {}
},
toggleSeveral: {
request: {
players: Arg(0, "array:animationplayer"),
shouldPause: Arg(1, "boolean")
},
response: {}
},
pauseSome: {
request: {
players: Arg(0, "array:animationplayer"),
@ -154,7 +100,6 @@ const animationsSpec = generateActorSpec({
players: Arg(0, "array:animationplayer"),
time: Arg(1, "number"),
shouldPause: Arg(2, "boolean"),
relativeToCreatedTime: Option(3, "boolean"),
},
response: {}
},