Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 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"> | |
| 2 <script src="../resources/testharness.js"></script> | 5 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharnessreport.js"></script> | 6 <script src="../resources/testharnessreport.js"></script> |
| 4 <script> | 7 <script> |
| 5 var animate_with_easing = function(inputEasing) { | 8 var animate_with_easing = function(inputEasing) { |
| 6 return document.documentElement.animate([], { easing : inputEasing }); | 9 return document.documentElement.animate([], { easing : inputEasing }); |
| 7 }; | 10 }; |
| 8 | 11 |
| 9 var assert_animate_with_easing_succeeds = function(inputEasing, expectedEasing) { | 12 var assert_animate_with_easing_succeeds = function(inputEasing, expectedEasing) { |
| 10 var animation = animate_with_easing(inputEasing); | 13 var animation = animate_with_easing(inputEasing); |
| 11 assert_equals(animation.effect.timing.easing, expectedEasing); | 14 assert_equals(animation.effect.timing.easing, expectedEasing); |
| 12 }; | 15 }; |
| 13 | 16 |
| 14 var assert_animate_with_easing_roundtrips = function(inputEasing) { | 17 var assert_animate_with_easing_roundtrips = function(inputEasing) { |
| 15 assert_animate_with_easing_succeeds(inputEasing, inputEasing); | 18 assert_animate_with_easing_succeeds(inputEasing, inputEasing); |
| 16 }; | 19 }; |
| 17 | 20 |
| 18 var assert_animate_with_easing_throws = function(inputEasing) { | 21 var assert_animate_with_easing_throws = function(inputEasing) { |
| 19 assert_throws( | 22 assert_throws( |
| 20 {name: 'TypeError'}, | 23 {name: 'TypeError'}, |
| 21 function() { animate_with_easing(inputEasing); }, | 24 function() { animate_with_easing(inputEasing); }, |
| 22 'with inputEasing=\'' + inputEasing + '\''); | 25 'with inputEasing=\'' + inputEasing + '\''); |
| 23 }; | 26 }; |
|
alancutter (OOO until 2018)
2016/07/12 01:59:34
We should make these regular functions rather than
| |
| 24 | 27 |
| 25 test(function() { | 28 test(function() { |
| 26 assert_animate_with_easing_roundtrips('ease'); | 29 assert_animate_with_easing_roundtrips('ease'); |
| 27 assert_animate_with_easing_roundtrips('linear'); | 30 assert_animate_with_easing_roundtrips('linear'); |
| 28 assert_animate_with_easing_roundtrips('ease-in'); | 31 assert_animate_with_easing_roundtrips('ease-in'); |
| 29 assert_animate_with_easing_roundtrips('ease-out'); | 32 assert_animate_with_easing_roundtrips('ease-out'); |
| 30 assert_animate_with_easing_roundtrips('ease-in-out'); | 33 assert_animate_with_easing_roundtrips('ease-in-out'); |
| 31 assert_animate_with_easing_roundtrips('step-start'); | 34 assert_animate_with_easing_roundtrips('step-start'); |
| 32 assert_animate_with_easing_roundtrips('step-middle'); | 35 assert_animate_with_easing_roundtrips('step-middle'); |
| 33 assert_animate_with_easing_roundtrips('step-end'); | 36 assert_animate_with_easing_roundtrips('step-end'); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 46 }, 'Should accept arbitrary casing and escape chararcters'); | 49 }, 'Should accept arbitrary casing and escape chararcters'); |
| 47 | 50 |
| 48 test(function() { | 51 test(function() { |
| 49 assert_animate_with_easing_throws(''); | 52 assert_animate_with_easing_throws(''); |
| 50 assert_animate_with_easing_throws('initial'); | 53 assert_animate_with_easing_throws('initial'); |
| 51 assert_animate_with_easing_throws('inherit'); | 54 assert_animate_with_easing_throws('inherit'); |
| 52 assert_animate_with_easing_throws('unset'); | 55 assert_animate_with_easing_throws('unset'); |
| 53 assert_animate_with_easing_throws('steps(3, nowhere)'); | 56 assert_animate_with_easing_throws('steps(3, nowhere)'); |
| 54 assert_animate_with_easing_throws('steps(-3, end)'); | 57 assert_animate_with_easing_throws('steps(-3, end)'); |
| 55 assert_animate_with_easing_throws('cubic-bezier(0.1, 0, 4, 0.4)'); | 58 assert_animate_with_easing_throws('cubic-bezier(0.1, 0, 4, 0.4)'); |
| 56 }, 'Invalid easing values should throw a TypeError'); | 59 assert_animate_with_easing_throws('function (a){return a}'); |
| 57 | |
| 58 test(function() { | |
| 59 assert_animate_with_easing_succeeds('function (a){return a}', 'linear'); | |
| 60 assert_animate_with_easing_throws('function (x){return x}'); | 60 assert_animate_with_easing_throws('function (x){return x}'); |
| 61 assert_animate_with_easing_throws('function(x, y){return 0.3}'); | 61 assert_animate_with_easing_throws('function(x, y){return 0.3}'); |
| 62 }, 'Function values for easing should throw a TypeError, except for one special linear case, which is deprecated for now and returns the default'); | 62 assert_animate_with_easing_throws('7'); |
| 63 }, 'Invalid easing values should throw a TypeError'); | |
| 63 </script> | 64 </script> |
| OLD | NEW |