Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: third_party/WebKit/LayoutTests/web-animations-api/timed-item.html

Issue 1944603003: Make AnimationEffectReadOnly.getComputedTiming() consistent with Web Animations spec (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 4
5 <body> 5 <body>
6 <div id='e'></div> 6 <div id='e'></div>
7 </body> 7 </body>
8 8
9 <script> 9 <script>
10 var element = document.getElementById('e'); 10 var element = document.getElementById('e');
11 var keyframes = [{opacity: '1', offset: 0}, {opacity: '0', offset: 1}]; 11 var keyframes = [{opacity: '1', offset: 0}, {opacity: '0', offset: 1}];
12 12
13 test(function() { 13 test(function() {
14 var keyframeEffect = new KeyframeEffect(element, keyframes); 14 var keyframeEffect = new KeyframeEffect(element, keyframes);
15 assert_equals(keyframeEffect.computedTiming.localTime, null); 15 assert_equals(keyframeEffect.getComputedTiming().localTime, null);
16 assert_equals(keyframeEffect.computedTiming.currentIteration, null); 16 assert_equals(keyframeEffect.getComputedTiming().currentIteration, null);
17 }, 'localTime and currentIteration are null when the KeyframeEffect is not assoc iated with an Animation'); 17 }, 'localTime and currentIteration are null when the KeyframeEffect is not assoc iated with an Animation');
18 18
19 test(function() { 19 test(function() {
20 var animation = element.animate(keyframes, {fill: 'both', duration: 2000, it erations: 3}); 20 var animation = element.animate(keyframes, {fill: 'both', duration: 2000, it erations: 3});
21 var keyframeEffect = animation.effect; 21 var keyframeEffect = animation.effect;
22 animation.currentTime = -1000; 22 animation.currentTime = -1000;
23 assert_equals(keyframeEffect.computedTiming.localTime, -1000, 'localTime'); 23 assert_equals(keyframeEffect.getComputedTiming().localTime, -1000, 'localTim e');
24 assert_equals(keyframeEffect.computedTiming.currentIteration, 0); 24 assert_equals(keyframeEffect.getComputedTiming().currentIteration, 0);
25 animation.currentTime = 1000; 25 animation.currentTime = 1000;
26 assert_equals(keyframeEffect.computedTiming.localTime, 1000); 26 assert_equals(keyframeEffect.getComputedTiming().localTime, 1000);
27 assert_equals(keyframeEffect.computedTiming.currentIteration, 0); 27 assert_equals(keyframeEffect.getComputedTiming().currentIteration, 0);
28 animation.currentTime = 5000; 28 animation.currentTime = 5000;
29 assert_equals(keyframeEffect.computedTiming.localTime, 5000); 29 assert_equals(keyframeEffect.getComputedTiming().localTime, 5000);
30 assert_equals(keyframeEffect.computedTiming.currentIteration, 2); 30 assert_equals(keyframeEffect.getComputedTiming().currentIteration, 2);
31 animation.currentTime = 7000; 31 animation.currentTime = 7000;
32 assert_equals(keyframeEffect.computedTiming.localTime, 7000); 32 assert_equals(keyframeEffect.getComputedTiming().localTime, 7000);
33 assert_equals(keyframeEffect.computedTiming.currentIteration, 2); 33 assert_equals(keyframeEffect.getComputedTiming().currentIteration, 2);
34 }, 'TimedItem.localTime and TimedItem.currentIteration return reasonable values when an keyframeEffect is in effect'); 34 }, 'TimedItem.localTime and TimedItem.currentIteration return reasonable values when an keyframeEffect is in effect');
35 35
36 test(function() { 36 test(function() {
37 var animation = element.animate(keyframes); 37 var animation = element.animate(keyframes);
38 var keyframeEffect = animation.effect; 38 var keyframeEffect = animation.effect;
39 animation.currentTime = -1; 39 animation.currentTime = -1;
40 assert_equals(keyframeEffect.computedTiming.currentIteration, null); 40 assert_equals(keyframeEffect.getComputedTiming().currentIteration, null);
41 animation.currentTime = 1; 41 animation.currentTime = 1;
42 assert_equals(keyframeEffect.computedTiming.currentIteration, null); 42 assert_equals(keyframeEffect.getComputedTiming().currentIteration, null);
43 }, 'TimedItem.currentIteration is null when keyframeEffect is not in effect'); 43 }, 'TimedItem.currentIteration is null when keyframeEffect is not in effect');
44 44
45 test(function() { 45 test(function() {
46 var keyframeEffect = new KeyframeEffect(element, keyframes, 2); 46 var keyframeEffect = new KeyframeEffect(element, keyframes, 2);
47 assert_equals(keyframeEffect.computedTiming.startTime, 0); 47 assert_equals(keyframeEffect.getComputedTiming().endTime, 2);
48 assert_equals(keyframeEffect.computedTiming.endTime, 2); 48 assert_equals(keyframeEffect.getComputedTiming().duration, 2);
49 assert_equals(keyframeEffect.computedTiming.duration, 2); 49 assert_equals(keyframeEffect.getComputedTiming().activeDuration, 2);
50 assert_equals(keyframeEffect.computedTiming.activeDuration, 2);
51 }, 'TimedItem startTime, endTime, duration, activeDuration are sensible for a si mple keyframeEffect'); 50 }, 'TimedItem startTime, endTime, duration, activeDuration are sensible for a si mple keyframeEffect');
52 51
53 test(function() { 52 test(function() {
54 var keyframeEffect = new KeyframeEffect(element, keyframes, {duration: 3, iter ations: 4, delay: 5}); 53 var keyframeEffect = new KeyframeEffect(element, keyframes, {duration: 3, iter ations: 4, delay: 5});
55 assert_equals(keyframeEffect.computedTiming.startTime, 0); 54 assert_equals(keyframeEffect.getComputedTiming().endTime, 17);
56 assert_equals(keyframeEffect.computedTiming.endTime, 17); 55 assert_equals(keyframeEffect.getComputedTiming().duration, 3);
57 assert_equals(keyframeEffect.computedTiming.duration, 3); 56 assert_equals(keyframeEffect.getComputedTiming().activeDuration, 12);
58 assert_equals(keyframeEffect.computedTiming.activeDuration, 12);
59 }, 'TimedItem startTime, endTime, duration, activeDuration are sensible for keyf rameEffects with delays and iterations'); 57 }, 'TimedItem startTime, endTime, duration, activeDuration are sensible for keyf rameEffects with delays and iterations');
60 58
61 test(function() { 59 test(function() {
62 var keyframeEffect = new KeyframeEffect(element, keyframes, {delay: 1}); 60 var keyframeEffect = new KeyframeEffect(element, keyframes, {delay: 1});
63 assert_equals(keyframeEffect.computedTiming.duration, 0); 61 assert_equals(keyframeEffect.getComputedTiming().duration, 0);
64 }, 'TimedItem duration is calculated when no duration is specified'); 62 }, 'TimedItem duration is calculated when no duration is specified');
65 63
66 test(function() { 64 test(function() {
67 var timing = new KeyframeEffect(element, keyframes).timing; 65 var timing = new KeyframeEffect(element, keyframes).timing;
68 for (var attr of ['delay', 'endDelay', 'iterationStart', 'playbackRate']) { 66 for (var attr of ['delay', 'endDelay', 'iterationStart', 'playbackRate']) {
69 assert_throws(new TypeError, function() { timing[attr] = NaN; }, attr); 67 assert_throws(new TypeError, function() { timing[attr] = NaN; }, attr);
70 assert_throws(new TypeError, function() { timing[attr] = Infinity; }, attr); 68 assert_throws(new TypeError, function() { timing[attr] = Infinity; }, attr);
71 } 69 }
72 }, 'Restricted double attributes on the Timing interface throws for non-finite v alues.'); 70 }, 'Restricted double attributes on the Timing interface throws for non-finite v alues.');
73 71
74 </script> 72 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698