From 5abe552c97cf090c2bc45c92f551078a1650b613 Mon Sep 17 00:00:00 2001 From: Mantaroh Yoshinaga Date: Wed, 20 Apr 2016 08:26:43 +0900 Subject: [PATCH] Bug 1260084 - Part3.Remove unnecessary css animation mochitest. r=birtles MozReview-Commit-ID: JgplbS9F57L --HG-- extra : transplant_source : _%A3K%E65%1A%10%D1%2B%A6%B6%E7%8F%2B%13%A8%B9%21f%9B --- .../file_animation-finished.html | 382 ------------------ .../css-animations/file_animation-id.html | 8 + .../file_animation-oncancel.html | 34 -- .../file_animation-onfinish.html | 133 ------ .../file_animation-pausing.html | 97 +---- .../css-animations/file_animation-ready.html | 91 ----- .../file_animation-reverse.html | 129 ------ .../test_animation-oncancel.html | 15 - .../test_animation-onfinish.html | 15 - dom/animation/test/mochitest.ini | 4 - 10 files changed, 13 insertions(+), 895 deletions(-) delete mode 100644 dom/animation/test/css-animations/file_animation-oncancel.html delete mode 100644 dom/animation/test/css-animations/file_animation-onfinish.html delete mode 100644 dom/animation/test/css-animations/test_animation-oncancel.html delete mode 100644 dom/animation/test/css-animations/test_animation-onfinish.html diff --git a/dom/animation/test/css-animations/file_animation-finished.html b/dom/animation/test/css-animations/file_animation-finished.html index 1b31204c6a80..c296abb11728 100644 --- a/dom/animation/test/css-animations/file_animation-finished.html +++ b/dom/animation/test/css-animations/file_animation-finished.html @@ -14,147 +14,6 @@ const ANIM_PROP_VAL = 'abc 100s'; const ANIM_DURATION = 100 * MS_PER_SEC; -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - var previousFinishedPromise = animation.finished; - return animation.ready.then(function() { - assert_equals(animation.finished, previousFinishedPromise, - 'Finished promise is the same object when playing starts'); - animation.pause(); - assert_equals(animation.finished, previousFinishedPromise, - 'Finished promise does not change when pausing'); - animation.play(); - assert_equals(animation.finished, previousFinishedPromise, - 'Finished promise does not change when play() unpauses'); - - animation.currentTime = ANIM_DURATION; - - return animation.finished; - }).then(function() { - assert_equals(animation.finished, previousFinishedPromise, - 'Finished promise is the same object when playing completes'); - }); -}, 'Test pausing then playing does not change the finished promise'); - -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - var previousFinishedPromise = animation.finished; - animation.finish(); - return animation.finished.then(function() { - assert_equals(animation.finished, previousFinishedPromise, - 'Finished promise is the same object when playing completes'); - animation.play(); - assert_not_equals(animation.finished, previousFinishedPromise, - 'Finished promise changes when replaying animation'); - - previousFinishedPromise = animation.finished; - animation.play(); - assert_equals(animation.finished, previousFinishedPromise, - 'Finished promise is the same after redundant play() call'); - - }); -}, 'Test restarting a finished animation'); - -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - var previousFinishedPromise; - animation.finish(); - return animation.finished.then(function() { - previousFinishedPromise = animation.finished; - animation.playbackRate = -1; - assert_not_equals(animation.finished, previousFinishedPromise, - 'Finished promise should be replaced when reversing a ' + - 'finished promise'); - animation.currentTime = 0; - return animation.finished; - }).then(function() { - previousFinishedPromise = animation.finished; - animation.play(); - assert_not_equals(animation.finished, previousFinishedPromise, - 'Finished promise is replaced after play() call on ' + - 'finished, reversed animation'); - }); -}, 'Test restarting a reversed finished animation'); - -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - var previousFinishedPromise = animation.finished; - animation.finish(); - return animation.finished.then(function() { - animation.currentTime = ANIM_DURATION + 1000; - assert_equals(animation.finished, previousFinishedPromise, - 'Finished promise is unchanged jumping past end of ' + - 'finished animation'); - }); -}, 'Test redundant finishing of animation'); - -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - // Setup callback to run if finished promise is resolved - var finishPromiseResolved = false; - animation.finished.then(function() { - finishPromiseResolved = true; - }); - return animation.ready.then(function() { - // Jump to mid-way in interval and pause - animation.currentTime = ANIM_DURATION / 2; - animation.pause(); - return animation.ready; - }).then(function() { - // Jump to the end - // (But don't use finish() since that should unpause as well) - animation.currentTime = ANIM_DURATION; - return waitForAnimationFrames(2); - }).then(function() { - assert_false(finishPromiseResolved, - 'Finished promise should not resolve when paused'); - }); -}, 'Finished promise does not resolve when paused'); - -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - // Setup callback to run if finished promise is resolved - var finishPromiseResolved = false; - animation.finished.then(function() { - finishPromiseResolved = true; - }); - return animation.ready.then(function() { - // Jump to mid-way in interval and pause - animation.currentTime = ANIM_DURATION / 2; - animation.pause(); - // Jump to the end - animation.currentTime = ANIM_DURATION; - return waitForAnimationFrames(2); - }).then(function() { - assert_false(finishPromiseResolved, - 'Finished promise should not resolve when pause-pending'); - }); -}, 'Finished promise does not resolve when pause-pending'); - -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - animation.currentTime = ANIM_DURATION; - return animation.finished.then(function(resolvedAnimation) { - assert_equals(resolvedAnimation, animation, - 'Object identity of animation passed to Promise callback' - + ' matches the animation object owning the Promise'); - }); -}, 'The finished promise is fulfilled with its Animation'); - promise_test(function(t) { var div = addDiv(t); // Set up pending animation @@ -210,133 +69,6 @@ promise_test(function(t) { }, 'finished promise is rejected when an animation is cancelled by changing ' + 'the animation property'); -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - var previousFinishedPromise = animation.finished; - - // Set up listeners on finished promise - var retPromise = animation.finished.then(function() { - assert_unreached('finished promise was fulfilled'); - }).catch(function(err) { - assert_equals(err.name, 'AbortError', - 'finished promise is rejected with AbortError'); - assert_not_equals(animation.finished, previousFinishedPromise, - 'Finished promise should change after the original is ' + - 'rejected'); - }); - - animation.cancel(); - - return retPromise; -}, 'finished promise is rejected when an animation is cancelled by calling ' + - 'cancel()'); - -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - var previousFinishedPromise = animation.finished; - animation.currentTime = ANIM_DURATION; - return animation.finished.then(function() { - animation.cancel(); - assert_not_equals(animation.finished, previousFinishedPromise, - 'A new finished promise should be created when' - + ' cancelling a finished animation'); - }); -}, 'cancelling an already-finished animation replaces the finished promise'); - -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - animation.cancel(); - // The spec says we still create a new finished promise and reject the old - // one even if we're already idle. That behavior might change, but for now - // test that we do that. - var retPromise = animation.finished.catch(function(err) { - assert_equals(err.name, 'AbortError', - 'finished promise is rejected with AbortError'); - }); - - // Redundant call to cancel(); - var previousFinishedPromise = animation.finished; - animation.cancel(); - assert_not_equals(animation.finished, previousFinishedPromise, - 'A redundant call to cancel() should still generate a new' - + ' finished promise'); - return retPromise; -}, 'cancelling an idle animation still replaces the finished promise'); - -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - const HALF_DUR = ANIM_DURATION / 2; - const QUARTER_DUR = ANIM_DURATION / 4; - var gotNextFrame = false; - var currentTimeBeforeShortening; - animation.currentTime = HALF_DUR; - return animation.ready.then(function() { - currentTimeBeforeShortening = animation.currentTime; - div.style.animationDuration = QUARTER_DUR + 'ms'; - window.getComputedStyle(div).animationDuration; // flush style - // Animation should now be finished - - // Below we use gotNextFrame to check that shortening of the animation - // duration causes the finished promise to resolve, rather than it just - // getting resolved on the next animation frame. This relies on the fact - // that the promises are resolved as a micro-task before the next frame - // happens. - waitForFrame().then(function() { - gotNextFrame = true; - }); - - return animation.finished; - }).then(function() { - assert_false(gotNextFrame, 'shortening of the animation duration should ' + - 'resolve the finished promise'); - assert_equals(animation.currentTime, currentTimeBeforeShortening, - 'currentTime should be unchanged when duration shortened'); - var previousFinishedPromise = animation.finished; - div.style.animationDuration = ANIM_DURATION + 'ms'; // now active again - window.getComputedStyle(div).animationDuration; // flush style - assert_not_equals(animation.finished, previousFinishedPromise, - 'Finished promise should change after lengthening the ' + - 'duration causes the animation to become active'); - }); -}, 'Test finished promise changes for animation duration changes'); - -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - var retPromise = animation.ready.then(function() { - animation.playbackRate = 0; - animation.currentTime = ANIM_DURATION + 1000; - return waitForAnimationFrames(2); - }); - - animation.finished.then(t.step_func(function() { - assert_unreached('finished promise should not resolve when playbackRate ' + - 'is zero'); - })); - - return retPromise; -}, 'Test finished promise changes when playbackRate == 0'); - -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - - return animation.ready.then(function() { - animation.playbackRate = -1; - return animation.finished; - }); -}, 'Test finished promise resolves when playbackRate set to a negative value'); - promise_test(function(t) { var div = addDiv(t); div.style.animation = ANIM_PROP_VAL; @@ -356,120 +88,6 @@ promise_test(function(t) { }); }, 'Test finished promise changes when animationPlayState set to running'); -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - var previousFinishedPromise = animation.finished; - animation.currentTime = ANIM_DURATION; - return animation.finished.then(function() { - animation.currentTime = 0; - assert_not_equals(animation.finished, previousFinishedPromise, - 'Finished promise should change once a prior ' + - 'finished promise resolved and the animation ' + - 'falls out finished state'); - }); -}, 'Test finished promise changes when a prior finished promise resolved ' + - 'and the animation falls out finished state'); - -test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - var previousFinishedPromise = animation.finished; - animation.currentTime = ANIM_DURATION; - animation.currentTime = ANIM_DURATION / 2; - assert_equals(animation.finished, previousFinishedPromise, - 'No new finished promise generated when finished state ' + - 'is checked asynchronously'); -}, 'Test no new finished promise generated when finished state ' + - 'is checked asynchronously'); - -test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - var previousFinishedPromise = animation.finished; - animation.finish(); - animation.currentTime = ANIM_DURATION / 2; - assert_not_equals(animation.finished, previousFinishedPromise, - 'New finished promise generated when finished state ' + - 'is checked synchronously'); -}, 'Test new finished promise generated when finished state ' + - 'is checked synchronously'); - -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - var resolvedFinished = false; - animation.finished.then(function() { - resolvedFinished = true; - }); - return animation.ready.then(function() { - animation.finish(); - animation.currentTime = ANIM_DURATION / 2; - }).then(function() { - assert_true(resolvedFinished, - 'Animation.finished should be resolved even if ' + - 'the finished state is changed soon'); - }); - -}, 'Test synchronous finished promise resolved even if finished state ' + - 'is changed soon'); - -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - var resolvedFinished = false; - animation.finished.then(function() { - resolvedFinished = true; - }); - - return animation.ready.then(function() { - animation.currentTime = ANIM_DURATION; - animation.finish(); - }).then(function() { - assert_true(resolvedFinished, - 'Animation.finished should be resolved soon after finish() is ' + - 'called even if there are other asynchronous promises just before it'); - }); -}, 'Test synchronous finished promise resolved even if asynchronous ' + - 'finished promise happens just before synchronous promise'); - -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - animation.finished.then(t.step_func(function() { - assert_unreached('Animation.finished should not be resolved'); - })); - - return animation.ready.then(function() { - animation.currentTime = ANIM_DURATION; - animation.currentTime = ANIM_DURATION / 2; - }); -}, 'Test finished promise is not resolved when the animation ' + - 'falls out finished state immediately'); - -promise_test(function(t) { - var div = addDiv(t); - div.style.animation = ANIM_PROP_VAL; - var animation = div.getAnimations()[0]; - - return animation.ready.then(function() { - animation.currentTime = ANIM_DURATION; - animation.finished.then(t.step_func(function() { - assert_unreached('Animation.finished should not be resolved'); - })); - animation.currentTime = 0; - }); - -}, 'Test finished promise is not resolved once the animation ' + - 'falls out finished state even though the current finished ' + - 'promise is generated soon after animation state became finished'); - done(); diff --git a/dom/animation/test/css-animations/file_animation-id.html b/dom/animation/test/css-animations/file_animation-id.html index dbd5ee0eef37..412616a7ad38 100644 --- a/dom/animation/test/css-animations/file_animation-id.html +++ b/dom/animation/test/css-animations/file_animation-id.html @@ -18,6 +18,14 @@ test(function(t) { assert_equals(animation.id, 'anim', 'animation.id reflects the value set'); }, 'Animation.id for CSS Animations'); +test(function(t) { + var div = addDiv(t); + var animation = div.animate({}, 100 * MS_PER_SEC); + assert_equals(animation.id, '', 'id for CSS Animation is initially empty'); + animation.id = 'anim' + + assert_equals(animation.id, 'anim', 'animation.id reflects the value set'); +}, 'Animation.id for CSS Animations'); done(); diff --git a/dom/animation/test/css-animations/file_animation-oncancel.html b/dom/animation/test/css-animations/file_animation-oncancel.html deleted file mode 100644 index 618cc7e448eb..000000000000 --- a/dom/animation/test/css-animations/file_animation-oncancel.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - diff --git a/dom/animation/test/css-animations/file_animation-onfinish.html b/dom/animation/test/css-animations/file_animation-onfinish.html deleted file mode 100644 index 38f08a0beb47..000000000000 --- a/dom/animation/test/css-animations/file_animation-onfinish.html +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - - diff --git a/dom/animation/test/css-animations/file_animation-pausing.html b/dom/animation/test/css-animations/file_animation-pausing.html index 817b4f277b4d..7176a0c1d6c8 100644 --- a/dom/animation/test/css-animations/file_animation-pausing.html +++ b/dom/animation/test/css-animations/file_animation-pausing.html @@ -18,26 +18,17 @@ function getMarginLeft(cs) { promise_test(function(t) { var div = addDiv(t); var cs = window.getComputedStyle(div); - div.style.animation = 'anim 1000s'; + div.style.animation = 'anim 1000s paused'; var animation = div.getAnimations()[0]; - assert_equals(getMarginLeft(cs), 0, 'Initial value of margin-left is zero'); - var previousAnimVal = getMarginLeft(cs); + animation.play(); return animation.ready.then(waitForFrame).then(function() { - assert_true(getMarginLeft(cs) > previousAnimVal, - 'margin-left is initially increasing'); - animation.pause(); - return animation.ready; - }).then(function() { - previousAnimVal = getMarginLeft(cs); - return waitForFrame(); - }).then(function() { - assert_equals(getMarginLeft(cs), previousAnimVal, - 'margin-left does not increase after calling pause()'); + assert_true(getMarginLeft(cs) > 0, + 'Playing value of margin-left is greater than zero'); }); -}, 'pause() a running animation'); +}, 'play() overrides animation-play-state'); promise_test(function(t) { var div = addDiv(t); @@ -58,21 +49,6 @@ promise_test(function(t) { }); }, 'pause() overrides animation-play-state'); -promise_test(function(t) { - var div = addDiv(t); - var cs = window.getComputedStyle(div); - div.style.animation = 'anim 1000s paused'; - var animation = div.getAnimations()[0]; - assert_equals(getMarginLeft(cs), 0, - 'Initial value of margin-left is zero'); - animation.play(); - - return animation.ready.then(waitForFrame).then(function() { - assert_true(getMarginLeft(cs) > 0, - 'Playing value of margin-left is greater than zero'); - }); -}, 'play() overrides animation-play-state'); - promise_test(function(t) { var div = addDiv(t); var cs = window.getComputedStyle(div); @@ -184,69 +160,6 @@ promise_test(function(t) { }); }, 'Setting the current time completes a pending pause'); -promise_test(function(t) { - var div = addDiv(t, { style: 'animation: anim 1000s' }); - var animation = div.getAnimations()[0]; - - // Go to idle state then pause - animation.cancel(); - animation.pause(); - - assert_equals(animation.currentTime, 0, 'currentTime is set to 0'); - assert_equals(animation.startTime, null, 'startTime is not set'); - assert_equals(animation.playState, 'pending', 'initially pause-pending'); - - // Check it still resolves as expected - return animation.ready.then(function() { - assert_equals(animation.playState, 'paused', - 'resolves to paused state asynchronously'); - assert_equals(animation.currentTime, 0, - 'keeps the initially set currentTime'); - }); -}, 'pause() from idle'); - -promise_test(function(t) { - var div = addDiv(t, { style: 'animation: anim 1000s' }); - var animation = div.getAnimations()[0]; - animation.cancel(); - animation.playbackRate = -1; - animation.pause(); - - assert_equals(animation.currentTime, 1000 * MS_PER_SEC, - 'currentTime is set to the effect end'); - - return animation.ready.then(function() { - assert_equals(animation.currentTime, 1000 * MS_PER_SEC, - 'keeps the initially set currentTime'); - }); -}, 'pause() from idle with a negative playbackRate'); - -test(function(t) { - var div = addDiv(t, { style: 'animation: anim 1000s infinite' }); - var animation = div.getAnimations()[0]; - animation.cancel(); - animation.playbackRate = -1; - - assert_throws('InvalidStateError', - function () { animation.pause(); }, - 'Expect InvalidStateError exception on calling pause() ' + - 'from idle with a negative playbackRate and ' + - 'infinite-duration animation'); -}, 'pause() from idle with a negative playbackRate and endless effect'); - -promise_test(function(t) { - var div = addDiv(t, { style: 'animation: anim 1000s' }); - return div.getAnimations()[0].ready - .then(function(animation) { - animation.finish(); - animation.pause(); - return animation.ready; - }).then(function(animation) { - assert_equals(animation.currentTime, 1000 * MS_PER_SEC, - 'currentTime after pausing finished animation'); - }); -}, 'pause() on a finished animation'); - done(); diff --git a/dom/animation/test/css-animations/file_animation-ready.html b/dom/animation/test/css-animations/file_animation-ready.html index 75521dff1a38..9318a1a1828f 100644 --- a/dom/animation/test/css-animations/file_animation-ready.html +++ b/dom/animation/test/css-animations/file_animation-ready.html @@ -10,30 +10,6 @@ diff --git a/dom/animation/test/css-animations/test_animation-oncancel.html b/dom/animation/test/css-animations/test_animation-oncancel.html deleted file mode 100644 index 94b5f92fb06f..000000000000 --- a/dom/animation/test/css-animations/test_animation-oncancel.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - -
- - diff --git a/dom/animation/test/css-animations/test_animation-onfinish.html b/dom/animation/test/css-animations/test_animation-onfinish.html deleted file mode 100644 index 2e7d70e6fcc5..000000000000 --- a/dom/animation/test/css-animations/test_animation-onfinish.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - -
- - diff --git a/dom/animation/test/mochitest.ini b/dom/animation/test/mochitest.ini index 4f3990fda306..1801077e69de 100644 --- a/dom/animation/test/mochitest.ini +++ b/dom/animation/test/mochitest.ini @@ -9,8 +9,6 @@ support-files = css-animations/file_animation-finish.html css-animations/file_animation-finished.html css-animations/file_animation-id.html - css-animations/file_animation-oncancel.html - css-animations/file_animation-onfinish.html css-animations/file_animation-pausing.html css-animations/file_animation-playstate.html css-animations/file_animation-ready.html @@ -49,8 +47,6 @@ support-files = [css-animations/test_animation-finish.html] [css-animations/test_animation-finished.html] [css-animations/test_animation-id.html] -[css-animations/test_animation-oncancel.html] -[css-animations/test_animation-onfinish.html] [css-animations/test_animation-pausing.html] [css-animations/test_animation-playstate.html] [css-animations/test_animation-ready.html]