OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <meta charset=utf-8> | 2 <meta charset=utf-8> |
3 <title>Animatable.animate tests</title> | 3 <title>Animatable.animate tests</title> |
4 <link rel="help" href="https://w3c.github.io/web-animations/#dom-animatable-anim
ate"> | 4 <link rel="help" href="https://w3c.github.io/web-animations/#dom-animatable-anim
ate"> |
5 <script src="/resources/testharness.js"></script> | 5 <script src="/resources/testharness.js"></script> |
6 <script src="/resources/testharnessreport.js"></script> | 6 <script src="/resources/testharnessreport.js"></script> |
7 <script src="../../testcommon.js"></script> | 7 <script src="../../testcommon.js"></script> |
8 <script src="../../resources/keyframe-utils.js"></script> | 8 <script src="../../resources/keyframe-utils.js"></script> |
9 <body> | 9 <body> |
10 <div id="log"></div> | 10 <div id="log"></div> |
| 11 <iframe width="10" height="10" id="iframe"></iframe> |
11 <script> | 12 <script> |
12 'use strict'; | 13 'use strict'; |
13 | 14 |
14 // Tests on Element | 15 // Tests on Element |
15 | 16 |
16 test(function(t) { | 17 test(function(t) { |
17 var div = createDiv(t); | 18 var div = createDiv(t); |
18 var anim = div.animate(null); | 19 var anim = div.animate(null); |
19 assert_class_string(anim, 'Animation', 'Returned object is an Animation'); | 20 assert_class_string(anim, 'Animation', 'Returned object is an Animation'); |
20 }, 'Element.animate() creates an Animation object'); | 21 }, 'Element.animate() creates an Animation object'); |
21 | 22 |
22 test(function(t) { | 23 test(function(t) { |
| 24 var iframe = window.frames[0]; |
| 25 var div = createDiv(t, iframe.document); |
| 26 var anim = Element.prototype.animate.call(div, null); |
| 27 assert_equals(Object.getPrototypeOf(anim), iframe.Animation.prototype, |
| 28 'The prototype of the created Animation is that defined on' |
| 29 + ' the relevant global for the target element'); |
| 30 assert_not_equals(Object.getPrototypeOf(anim), Animation.prototype, |
| 31 'The prototype of the created Animation is NOT that of' |
| 32 + ' the current global'); |
| 33 }, 'Element.animate() creates an Animation object in the relevant realm of' |
| 34 + ' the target element'); |
| 35 |
| 36 test(function(t) { |
23 var div = createDiv(t); | 37 var div = createDiv(t); |
24 var anim = div.animate(null); | 38 var anim = Element.prototype.animate.call(div, null); |
25 assert_class_string(anim.effect, 'KeyframeEffect', | 39 assert_class_string(anim.effect, 'KeyframeEffect', |
26 'Returned Animation has a KeyframeEffect'); | 40 'Returned Animation has a KeyframeEffect'); |
27 }, 'Element.animate() creates an Animation object with a KeyframeEffect'); | 41 }, 'Element.animate() creates an Animation object with a KeyframeEffect'); |
28 | 42 |
| 43 test(function(t) { |
| 44 var iframe = window.frames[0]; |
| 45 var div = createDiv(t, iframe.document); |
| 46 var anim = Element.prototype.animate.call(div, null); |
| 47 assert_equals(Object.getPrototypeOf(anim.effect), |
| 48 iframe.KeyframeEffect.prototype, |
| 49 'The prototype of the created KeyframeEffect is that defined on' |
| 50 + ' the relevant global for the target element'); |
| 51 assert_not_equals(Object.getPrototypeOf(anim.effect), |
| 52 KeyframeEffect.prototype, |
| 53 'The prototype of the created KeyframeEffect is NOT that of' |
| 54 + ' the current global'); |
| 55 }, 'Element.animate() creates an Animation object with a KeyframeEffect' |
| 56 + ' that is created in the relevant realm of the target element'); |
| 57 |
| 58 test(function(t) { |
| 59 var iframe = window.frames[0]; |
| 60 var div = createDiv(t, iframe.document); |
| 61 var anim = div.animate(null); |
| 62 assert_equals(Object.getPrototypeOf(anim.effect.timing), |
| 63 iframe.AnimationEffectTiming.prototype, |
| 64 'The prototype of the created AnimationEffectTiming is that' |
| 65 + ' defined on the relevant global for the target element'); |
| 66 assert_not_equals(Object.getPrototypeOf(anim.effect.timing), |
| 67 AnimationEffectTiming.prototype, |
| 68 'The prototype of the created AnimationEffectTiming is NOT' |
| 69 + ' that of the current global'); |
| 70 }, 'Element.animate() creates an Animation object with a KeyframeEffect' |
| 71 + ' whose AnimationEffectTiming object is created in the relevant realm' |
| 72 + ' of the target element'); |
| 73 |
29 gPropertyIndexedKeyframesTests.forEach(function(subtest) { | 74 gPropertyIndexedKeyframesTests.forEach(function(subtest) { |
30 test(function(t) { | 75 test(function(t) { |
31 var div = createDiv(t); | 76 var div = createDiv(t); |
32 var anim = div.animate(subtest.input, 2000); | 77 var anim = div.animate(subtest.input, 2000); |
33 assert_frame_lists_equal(anim.effect.getKeyframes(), subtest.output); | 78 assert_frame_lists_equal(anim.effect.getKeyframes(), subtest.output); |
34 }, 'Element.animate() accepts ' + subtest.desc); | 79 }, 'Element.animate() accepts ' + subtest.desc); |
35 }); | 80 }); |
36 | 81 |
37 gKeyframeSequenceTests.forEach(function(subtest) { | 82 gKeyframeSequenceTests.forEach(function(subtest) { |
38 test(function(t) { | 83 test(function(t) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 171 |
127 test(function(t) { | 172 test(function(t) { |
128 var pseudoTarget = createPseudo(t, 'before'); | 173 var pseudoTarget = createPseudo(t, 'before'); |
129 var anim = pseudoTarget.animate(null); | 174 var anim = pseudoTarget.animate(null); |
130 assert_equals(anim.effect.target, pseudoTarget, | 175 assert_equals(anim.effect.target, pseudoTarget, |
131 'The returned Animation targets to the correct object'); | 176 'The returned Animation targets to the correct object'); |
132 }, 'CSSPseudoElement.animate() creates an Animation object targeting ' + | 177 }, 'CSSPseudoElement.animate() creates an Animation object targeting ' + |
133 'to the correct CSSPseudoElement object'); | 178 'to the correct CSSPseudoElement object'); |
134 </script> | 179 </script> |
135 </body> | 180 </body> |
OLD | NEW |