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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/web-animations/timing-model/animations/set-the-animation-start-time.html

Issue 1999243002: Import wpt@5df9b57edb3307a87d5187804b29c8ddd2aa14e1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add expectations files (using run-webkit-tests --new-baseline) 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>Setting the start time tests</title>
4 <link rel="help" href="https://w3c.github.io/web-animations/#set-the-animation-s tart-time">
5 <script src="../../../../../resources/testharness.js"></script>
6 <script src="../../../../../resources/testharnessreport.js"></script>
7 <script src="../../testcommon.js"></script>
8 <body>
9 <div id="log"></div>
10 <script>
11 'use strict';
12
13 test(function(t)
14 {
15 // It should only be possible to set *either* the start time or the current
16 // time for an animation that does not have an active timeline.
17
18 var animation =
19 new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC));
20
21 assert_equals(animation.currentTime, null, 'Intial current time');
22 assert_equals(animation.startTuime, null, 'Intial start time');
23
24 animation.currentTime = 1000;
25 assert_equals(animation.currentTime, 1000,
26 'Setting the current time succeeds');
27 assert_equals(animation.startTime, null,
28 'Start time remains null after setting current time');
29
30 animation.startTime = 1000;
31 assert_equals(animation.startTime, 1000,
32 'Setting the start time succeeds');
33 assert_equals(animation.currentTime, null,
34 'Setting the start time clears the current time');
35
36 animation.startTime = null;
37 assert_equals(animation.startTime, null,
38 'Setting the start time to an unresolved time succeeds');
39 assert_equals(animation.currentTime, null, 'The current time is unaffected');
40
41 }, 'Setting the start time of an animation without an active timeline');
42
43 test(function(t)
44 {
45 // Setting an unresolved start time on an animation without an active
46 // timeline should not clear the current time.
47
48 var animation =
49 new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC));
50
51 assert_equals(animation.currentTime, null, 'Intial current time');
52 assert_equals(animation.startTuime, null, 'Intial start time');
53
54 animation.currentTime = 1000;
55 assert_equals(animation.currentTime, 1000,
56 'Setting the current time succeeds');
57 assert_equals(animation.startTime, null,
58 'Start time remains null after setting current time');
59
60 animation.startTime = null;
61 assert_equals(animation.startTime, null, 'Start time remains unresolved');
62 assert_equals(animation.currentTime, 1000, 'Current time is unaffected');
63
64 }, 'Setting an unresolved start time an animation without an active timeline'
65 + ' does not clear the current time');
66
67 test(function(t)
68 {
69 var animation =
70 new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
71 document.timeline);
72
73 // So long as a hold time is set, querying the current time will return
74 // the hold time.
75
76 // Since the start time is unresolved at this point, setting the current time
77 // will set the hold time
78 animation.currentTime = 1000;
79 assert_equals(animation.currentTime, 1000,
80 'The current time is calculated from the hold time');
81
82 // If we set the start time, however, we should clear the hold time.
83 animation.startTime = document.timeline.currentTime - 2000;
84 assert_times_equal(animation.currentTime, 2000,
85 'The current time is calculated from the start time,'
86 + ' not the hold time');
87
88 // Sanity check
89 assert_equals(animation.playState, 'running',
90 'Animation reports it is running after setting a resolved'
91 + ' start time');
92 }, 'Setting the start time clears the hold time');
93
94 test(function(t)
95 {
96 var animation =
97 new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
98 document.timeline);
99
100 // Set up a running animation (i.e. both start time and current time
101 // are resolved).
102 animation.startTime = document.timeline.currentTime - 1000;
103 assert_equals(animation.playState, 'running');
104 assert_times_equal(animation.currentTime, 1000,
105 'Current time is resolved for a running animation')
106
107 // Clear start time
108 animation.startTime = null;
109 assert_times_equal(animation.currentTime, 1000,
110 'Hold time is set after start time is made unresolved');
111 assert_equals(animation.playState, 'paused',
112 'Animation reports it is paused after setting an unresolved'
113 + ' start time');
114 }, 'Setting an unresolved start time sets the hold time');
115
116 promise_test(function(t)
117 {
118 var animation =
119 new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
120 document.timeline);
121
122 var readyPromiseCallbackCalled = false;
123 animation.ready.then(function() { readyPromiseCallbackCalled = true; } );
124
125 // Put the animation in the play-pending state
126 animation.play();
127
128 // Sanity check
129 assert_equals(animation.playState, 'pending',
130 'Animation is in play-pending state');
131
132 // Setting the start time should resolve the 'ready' promise, i.e.
133 // it should schedule a microtask to run the promise callbacks.
134 animation.startTime = document.timeline.currentTime;
135 assert_false(readyPromiseCallbackCalled,
136 'Ready promise callback is not called synchronously');
137
138 // If we schedule another microtask then it should run immediately after
139 // the ready promise resolution microtask.
140 return Promise.resolve().then(function() {
141 assert_true(readyPromiseCallbackCalled,
142 'Ready promise callback called after setting startTime');
143 });
144 }, 'Setting the start time resolves a pending ready promise');
145
146 promise_test(function(t)
147 {
148 var animation =
149 new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
150 document.timeline);
151
152 var readyPromiseCallbackCalled = false;
153 animation.ready.then(function() { readyPromiseCallbackCalled = true; } );
154
155 // Put the animation in the pause-pending state
156 animation.startTime = document.timeline.currentTime;
157 animation.pause();
158
159 // Sanity check
160 assert_equals(animation.playState, 'pending',
161 'Animation is in pause-pending state');
162
163 // Setting the start time should resolve the 'ready' promise although
164 // the resolution callbacks when be run in a separate microtask.
165 animation.startTime = null;
166 assert_false(readyPromiseCallbackCalled,
167 'Ready promise callback is not called synchronously');
168
169 return Promise.resolve().then(function() {
170 assert_true(readyPromiseCallbackCalled,
171 'Ready promise callback called after setting startTime');
172 });
173 }, 'Setting the start time resolves a pending pause task');
174
175 promise_test(function(t)
176 {
177 var animation =
178 new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
179 document.timeline);
180
181 // Set start time such that the current time is past the end time
182 animation.startTime = document.timeline.currentTime
183 - 110 * MS_PER_SEC;
184 assert_equals(animation.playState, 'finished',
185 'Seeked to finished state using the startTime');
186
187 // If the 'did seek' flag is true, the current time should be greater than
188 // the effect end.
189 assert_greater_than(animation.currentTime,
190 animation.effect.getComputedTiming().endTime,
191 'Setting the start time updated the finished state with'
192 + ' the \'did seek\' flag set to true');
193
194 // Furthermore, that time should persist if we have correctly updated
195 // the hold time
196 var finishedCurrentTime = animation.currentTime;
197 return waitForAnimationFrames(1).then(function() {
198 assert_equals(animation.currentTime, finishedCurrentTime,
199 'Current time does not change after seeking past the effect'
200 + ' end time by setting the current time');
201 });
202 }, 'Setting the start time updates the finished state');
203
204 </script>
205 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698