Bug 1141710, part 8 - Create helpers to get the startTime corresponding to various points through the active duration. r=dholbert
☠☠ backed out by 24872a839d9d ☠ ☠
authorJonathan Watt <jwatt@jwatt.org>
Tue, 03 Mar 2015 17:40:28 +0000
changeset 232913 c67f9c7dfd4ec05f4d9b49f0e822f0187df6aeb5
parent 232912 9496b1468d9cefa27eb5db157a935f5d32d39988
child 232914 0e360d3f690bc3e62e406e9af641525494f46669
push id56680
push userjwatt@jwatt.org
push dateWed, 11 Mar 2015 00:34:08 +0000
treeherdermozilla-inbound@0e360d3f690b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1141710
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1141710, part 8 - Create helpers to get the startTime corresponding to various points through the active duration. r=dholbert
dom/animation/test/css-animations/test_animation-player-starttime.html
--- a/dom/animation/test/css-animations/test_animation-player-starttime.html
+++ b/dom/animation/test/css-animations/test_animation-player-starttime.html
@@ -42,27 +42,39 @@
 const CSS_ANIM_EVENTS = ['animationstart', 'animationiteration', 'animationend'];
 const ANIM_DELAY_MS = 1000000; // 1000s
 const ANIM_DUR_MS = 1000000; // 1000s
 const ANIM_PROPERTY_VAL = 'anim ' + ANIM_DUR_MS + 'ms ' + ANIM_DELAY_MS + 'ms';
 
 /**
  * These helpers get the value that the startTime needs to be set to, to put an
  * animation that uses the above ANIM_DELAY_MS and ANIM_DUR_MS values into the
- * before, active and after phases, respectively.
+ * middle of various phases or points through the active duration.
  */
 function startTimeForBeforePhase(timeline) {
   return timeline.currentTime - ANIM_DELAY_MS / 2;
 }
 function startTimeForActivePhase(timeline) {
   return timeline.currentTime - ANIM_DELAY_MS - ANIM_DUR_MS / 2;
 }
 function startTimeForAfterPhase(timeline) {
   return timeline.currentTime - ANIM_DELAY_MS - ANIM_DUR_MS - ANIM_DELAY_MS / 2;
 }
+function startTimeForStartOfActiveInterval(timeline) {
+  return timeline.currentTime - ANIM_DELAY_MS;
+}
+function startTimeForFiftyPercentThroughActiveInterval(timeline) {
+  return timeline.currentTime - ANIM_DELAY_MS - ANIM_DUR_MS * 0.5;
+}
+function startTimeForNinetyPercentThroughActiveInterval(timeline) {
+  return timeline.currentTime - ANIM_DELAY_MS - ANIM_DUR_MS * 0.9;
+}
+function startTimeForEndOfActiveInterval(timeline) {
+  return timeline.currentTime - ANIM_DELAY_MS - ANIM_DUR_MS;
+}
 
 
 // Expected computed 'margin-left' values at points during the active interval:
 // When we assert_between_inclusive using these values we could in theory cause
 // intermittent failure due to very long delays between paints, but since the
 // active duration is 1000s long, a delay would need to be around 100s to cause
 // that. If that's happening then there are likely other issues that should be
 // fixed, so a failure to make us look into that seems like a good thing.
@@ -337,28 +349,28 @@ async_test(function(t) {
 
   div.style.animation = ANIM_PROPERTY_VAL;
 
   var player = div.getAnimationPlayers()[0];
 
   player.ready.then(t.step_func(function() {
     checkStateOnReadyPromiseResolved(player);
 
-    player.startTime = document.timeline.currentTime - ANIM_DELAY_MS; // jump to start of active interval
+    player.startTime = startTimeForStartOfActiveInterval(player.timeline);
     return eventWatcher.waitForEvent('animationstart');
   })).then(t.step_func(function() {
     checkStateAtActiveIntervalStartTime(player);
 
-    player.startTime = document.timeline.currentTime - ANIM_DELAY_MS - ANIM_DUR_MS * 0.5; // 50% through active interval
+    player.startTime = startTimeForFiftyPercentThroughActiveInterval(player.timeline);
     checkStateAtFiftyPctOfActiveInterval(player);
 
-    player.startTime = document.timeline.currentTime - ANIM_DELAY_MS - ANIM_DUR_MS * 0.9; // 90% through active interval
+    player.startTime = startTimeForNinetyPercentThroughActiveInterval(player.timeline);
     checkStateAtNinetyPctOfActiveInterval(player);
 
-    player.startTime = document.timeline.currentTime - ANIM_DELAY_MS - ANIM_DUR_MS; // end of active interval
+    player.startTime = startTimeForEndOfActiveInterval(player.timeline);
     return eventWatcher.waitForEvent('animationend');
   })).then(t.step_func(function() {
     checkStateAtActiveIntervalEndTime(player);
 
     eventWatcher.stopWatching();
   })).catch(t.step_func(function(reason) {
     assert_unreached(reason);
   })).then(function() {
@@ -370,40 +382,40 @@ async_test(function(t) {
 async_test(function(t) {
   var div = addDiv(t, {'class': 'animated-div'});
   var eventWatcher = new EventWatcher(div, CSS_ANIM_EVENTS);
 
   div.style.animation = ANIM_PROPERTY_VAL;
 
   var player = div.getAnimationPlayers()[0];
 
-  player.startTime = document.timeline.currentTime - ANIM_DELAY_MS - ANIM_DUR_MS; // end of active interval
+  player.startTime = startTimeForEndOfActiveInterval(player.timeline);
 
   // Skipping over the active interval will dispatch an 'animationstart' then
   // an 'animationend' event. We need to wait for these events before we start
   // testing going backwards since EventWatcher will fail the test if it gets
   // an event that we haven't told it about.
   eventWatcher.waitForEvents(['animationstart', 'animationend']).then(t.step_func(function() {
     // Now we can start the tests for skipping backwards, but first we check
     // that after the events we're still in the same end time state:
     checkStateAtActiveIntervalEndTime(player);
 
-    player.startTime = document.timeline.currentTime - ANIM_DELAY_MS - ANIM_DUR_MS * 0.9; // 90% through active interval
+    player.startTime = startTimeForNinetyPercentThroughActiveInterval(player.timeline);
 
     // Despite going backwards from after the end of the animation to just
     // before the end of the animation, we now expect an animationstart event
     // because we went from outside to inside the active interval.
     return eventWatcher.waitForEvent('animationstart');
   })).then(t.step_func(function() {
     checkStateAtNinetyPctOfActiveInterval(player);
 
-    player.startTime = document.timeline.currentTime - ANIM_DELAY_MS - ANIM_DUR_MS * 0.5; // 50% through active interval
+    player.startTime = startTimeForFiftyPercentThroughActiveInterval(player.timeline);
     checkStateAtFiftyPctOfActiveInterval(player);
 
-    player.startTime = document.timeline.currentTime - ANIM_DELAY_MS; // jump to start of active interval
+    player.startTime = startTimeForStartOfActiveInterval(player.timeline);
     checkStateAtActiveIntervalStartTime(player);
 
     player.startTime = document.timeline.currentTime;
     // Despite going backwards from just after the active interval starts to
     // the animation start time, we now expect an animationend event
     // because we went from inside to outside the active interval.
     return eventWatcher.waitForEvent('animationend');
   })).then(t.step_func(function() {