[Web Animations] Update WPT tests and move them to imported/w3c/web-platform-tests
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / web-animations / interfaces / Animation / startTime.html
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>Animation.startTime</title>
4 <link rel="help"
5 href="https://drafts.csswg.org/web-animations/#dom-animation-starttime">
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(t => {
15   const animation = new Animation(new KeyframeEffect(createDiv(t), null),
16                                   document.timeline);
17   assert_equals(animation.startTime, null, 'startTime is unresolved');
18 }, 'startTime of a newly created (idle) animation is unresolved');
19
20 test(t => {
21   const animation = new Animation(new KeyframeEffect(createDiv(t), null),
22                                   document.timeline);
23   animation.play();
24   assert_equals(animation.startTime, null, 'startTime is unresolved');
25 }, 'startTime of a play-pending animation is unresolved');
26
27 test(t => {
28   const animation = new Animation(new KeyframeEffect(createDiv(t), null),
29                                   document.timeline);
30   animation.pause();
31   assert_equals(animation.startTime, null, 'startTime is unresolved');
32 }, 'startTime of a pause-pending animation is unresolved');
33
34 test(t => {
35   const animation = createDiv(t).animate(null);
36   assert_equals(animation.startTime, null, 'startTime is unresolved');
37 }, 'startTime of a play-pending animation created using Element.animate'
38    + ' shortcut is unresolved');
39
40 promise_test(t => {
41   const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
42   return animation.ready.then(() => {
43     assert_greater_than(animation.startTime, 0, 'startTime when running');
44   });
45 }, 'startTime is resolved when running');
46
47 test(t => {
48   const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
49   animation.cancel();
50   assert_equals(animation.startTime, null);
51   assert_equals(animation.currentTime, null);
52 }, 'startTime and currentTime are unresolved when animation is cancelled');
53
54 </script>
55 </body>