OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset=utf-8> |
| 3 <title>Animation.cancel()</title> |
| 4 <link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-cance
l"> |
| 5 <script src="../../../../resources/testharness.js"></script> |
| 6 <script src="../../../../resources/testharnessreport.js"></script> |
| 7 <script src="../testcommon.js"></script> |
| 8 <link rel="stylesheet" href="../../../../resources/testharness.css"> |
| 9 <body> |
| 10 <div id="log"></div> |
| 11 <script> |
| 12 'use strict'; |
| 13 |
| 14 promise_test(function(t) { |
| 15 var div = createDiv(t); |
| 16 var animation = div.animate({transform: ['none', 'translate(100px)']}, |
| 17 100 * MS_PER_SEC); |
| 18 return animation.ready.then(function() { |
| 19 assert_not_equals(getComputedStyle(div).transform, 'none', |
| 20 'transform style is animated before cancelling'); |
| 21 animation.cancel(); |
| 22 assert_equals(getComputedStyle(div).transform, 'none', |
| 23 'transform style is no longer animated after cancelling'); |
| 24 }); |
| 25 }, 'Animated style is cleared after calling Animation.cancel()'); |
| 26 |
| 27 test(function(t) { |
| 28 var div = createDiv(t); |
| 29 var animation = div.animate({marginLeft: ['0px', '100px']}, |
| 30 100 * MS_PER_SEC); |
| 31 animation.effect.timing.easing = 'linear'; |
| 32 animation.cancel(); |
| 33 assert_equals(getComputedStyle(div).marginLeft, '0px', |
| 34 'margin-left style is not animated after cancelling'); |
| 35 |
| 36 animation.currentTime = 50 * MS_PER_SEC; |
| 37 assert_equals(getComputedStyle(div).marginLeft, '50px', |
| 38 'margin-left style is updated when cancelled animation is' |
| 39 + ' seeked'); |
| 40 }, 'After cancelling an animation, it can still be seeked'); |
| 41 |
| 42 promise_test(function(t) { |
| 43 var div = createDiv(t); |
| 44 var animation = div.animate({marginLeft:['100px', '200px']}, |
| 45 100 * MS_PER_SEC); |
| 46 return animation.ready.then(function() { |
| 47 animation.cancel(); |
| 48 assert_equals(getComputedStyle(div).marginLeft, '0px', |
| 49 'margin-left style is not animated after cancelling'); |
| 50 animation.play(); |
| 51 assert_equals(getComputedStyle(div).marginLeft, '100px', |
| 52 'margin-left style is animated after re-starting animation'); |
| 53 return animation.ready; |
| 54 }).then(function() { |
| 55 assert_equals(animation.playState, 'running', |
| 56 'Animation succeeds in running after being re-started'); |
| 57 }); |
| 58 }, 'After cancelling an animation, it can still be re-used'); |
| 59 |
| 60 </script> |
| 61 </body> |
OLD | NEW |