Bug 1278485 - Part 3: Add test cases to check x value of cubic-bezier is in [0, 1] and step numbers of steps function. r?birtles draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Tue, 12 Jul 2016 16:37:28 +0900
changeset 386578 d06cf2309cc55b9085ae22741b6213490d3d4b42
parent 386577 b6d0803523c3768a627ea79da135f5686e347f36
child 525151 1a44eda2031583a816454ea7d22151b2ee04cae9
push id22748
push userhiikezoe@mozilla-japan.org
push dateTue, 12 Jul 2016 10:30:30 +0000
reviewersbirtles
bugs1278485
milestone50.0a1
Bug 1278485 - Part 3: Add test cases to check x value of cubic-bezier is in [0, 1] and step numbers of steps function. r?birtles MozReview-Commit-ID: DVQF44NMMfp
testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/easing.html
testing/web-platform/tests/web-animations/interfaces/KeyframeEffect/effect-easing.html
testing/web-platform/tests/web-animations/resources/effect-easing-tests.js
--- a/testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/easing.html
+++ b/testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/easing.html
@@ -34,28 +34,26 @@ gEffectEasingTests.forEach(function(opti
     assert_progress(anim, 0, easing);
     assert_progress(anim, 250 * MS_PER_SEC, easing);
     assert_progress(anim, 500 * MS_PER_SEC, easing);
     assert_progress(anim, 750 * MS_PER_SEC, easing);
     assert_progress(anim, 1000 * MS_PER_SEC, easing);
   }, options.desc);
 });
 
-test(function(t) {
-  var div = createDiv(t);
-  var anim = div.animate({ opacity: [ 0, 1 ] }, 100 * MS_PER_SEC);
-  assert_throws({ name: 'TypeError' },
-                function() {
-                  anim.effect.timing.easing = '';
-                });
-  assert_throws({ name: 'TypeError' },
-                function() {
-                  anim.effect.timing.easing = 'test';
-                });
-}, 'Test invalid easing value');
+gInvalidEasingTests.forEach(function(options) {
+  test(function(t) {
+    var div = createDiv(t);
+    var anim = div.animate({ opacity: [ 0, 1 ] }, 100 * MS_PER_SEC);
+    assert_throws({ name: 'TypeError' },
+                  function() {
+                    anim.effect.timing.easing = options.easing;
+                  });
+  }, 'Invalid effect easing value test: \'' + options.easing + '\'');
+});
 
 test(function(t) {
   var delay = 1000 * MS_PER_SEC;
 
   var target = createDiv(t);
   var anim = target.animate([ { opacity: 0 }, { opacity: 1 } ],
                             { duration: 1000 * MS_PER_SEC,
                               fill: 'both',
--- a/testing/web-platform/tests/web-animations/interfaces/KeyframeEffect/effect-easing.html
+++ b/testing/web-platform/tests/web-animations/interfaces/KeyframeEffect/effect-easing.html
@@ -664,10 +664,20 @@ gStepTimingFunctionTests.forEach(functio
         assert_equals(getComputedStyle(target).width,
                       condition.width,
                       'Progress at ' + animation.currentTime + 'ms');
       }
     });
   }, options.description);
 });
 
+gInvalidEasingTests.forEach(function(options) {
+  test(function(t) {
+    var div = createDiv(t);
+    assert_throws({ name: 'TypeError' },
+                  function() {
+                    div.animate({ easing: options.easing }, 100 * MS_PER_SEC);
+                  });
+  }, 'Invalid keyframe easing value: \'' + options.easing + '\'');
+});
+
 </script>
 </body>
--- a/testing/web-platform/tests/web-animations/resources/effect-easing-tests.js
+++ b/testing/web-platform/tests/web-animations/resources/effect-easing-tests.js
@@ -35,8 +35,35 @@ var gEffectEasingTests = [
     easingFunction: cubicBezier(0, 0, 0.58, 1.0)
   },
   {
     desc: 'easing function which produces values greater than 1',
     easing: 'cubic-bezier(0, 1.5, 1, 1.5)',
     easingFunction: cubicBezier(0, 1.5, 1, 1.5)
   }
 ];
+
+var gInvalidEasingTests = [
+  {
+    easing: ''
+  },
+  {
+    easing: 'test'
+  },
+  {
+    easing: 'cubic-bezier(1.1, 0, 1, 1)'
+  },
+  {
+    easing: 'cubic-bezier(0, 0, 1.1, 1)'
+  },
+  {
+    easing: 'cubic-bezier(-0.1, 0, 1, 1)'
+  },
+  {
+    easing: 'cubic-bezier(0, 0, -0.1, 1)'
+  },
+  {
+    easing: 'steps(-1, start)'
+  },
+  {
+    easing: 'steps(0.1, start)'
+  },
+];