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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/keyframe-effect/keyframe-handling.html

Issue 1984133002: Move web-platform-tests to wpt (part 2 of 2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
(Empty)
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>Keyframe handling tests</title>
4 <link rel="help" href="https://w3c.github.io/web-animations/#the-effect-value-of -a-keyframe-animation-effect">
5 <link rel="author" title="Brian Birtles" href="mailto:bbirtles@mozilla.com">
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 <div id="target"></div>
12 <script>
13 'use strict';
14
15 test(function(t) {
16 var div = createDiv(t);
17 var anim = div.animate([ { offset: 0, opacity: 0 },
18 { offset: 0, opacity: 0.1 },
19 { offset: 0, opacity: 0.2 },
20 { offset: 1, opacity: 0.8 },
21 { offset: 1, opacity: 0.9 },
22 { offset: 1, opacity: 1 } ],
23 { duration: 1000,
24 easing: 'cubic-bezier(0.5, -0.5, 0.5, 1.5)' });
25 assert_equals(getComputedStyle(div).opacity, '0.2',
26 'When progress is zero the last keyframe with offset 0 should'
27 + ' be used');
28 // http://cubic-bezier.com/#.5,-0.5,.5,1.5
29 // At t=0.15, the progress should be negative
30 anim.currentTime = 150;
31 assert_equals(getComputedStyle(div).opacity, '0',
32 'When progress is negative, the first keyframe with a 0 offset'
33 + ' should be used');
34 // At t=0.71, the progress should be just less than 1
35 anim.currentTime = 710;
36 assert_approx_equals(parseFloat(getComputedStyle(div).opacity), 0.8, 0.01,
37 'When progress is just less than 1, the first keyframe with an'
38 + ' offset of 1 should be used as the interval endpoint');
39 // At t=0.85, the progress should be > 1
40 anim.currentTime = 850;
41 assert_equals(getComputedStyle(div).opacity, '1',
42 'When progress is greater than 1.0, the last keyframe with a 1'
43 + ' offset should be used');
44 anim.finish();
45 assert_equals(getComputedStyle(div).opacity, '1',
46 'When progress is equal to 1.0, the last keyframe with a 1'
47 + ' offset should be used');
48 }, 'Overlapping keyframes at 0 and 1 use the appropriate value when the'
49 + ' progress is outside the range [0, 1]');
50
51 test(function(t) {
52 var div = createDiv(t);
53 var anim = div.animate([ { offset: 0, opacity: 0 },
54 { offset: 0.5, opacity: 0.3 },
55 { offset: 0.5, opacity: 0.5 },
56 { offset: 0.5, opacity: 0.7 },
57 { offset: 1, opacity: 1 } ], 1000);
58 anim.currentTime = 250;
59 assert_equals(getComputedStyle(div).opacity, '0.15',
60 'Before the overlap point, the first keyframe from the'
61 + ' overlap point should be used as interval endpoint');
62 anim.currentTime = 500;
63 assert_equals(getComputedStyle(div).opacity, '0.7',
64 'At the overlap point, the last keyframe from the'
65 + ' overlap point should be used as interval startpoint');
66 anim.currentTime = 750;
67 assert_equals(getComputedStyle(div).opacity, '0.85',
68 'After the overlap point, the last keyframe from the'
69 + ' overlap point should be used as interval startpoint');
70 }, 'Overlapping keyframes between 0 and 1 use the appropriate value on each'
71 + ' side of the overlap point');
72
73 test(function(t) {
74 var div = createDiv(t);
75 var anim = div.animate({ visibility: ['hidden','visible'] },
76 { duration: 100 * MS_PER_SEC, fill: 'both' });
77
78 anim.currentTime = 0;
79 assert_equals(getComputedStyle(div).visibility, 'hidden',
80 'Visibility when progress = 0.');
81
82 anim.currentTime = 10 * MS_PER_SEC + 1;
83 assert_equals(getComputedStyle(div).visibility, 'visible',
84 'Visibility when progress > 0 due to linear easing.');
85
86 anim.finish();
87 assert_equals(getComputedStyle(div).visibility, 'visible',
88 'Visibility when progress = 1.');
89
90 }, "Test visibility clamping behavior.");
91
92 test(function(t) {
93 var div = createDiv(t);
94 var anim = div.animate({ visibility: ['hidden', 'visible'] },
95 { duration: 100 * MS_PER_SEC, fill: 'both',
96 easing: 'cubic-bezier(0.25, -0.6, 0, 0.5)' });
97
98 anim.currentTime = 0;
99 assert_equals(getComputedStyle(div).visibility, 'hidden',
100 'Visibility when progress = 0.');
101
102 // Timing function is below zero. So we expected visibility is hidden.
103 anim.currentTime = 10 * MS_PER_SEC + 1;
104 assert_equals(getComputedStyle(div).visibility, 'hidden',
105 'Visibility when progress < 0 due to cubic-bezier easing.');
106
107 anim.currentTime = 60 * MS_PER_SEC;
108 assert_equals(getComputedStyle(div).visibility, 'visible',
109 'Visibility when progress > 0 due to cubic-bezier easing.');
110
111 }, "Test visibility clamping behavior with an easing that has a negative compone nt");
112
113 done();
114 </script>
115 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698