From fb9e59da0e1af111e4610464d4f83a72dcff503a Mon Sep 17 00:00:00 2001 From: Alan Cutter Date: Tue, 26 Jul 2016 15:42:58 +1000 Subject: [PATCH 1/2] Do the fixings --- src/animation.js | 15 +++++++++++++-- src/web-animations-next-animation.js | 3 --- test/web-platform-tests-expectations.js | 8 -------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/animation.js b/src/animation.js index d1e7746..a5d6213 100644 --- a/src/animation.js +++ b/src/animation.js @@ -116,7 +116,10 @@ this._playbackRate = value; this._startTime = null; if (this.playState != 'paused' && this.playState != 'idle') { - this.play(); + this._finishedFlag = false; + this._idle = false; + this._ensureAlive(); + scope.invalidateEffects(); } if (oldCurrentTime != null) { this.currentTime = oldCurrentTime; @@ -141,7 +144,15 @@ play: function() { this._paused = false; if (this._isFinished || this._idle) { - this._currentTime = this._playbackRate > 0 ? 0 : this._totalDuration; + if (this._playbackRate >= 0) { + this._currentTime = 0; + } else if (this._totalDuration < Infinity) { + this._currentTime = this._totalDuration; + } else { + throw new DOMException( + 'Unable to rewind negative playback rate animation with infinite duration', + 'InvalidStateError'); + } this._startTime = null; } this._finishedFlag = false; diff --git a/src/web-animations-next-animation.js b/src/web-animations-next-animation.js index 9642e44..3ee673c 100644 --- a/src/web-animations-next-animation.js +++ b/src/web-animations-next-animation.js @@ -276,9 +276,6 @@ this._forEachChild(function(childAnimation) { childAnimation.playbackRate = value; }); - if (this.playState != 'paused' && this.playState != 'idle') { - this.play(); - } if (oldCurrentTime !== null) { this.currentTime = oldCurrentTime; } diff --git a/test/web-platform-tests-expectations.js b/test/web-platform-tests-expectations.js index a950ced..933607a 100644 --- a/test/web-platform-tests-expectations.js +++ b/test/web-platform-tests-expectations.js @@ -232,11 +232,6 @@ module.exports = { 'assert_throws: Expect InvalidStateError exception on calling pause() from idle with a negative playbackRate and infinite-duration animation function "function () {\n"use strict";\n animation.pause(); }" did not throw', }, - 'test/web-platform-tests/web-animations/interfaces/Animation/play.html': { - 'play() throws when seeking an infinite-duration animation played in reverse': - 'assert_throws: Expected InvalidStateError exception on calling play() with a negative playbackRate and infinite-duration animation function "function () {\n"use strict";\n animation.play(); }" did not throw', - }, - 'test/web-platform-tests/web-animations/interfaces/Animation/playState.html': { 'Animation.playState is \'paused\' after cancelling an animation, seeking it makes it paused': 'assert_equals: After seeking an idle animation, it is effectively paused expected "paused" but got "idle"', @@ -260,9 +255,6 @@ module.exports = { 'reverse() when playbackRate > 0 and currentTime < 0': 'assert_equals: reverse() should start playing from the animation effect end if the playbackRate > 0 and the currentTime < 0 expected 100000 but got -200000', - 'reverse() when playbackRate > 0 and currentTime < 0 and the target effect end is positive infinity': - 'assert_throws: reverse() should throw InvalidStateError if the playbackRate > 0 and the currentTime < 0 and the target effect is positive infinity function "function () {\n"use strict";\n animation.reverse(); }" did not throw', - 'reverse() when playbackRate > 0 and currentTime > effect end': 'assert_equals: reverse() should start playing from the animation effect end if the playbackRate > 0 and the currentTime > effect end expected 100000 but got 200000', }, From 667eba21131dc4e3cdd8578e6c9b5b26a9d197df Mon Sep 17 00:00:00 2001 From: Alan Cutter Date: Tue, 26 Jul 2016 17:06:37 +1000 Subject: [PATCH 2/2] Update expectations for finish.html --- test/web-platform-tests-expectations.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/web-platform-tests-expectations.js b/test/web-platform-tests-expectations.js index 933607a..f490fb9 100644 --- a/test/web-platform-tests-expectations.js +++ b/test/web-platform-tests-expectations.js @@ -176,10 +176,10 @@ module.exports = { 'KeyframeEffectReadOnly is not defined', 'Test finish() while pause-pending with negative playbackRate': - 'assert_equals: The start time of a pause-pending animation should be set after calling finish() expected (undefined) undefined but got (number) 100000', + 'assert_equals: The play state of a pause-pending animation should become "finished" after finish() is called expected "finished" but got "paused"', 'Test finish() while pause-pending with positive playbackRate': - 'assert_approx_equals: The start time of a pause-pending animation should be set after calling finish() expected NaN +/- 0.0005 but got 0', + 'assert_equals: The play state of a pause-pending animation should become "finished" after finish() is called expected "finished" but got "paused"', 'Test finish() while paused': 'assert_equals: The play state of a paused animation should become "finished" after finish() is called expected "finished" but got "paused"',