Bug 1244590 - Part 13: Test for different units. draft
authorBoris Chiou <boris.chiou@gmail.com>
Sat, 21 May 2016 19:24:54 +0800
changeset 369288 4a55d9b857efa3fbd8d2e423d8ef532de8cad463
parent 369287 da5e7ba24fce1c2c7c188db5dcf5c74451bc9876
child 521541 fd46bba5617f29290183603cfe1a43a0383c7587
push id18826
push userbmo:boris.chiou@gmail.com
push dateSat, 21 May 2016 11:25:24 +0000
bugs1244590
milestone49.0a1
Bug 1244590 - Part 13: Test for different units. MozReview-Commit-ID: Jcx4sQxSIdy
testing/web-platform/tests/web-animations/animation-model/keyframe-effects/spacing-keyframes.html
--- a/testing/web-platform/tests/web-animations/animation-model/keyframe-effects/spacing-keyframes.html
+++ b/testing/web-platform/tests/web-animations/animation-model/keyframe-effects/spacing-keyframes.html
@@ -166,17 +166,36 @@ test(function(t) {
 
   var frames = anim.effect.getKeyframes();
   var slots = frames.length - 1;
   assert_equals(frames[1].computedOffset, 1.0 / slots, '2nd frame offset');
   assert_equals(frames[2].computedOffset, 2.0 / slots, '3rd frame offset');
 }, 'Test falling back to distribute spacing if all paced property value ' +
    'are not changed');
 
-// TODO: Add test case for mixing % values and pixel values
+test(function(t) {
+  var parent = createDiv(t);
+  var div = document.createElement('div');
+  parent.appendChild(div);
+  parent.style.width = '100px';
+  div.style.fontSize = '16px';
+  var anim = div.animate([ { marginLeft: '0px' },
+                           { marginLeft: '-20%' },
+                           { marginLeft: '100px' },
+                           { marginLeft: '3em' } ],
+                         { duration: 100 * MS_PER_SEC,
+                           spacing: 'paced(margin-left)' });
+
+  var frames = anim.effect.getKeyframes();
+  var cumDist = [ 0, 20, 140, 140 + (100 - 16 * 3) ];
+  assert_approx_equals(frames[1].computedOffset, cumDist[1] / cumDist[3],
+                       0.0001, '2nd frame offset');
+  assert_approx_equals(frames[2].computedOffset, cumDist[2] / cumDist[3],
+                       0.0001, '3rd frame offset');
+}, 'Test paced spacing with different units');
 
 test(function(t) {
   var anim = createDiv(t).animate([ { margin: '0px' },
                                     { marginTop: '-20px' },
                                     { marginLeft: '100px' },
                                     { margin: '50px' } ],
                                   { duration: 100 * MS_PER_SEC,
                                     spacing: 'paced(margin-left)' });