undefined reference to 'JSC::B3::BasicBlock::fallThrough() const
[WebKit-https.git] / LayoutTests / http / wpt / web-animations / interfaces / KeyframeEffect / constructor.html
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>KeyframeEffectReadOnly constructor tests</title>
4 <link rel="help" href="https://w3c.github.io/web-animations/#the-keyframeeffect-interfaces">
5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 <script src="../../testcommon.js"></script>
8 <script src="../../resources/easing-tests.js"></script>
9 <script src="../../resources/keyframe-utils.js"></script>
10 <body>
11 <div id="log"></div>
12 <div id="target"></div>
13 <style>
14 #target {
15   border-style: solid;  /* so border-*-width values don't compute to 0 */
16 }
17 </style>
18 <script>
19 "use strict";
20
21 var target = document.getElementById("target");
22
23 test(function(t) {
24   gEmptyKeyframeListTests.forEach(function(frames) {
25     assert_equals(new KeyframeEffectReadOnly(target, frames)
26                         .getKeyframes().length,
27                   0, "number of frames for " + JSON.stringify(frames));
28   });
29 }, "a KeyframeEffectReadOnly can be constructed with no frames");
30
31 test(function(t) {
32   gEasingParsingTests.forEach(function(subtest) {
33     var easing = subtest[0];
34     var expected = subtest[1];
35     var effect = new KeyframeEffectReadOnly(target, {
36       left: ["10px", "20px"]
37     }, { easing: easing });
38     assert_equals(effect.timing.easing, expected,
39                   "resulting easing for '" + easing + "'");
40   });
41 }, "easing values are parsed correctly when passed to the " +
42    "KeyframeEffectReadOnly constructor in KeyframeEffectOptions");
43
44 test(function(t) {
45   gInvalidEasings.forEach(invalidEasing => {
46     assert_throws(new TypeError, () => {
47       new KeyframeEffectReadOnly(target, null, { easing: invalidEasing });
48     }, `TypeError is thrown for easing '${invalidEasing}'`);
49   });
50 }, 'invalid easing values are correctly rejected when passed to the ' +
51    'KeyframeEffectReadOnly constructor in KeyframeEffectOptions');
52
53 test(function(t) {
54   var getKeyframe = function(composite) {
55     return { left: [ "10px", "20px" ], composite: composite };
56   };
57   gGoodKeyframeCompositeValueTests.forEach(function(composite) {
58     var effect = new KeyframeEffectReadOnly(target, getKeyframe(composite));
59     assert_equals(effect.getKeyframes()[0].composite, composite,
60                   "resulting composite for '" + composite + "'");
61   });
62   gBadCompositeValueTests.forEach(function(composite) {
63     assert_throws(new TypeError, function() {
64       new KeyframeEffectReadOnly(target, getKeyframe(composite));
65     });
66   });
67 }, "composite values are parsed correctly when passed to the " +
68    "KeyframeEffectReadOnly constructor in property-indexed keyframes");
69
70 test(function(t) {
71   var getKeyframes = function(composite) {
72     return [
73       { offset: 0, left: "10px", composite: composite },
74       { offset: 1, left: "20px" }
75     ];
76   };
77   gGoodKeyframeCompositeValueTests.forEach(function(composite) {
78     var effect = new KeyframeEffectReadOnly(target, getKeyframes(composite));
79     assert_equals(effect.getKeyframes()[0].composite, composite,
80                   "resulting composite for '" + composite + "'");
81   });
82   gBadCompositeValueTests.forEach(function(composite) {
83     assert_throws(new TypeError, function() {
84       new KeyframeEffectReadOnly(target, getKeyframes(composite));
85     });
86   });
87 }, "composite values are parsed correctly when passed to the " +
88    "KeyframeEffectReadOnly constructor in regular keyframes");
89
90 test(function(t) {
91   gGoodOptionsCompositeValueTests.forEach(function(composite) {
92     var effect = new KeyframeEffectReadOnly(target, {
93       left: ["10px", "20px"]
94     }, { composite: composite });
95     assert_equals(effect.getKeyframes()[0].composite, undefined,
96                   "resulting composite for '" + composite + "'");
97   });
98   gBadCompositeValueTests.forEach(function(composite) {
99     assert_throws(new TypeError, function() {
100       new KeyframeEffectReadOnly(target, {
101         left: ["10px", "20px"]
102       }, { composite: composite });
103     });
104   });
105 }, "composite value is absent if the composite operation specified on the " +
106    "keyframe effect is being used");
107
108 gPropertyIndexedKeyframesTests.forEach(function(subtest) {
109   test(function(t) {
110     var effect = new KeyframeEffectReadOnly(target, subtest.input);
111     assert_frame_lists_equal(effect.getKeyframes(), subtest.output);
112   }, "a KeyframeEffectReadOnly can be constructed with " + subtest.desc);
113
114   test(function(t) {
115     var effect = new KeyframeEffectReadOnly(target, subtest.input);
116     var secondEffect =
117       new KeyframeEffectReadOnly(target, effect.getKeyframes());
118     assert_frame_lists_equal(secondEffect.getKeyframes(),
119                              effect.getKeyframes());
120   }, "a KeyframeEffectReadOnly constructed with " + subtest.desc +
121      " roundtrips");
122 });
123
124 gKeyframeSequenceTests.forEach(function(subtest) {
125   test(function(t) {
126     var effect = new KeyframeEffectReadOnly(target, subtest.input);
127     assert_frame_lists_equal(effect.getKeyframes(), subtest.output);
128   }, "a KeyframeEffectReadOnly can be constructed with " + subtest.desc);
129
130   test(function(t) {
131     var effect = new KeyframeEffectReadOnly(target, subtest.input);
132     var secondEffect =
133       new KeyframeEffectReadOnly(target, effect.getKeyframes());
134     assert_frame_lists_equal(secondEffect.getKeyframes(),
135                              effect.getKeyframes());
136   }, "a KeyframeEffectReadOnly constructed with " + subtest.desc +
137      " roundtrips");
138 });
139
140 gInvalidKeyframesTests.forEach(function(subtest) {
141   test(function(t) {
142     assert_throws(subtest.expected, function() {
143       new KeyframeEffectReadOnly(target, subtest.input);
144     });
145   }, "KeyframeEffectReadOnly constructor throws with " + subtest.desc);
146 });
147
148 test(function(t) {
149   var effect = new KeyframeEffectReadOnly(target,
150                                           { left: ["10px", "20px"] });
151
152   var timing = effect.timing;
153   assert_equals(timing.delay, 0, "default delay");
154   assert_equals(timing.endDelay, 0, "default endDelay");
155   assert_equals(timing.fill, "auto", "default fill");
156   assert_equals(timing.iterations, 1.0, "default iterations");
157   assert_equals(timing.iterationStart, 0.0, "default iterationStart");
158   assert_equals(timing.duration, "auto", "default duration");
159   assert_equals(timing.direction, "normal", "default direction");
160   assert_equals(timing.easing, "linear", "default easing");
161
162   assert_equals(effect.composite, "replace", "default composite");
163   assert_equals(effect.iterationComposite, "replace",
164                 "default iterationComposite");
165 }, "a KeyframeEffectReadOnly constructed without any " +
166    "KeyframeEffectOptions object");
167
168 gKeyframeEffectOptionTests.forEach(function(stest) {
169   test(function(t) {
170     var effect = new KeyframeEffectReadOnly(target,
171                                             { left: ["10px", "20px"] },
172                                             stest.input);
173
174     // Helper function to provide default expected values when the test does
175     // not supply them.
176     var expected = function(field, defaultValue) {
177       return field in stest.expected ? stest.expected[field] : defaultValue;
178     };
179
180     var timing = effect.timing;
181     assert_equals(timing.delay, expected("delay", 0),
182                   "timing delay");
183     assert_equals(timing.fill, expected("fill", "auto"),
184                   "timing fill");
185     assert_equals(timing.iterations, expected("iterations", 1),
186                   "timing iterations");
187     assert_equals(timing.duration, expected("duration", "auto"),
188                   "timing duration");
189     assert_equals(timing.direction, expected("direction", "normal"),
190                   "timing direction");
191
192   }, "a KeyframeEffectReadOnly constructed by " + stest.desc);
193 });
194
195 gInvalidKeyframeEffectOptionTests.forEach(function(stest) {
196   test(function(t) {
197     assert_throws(stest.expected, function() {
198       new KeyframeEffectReadOnly(target,
199                                  { left: ["10px", "20px"] },
200                                  stest.input);
201     });
202   }, "Invalid KeyframeEffectReadOnly option by " + stest.desc);
203 });
204
205 test(function(t) {
206   var effect = new KeyframeEffectReadOnly(null,
207                                           { left: ["10px", "20px"] },
208                                           { duration: 100 * MS_PER_SEC,
209                                             fill: "forwards" });
210   assert_equals(effect.target, null,
211                 "Effect created with null target has correct target");
212 }, "a KeyframeEffectReadOnly constructed with null target");
213
214 test(function(t) {
215   var effect = new KeyframeEffect(target, null);
216   assert_class_string(effect, "KeyframeEffect");
217   assert_class_string(effect.timing, "AnimationEffectTiming");
218 }, "KeyframeEffect constructor creates an AnimationEffectTiming timing object");
219
220 test(function(t) {
221   var test_error = { name: "test" };
222
223   assert_throws(test_error, function() {
224     new KeyframeEffect(target, { get left() { throw test_error }})
225   });
226 }, "KeyframeEffect constructor propagates exceptions generated by accessing"
227    + " the options object");
228 </script>
229 </body>