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

Side by Side Diff: third_party/WebKit/LayoutTests/web-animations-api/animation-effect-timing-easing.html

Issue 1851003002: Throw TypeError if easing string is invalid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix "liner"->"linear" typo in ui/file_manager js file 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 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script>
5 var animate_with_easing = function(inputEasing) {
6 return document.documentElement.animate([], { easing : inputEasing });
7 };
8
9 var assert_animate_with_easing_succeeds = function(inputEasing, expectedEasing) {
10 var animation = animate_with_easing(inputEasing);
11 assert_equals(animation.effect.timing.easing, expectedEasing);
12 };
13
14 var assert_animate_with_easing_roundtrips = function(inputEasing) {
15 assert_animate_with_easing_succeeds(inputEasing, inputEasing);
16 };
17
18 var assert_animate_with_easing_throws = function(inputEasing) {
19 assert_throws(
20 {name: 'TypeError'},
21 function() { animate_with_easing(inputEasing); },
22 'with inputEasing=\'' + inputEasing + '\'');
23 };
24
25 test(function() {
26 assert_animate_with_easing_roundtrips('ease');
27 assert_animate_with_easing_roundtrips('linear');
28 assert_animate_with_easing_roundtrips('ease-in');
29 assert_animate_with_easing_roundtrips('ease-out');
30 assert_animate_with_easing_roundtrips('ease-in-out');
31 assert_animate_with_easing_roundtrips('step-start');
32 assert_animate_with_easing_roundtrips('step-middle');
33 assert_animate_with_easing_roundtrips('step-end');
34 assert_animate_with_easing_roundtrips('steps(3, start)');
35 assert_animate_with_easing_roundtrips('steps(3, middle)');
36 assert_animate_with_easing_roundtrips('steps(3, end)');
37 assert_animate_with_easing_roundtrips('cubic-bezier(0.1, 5, 0.23, 0)');
38 }, 'Valid easing functions should come out the same as they went in');
39
40 test(function() {
41 assert_animate_with_easing_succeeds('steps(3)', 'steps(3, end)');
42 }, 'steps easing second parameter defaults to end');
43
44 test(function() {
45 assert_animate_with_easing_succeeds('eAse\\2d iN-ouT', 'ease-in-out');
46 }, 'Should accept arbitrary casing and escape chararcters');
47
48 test(function() {
49 assert_animate_with_easing_throws('');
50 assert_animate_with_easing_throws('initial');
51 assert_animate_with_easing_throws('inherit');
52 assert_animate_with_easing_throws('unset');
53 assert_animate_with_easing_throws('steps(3, nowhere)');
54 assert_animate_with_easing_throws('steps(-3, end)');
55 assert_animate_with_easing_throws('cubic-bezier(0.1, 0, 4, 0.4)');
56 }, 'Invalid easing values should throw a TypeError');
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}');
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');
63 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698