OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <meta charset=utf-8> | |
3 <title>AnimationEffectTiming easing tests</title> | |
4 <link rel="help" href="https://w3c.github.io/web-animations/#the-animationeffect
timing-interface"> | |
5 <script src="../resources/testharness.js"></script> | |
6 <script src="../resources/testharnessreport.js"></script> | |
7 <script> | |
8 var animate_with_easing = function(inputEasing) { | |
9 return document.documentElement.animate([], { easing : inputEasing }); | |
10 }; | |
11 | |
12 var assert_animate_with_easing_succeeds = function(inputEasing, expectedEasing)
{ | |
13 var animation = animate_with_easing(inputEasing); | |
14 assert_equals(animation.effect.timing.easing, expectedEasing); | |
15 }; | |
16 | |
17 var assert_animate_with_easing_roundtrips = function(inputEasing) { | |
18 assert_animate_with_easing_succeeds(inputEasing, inputEasing); | |
19 }; | |
20 | |
21 var assert_animate_with_easing_throws = function(inputEasing) { | |
22 assert_throws( | |
23 {name: 'TypeError'}, | |
24 function() { animate_with_easing(inputEasing); }, | |
25 'with inputEasing=\'' + inputEasing + '\''); | |
26 }; | |
27 | |
28 test(function() { | |
29 assert_animate_with_easing_roundtrips('ease'); | |
30 assert_animate_with_easing_roundtrips('linear'); | |
31 assert_animate_with_easing_roundtrips('ease-in'); | |
32 assert_animate_with_easing_roundtrips('ease-out'); | |
33 assert_animate_with_easing_roundtrips('ease-in-out'); | |
34 assert_animate_with_easing_roundtrips('cubic-bezier(0.1, 5, 0.23, 0)'); | |
35 }, 'Valid linear and cubic-bezier easing functions should come out the same as t
hey went in'); | |
36 | |
37 test(function() { | |
38 assert_animate_with_easing_succeeds('step-start', 'steps(1, start)'); | |
39 assert_animate_with_easing_succeeds('step-middle', 'steps(1, middle)'); | |
40 assert_animate_with_easing_succeeds('step-end', 'steps(1)'); | |
41 assert_animate_with_easing_succeeds('steps(3, start)', 'steps(3, start)'); | |
42 assert_animate_with_easing_succeeds('steps(3, middle)', 'steps(3, middle)'); | |
43 assert_animate_with_easing_succeeds('steps(3, end)', 'steps(3)'); | |
44 assert_animate_with_easing_succeeds('steps(3)', 'steps(3)'); | |
45 }, 'Valid step-function easings serialize as steps(<int>) or steps(<int>, start)
'); | |
46 | |
47 test(function() { | |
48 assert_animate_with_easing_succeeds('eAse\\2d iN-ouT', 'ease-in-out'); | |
49 }, 'Should accept arbitrary casing and escape chararcters'); | |
50 | |
51 test(function() { | |
52 assert_animate_with_easing_throws(''); | |
53 assert_animate_with_easing_throws('initial'); | |
54 assert_animate_with_easing_throws('inherit'); | |
55 assert_animate_with_easing_throws('unset'); | |
56 assert_animate_with_easing_throws('steps(3, nowhere)'); | |
57 assert_animate_with_easing_throws('steps(-3, end)'); | |
58 assert_animate_with_easing_throws('cubic-bezier(0.1, 0, 4, 0.4)'); | |
59 assert_animate_with_easing_throws('function (a){return a}'); | |
60 assert_animate_with_easing_throws('function (x){return x}'); | |
61 assert_animate_with_easing_throws('function(x, y){return 0.3}'); | |
62 assert_animate_with_easing_throws('7'); | |
63 }, 'Invalid easing values should throw a TypeError'); | |
64 </script> | |
OLD | NEW |