| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <meta charset=utf-8> | |
| 3 <title>getComputedStyle tests</title> | |
| 4 <link rel="help" href="http://w3c.github.io/web-animations/#animationeffecttimin
g"> | |
| 5 <link rel="author" title="Ryo Motozawa" href="mailto:motozawa@mozilla-japan.org"
> | |
| 6 <script src="../../../../resources/testharness.js"></script> | |
| 7 <script src="../../../../resources/testharnessreport.js"></script> | |
| 8 <script src="../testcommon.js"></script> | |
| 9 <body> | |
| 10 <div id="log"></div> | |
| 11 <script> | |
| 12 'use strict'; | |
| 13 | |
| 14 test(function(t) { | |
| 15 var div = createDiv(t); | |
| 16 var anim = div.animate({ opacity: [ 0, 1 ] }, 100000); | |
| 17 anim.finish(); | |
| 18 assert_equals(getComputedStyle(div).opacity, '1', 'animation finished'); | |
| 19 anim.effect.timing.duration *= 2; | |
| 20 assert_equals(getComputedStyle(div).opacity, '0.5', 'set double duration'); | |
| 21 anim.effect.timing.duration = 0; | |
| 22 assert_equals(getComputedStyle(div).opacity, '1', 'set duration 0'); | |
| 23 anim.effect.timing.duration = 'auto'; | |
| 24 assert_equals(getComputedStyle(div).opacity, '1', 'set duration \'auto\''); | |
| 25 }, 'changed duration immediately updates its computed styles'); | |
| 26 | |
| 27 test(function(t) { | |
| 28 var div = createDiv(t); | |
| 29 var anim = div.animate({ opacity: [ 1, 0 ] }, | |
| 30 { duration: 10000, endDelay: 1000, fill: 'none' }); | |
| 31 | |
| 32 anim.currentTime = 9000; | |
| 33 assert_equals(getComputedStyle(div).opacity, '0.1', | |
| 34 'set currentTime during duration'); | |
| 35 | |
| 36 anim.currentTime = 10900; | |
| 37 assert_equals(getComputedStyle(div).opacity, '1', | |
| 38 'set currentTime during endDelay'); | |
| 39 | |
| 40 anim.currentTime = 11100; | |
| 41 assert_equals(getComputedStyle(div).opacity, '1', | |
| 42 'set currentTime after endDelay'); | |
| 43 }, 'change currentTime when fill is none and endDelay is positive'); | |
| 44 | |
| 45 test(function(t) { | |
| 46 var div = createDiv(t); | |
| 47 var anim = div.animate({ opacity: [ 1, 0 ] }, | |
| 48 { duration: 10000, | |
| 49 endDelay: 1000, | |
| 50 fill: 'forwards' }); | |
| 51 anim.currentTime = 5000; | |
| 52 assert_equals(getComputedStyle(div).opacity, '0.5', | |
| 53 'set currentTime during duration'); | |
| 54 | |
| 55 anim.currentTime = 9999; | |
| 56 assert_equals(getComputedStyle(div).opacity, '0.0001', | |
| 57 'set currentTime just a little before duration'); | |
| 58 | |
| 59 anim.currentTime = 10900; | |
| 60 assert_equals(getComputedStyle(div).opacity, '0', | |
| 61 'set currentTime during endDelay'); | |
| 62 | |
| 63 anim.currentTime = 11100; | |
| 64 assert_equals(getComputedStyle(div).opacity, '0', | |
| 65 'set currentTime after endDelay'); | |
| 66 }, 'change currentTime when fill forwards and endDelay is positive'); | |
| 67 | |
| 68 test(function(t) { | |
| 69 var div = createDiv(t); | |
| 70 var anim = div.animate({ opacity: [ 1, 0 ] }, | |
| 71 { duration: 10000, endDelay: -5000, fill: 'none' }); | |
| 72 | |
| 73 anim.currentTime = 1000; | |
| 74 assert_equals(getComputedStyle(div).opacity, '0.9', | |
| 75 'set currentTime before endTime'); | |
| 76 | |
| 77 anim.currentTime = 10000; | |
| 78 assert_equals(getComputedStyle(div).opacity, '1', | |
| 79 'set currentTime after endTime'); | |
| 80 }, 'change currentTime when fill none and endDelay is negative'); | |
| 81 | |
| 82 test(function(t) { | |
| 83 var div = createDiv(t); | |
| 84 var anim = div.animate({ opacity: [ 1, 0 ] }, | |
| 85 { duration: 10000, | |
| 86 endDelay: -5000, | |
| 87 fill: 'forwards' }); | |
| 88 | |
| 89 anim.currentTime = 1000; | |
| 90 assert_equals(getComputedStyle(div).opacity, '0.9', | |
| 91 'set currentTime before endTime'); | |
| 92 | |
| 93 anim.currentTime = 5000; | |
| 94 assert_equals(getComputedStyle(div).opacity, '0', | |
| 95 'set currentTime same as endTime'); | |
| 96 | |
| 97 anim.currentTime = 9999; | |
| 98 assert_equals(getComputedStyle(div).opacity, '0', | |
| 99 'set currentTime during duration'); | |
| 100 | |
| 101 anim.currentTime = 10000; | |
| 102 assert_equals(getComputedStyle(div).opacity, '0', | |
| 103 'set currentTime after endTime'); | |
| 104 }, 'change currentTime when fill forwards and endDelay is negative'); | |
| 105 | |
| 106 </script> | |
| 107 </body> | |
| OLD | NEW |