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