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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animatable/animate.html

Issue 1866333004: Import web-platform-tests@5a8700479d98852455bee6117558897867eb278a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wpt-sync
Patch Set: Add Failure option for two TestExpectations entries Created 4 years, 8 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>Animatable.animate tests</title>
4 <link rel="help" href="http://w3c.github.io/web-animations/#dom-animatable-anima te">
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 <script>
12 'use strict';
13
14 test(function(t) {
15 var div = createDiv(t);
16 var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
17 assert_class_string(anim, 'Animation', 'Returned object is an Animation');
18 }, 'Element.animate() creates an Animation object');
19
20 test(function(t) {
21 var div = createDiv(t);
22 var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
23 assert_class_string(anim.effect, 'KeyframeEffect',
24 'Returned Animation has a KeyframeEffect');
25 }, 'Element.animate() creates an Animation object with a KeyframeEffect');
26
27 // Animatable.animate() passes its |frames| argument to the KeyframeEffect
28 // constructor. As a result, detailed tests of the handling of that argument
29 // are found in the tests for that constructor. Here we just check that the
30 // different types of arguments are correctly passed along.
31
32 test(function(t) {
33 var div = createDiv(t);
34 var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
35 assert_equals(anim.effect.getFrames().length, 2);
36 assert_equals(anim.effect.getFrames()[0].opacity, '0');
37 assert_equals(anim.effect.getFrames()[1].opacity, '1');
38 }, 'Element.animate() accepts a property-indexed keyframe specification');
39
40 test(function(t) {
41 var div = createDiv(t);
42 var anim = div.animate([ { opacity: 0 }, { opacity: 1 } ], 2000);
43 assert_equals(anim.effect.getFrames().length, 2);
44 assert_equals(anim.effect.getFrames()[0].opacity, '0');
45 assert_equals(anim.effect.getFrames()[1].opacity, '1');
46 }, 'Element.animate() accepts a frame-indexed keyframe specification');
47
48 test(function(t) {
49 var div = createDiv(t);
50 var anim = div.animate({ opacity: 0 }, 2000);
51 assert_equals(anim.effect.getFrames().length, 1);
52 assert_equals(anim.effect.getFrames()[0].opacity, '0');
53 }, 'Element.animate() accepts a single-valued keyframe specification');
54
55 // As with the |frames| argument, Animatable.animate() passes its |options|
56 // argument to the KeyframeEffect constructor as well. As a result, detailed
57 // tests of the handling of that argument are found in the tests for that
58 // constructor. Here we just check that the different types of arguments are
59 // correctly passed along.
60
61 test(function(t) {
62 var div = createDiv(t);
63 var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
64 assert_equals(anim.effect.timing.duration, 2000);
65 // Also check that unspecified parameters receive their default values
66 assert_equals(anim.effect.timing.fill, 'auto');
67 }, 'Element.animate() accepts a double as an options argument');
68
69 test(function(t) {
70 var div = createDiv(t);
71 var anim = div.animate({ opacity: [ 0, 1 ] },
72 { duration: Infinity, fill: 'forwards' });
73 assert_equals(anim.effect.timing.duration, Infinity);
74 assert_equals(anim.effect.timing.fill, 'forwards');
75 // Also check that unspecified parameters receive their default values
76 assert_equals(anim.effect.timing.direction, 'normal');
77 }, 'Element.animate() accepts a KeyframeAnimationOptions argument');
78
79 test(function(t) {
80 var div = createDiv(t);
81 var anim = div.animate({ opacity: [ 0, 1 ] });
82 assert_equals(anim.effect.timing.duration, 'auto');
83 }, 'Element.animate() accepts an absent options argument');
84
85 test(function(t) {
86 var div = createDiv(t);
87 var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
88 assert_equals(anim.id, '');
89 }, 'Element.animate() correctly sets the id attribute when no id is specified');
90
91 test(function(t) {
92 var div = createDiv(t);
93 var anim = div.animate({ opacity: [ 0, 1 ] }, { id: 'test' });
94 assert_equals(anim.id, 'test');
95 }, 'Element.animate() correctly sets the id attribute');
96
97 test(function(t) {
98 var div = createDiv(t);
99 var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
100 assert_equals(anim.timeline, document.timeline);
101 }, 'Element.animate() correctly sets the Animation\'s timeline');
102
103 async_test(function(t) {
104 var iframe = document.createElement('iframe');
105 iframe.src = 'data:text/html;charset=utf-8,';
106 iframe.width = 10;
107 iframe.height = 10;
108
109 iframe.addEventListener('load', t.step_func(function() {
110 var div = createDiv(t, iframe.contentDocument);
111 var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
112 assert_equals(anim.timeline, iframe.contentDocument.timeline);
113 iframe.remove();
114 t.done();
115 }));
116
117 document.body.appendChild(iframe);
118 }, 'Element.animate() correctly sets the Animation\'s timeline when ' +
119 'triggered on an element in a different document');
120
121 test(function(t) {
122 var div = createDiv(t);
123 var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
124 assert_equals(anim.playState, 'pending');
125 }, 'Element.animate() calls play on the Animation');
126
127 // Tests on CSSPseudoElement
128
129 test(function(t) {
130 var pseudoTarget = createPseudo(t, 'before');
131 var anim = pseudoTarget.animate({ opacity: [ 0, 1 ] }, 2000);
132 assert_class_string(anim, 'Animation', 'The returned object is an Animation');
133 }, 'CSSPseudoElement.animate() creates an Animation object');
134
135 test(function(t) {
136 var pseudoTarget = createPseudo(t, 'before');
137 var anim = pseudoTarget.animate({ opacity: [ 0, 1 ] }, 2000);
138 assert_equals(anim.effect.target, pseudoTarget,
139 'The returned Animation targets to the correct object');
140 }, 'CSSPseudoElement.animate() creates an Animation object targeting ' +
141 'to the correct CSSPseudoElement object');
142 </script>
143 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698