Bug 1141710, part 1 - Update to the new version of addDiv() in testcommon.js. r=dholbert
☠☠ backed out by 24872a839d9d ☠ ☠
authorJonathan Watt <jwatt@jwatt.org>
Mon, 02 Mar 2015 20:04:57 +0000
changeset 232906 fcd5ac448c46bd0b99671c3cf98ceb4a25f31eef
parent 232905 aab01fe57d4880d907335887a7ad90fd5f31602d
child 232907 255c9236bb3771a7565652767465001bc9cb8180
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 1 - Update to the new version of addDiv() in testcommon.js. 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
@@ -14,16 +14,17 @@
 @keyframes anim {
   from { margin-left: 100px; }
   to { margin-left: 200px; }
 }
 
     </style>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
+    <script src="../testcommon.js"></script>
   </head>
   <body>
     <div id="log"></div>
     <script type="text/javascript;version=1.8">
 
 'use strict';
 
 // TODO: add equivalent tests without an animation-delay, but first we need to
@@ -50,27 +51,16 @@ const ANIM_DUR_MS = 1000000; // 1000s
 // failure to make us look into that seems like a good thing.
 const UNANIMATED_POSITION = 10;
 const INITIAL_POSITION = 100;
 const TEN_PCT_POSITION = 110;
 const FIFTY_PCT_POSITION = 150;
 const NINETY_PCT_POSITION = 190;
 const END_POSITION = 200;
 
-function addDiv(id)
-{
-  var div = document.createElement('div');
-  div.setAttribute('class', 'animated-div');
-  if (id) {
-    div.setAttribute('id', id);
-  }
-  document.body.appendChild(div);
-  return div;
-}
-
 /**
  * CSS animation events fire asynchronously after we set 'startTime'. This
  * helper class allows us to handle such events using Promises.
  *
  * To use this class:
  *
  *   var eventWatcher = new EventWatcher(watchedNode, eventTypes);
  *   eventWatcher.waitForEvent(eventType).then(function() {
@@ -283,19 +273,19 @@ function checkStateAtActiveIntervalEndTi
   var div = player.source.target;
   var marginLeft = parseFloat(getComputedStyle(div).marginLeft);
   assert_equals(marginLeft, UNANIMATED_POSITION,
     'the computed value of margin-left should be unaffected ' +
     'by the animation at the end of the active duration');
 }
 
 
-test(function()
+test(function(t)
 {
-  var div = addDiv();
+  var div = addDiv(t, {'class': 'animated-div'});
 
   div.style.animation = 'anim ' + ANIM_DUR_MS + 'ms ' + ANIM_DELAY_MS + 'ms';
 
   var player = div.getAnimationPlayers()[0];
 
   // Animations shouldn't start until the next paint tick, so:
   assert_equals(player.startTime, null,
     'AnimationPlayer.startTime should be unresolved when an animation ' +
@@ -316,23 +306,21 @@ test(function()
   // the past or is resolved in the future.
 
   var currentTime = document.timeline.currentTime;
   player.startTime = document.timeline.currentTime;
   assert_approx_equals(player.startTime, currentTime, 0.0001, // rounding error
     'Check setting of startTime actually works');
 
   checkStateOnSettingStartTimeToAnimationCreationTime(player);
-
-  div.parentNode.removeChild(div);
 }, 'Examine newly created Animation');
 
 
 async_test(function(t) {
-  var div = addDiv();
+  var div = addDiv(t, {'class': 'animated-div'});
   var eventWatcher = new EventWatcher(div, CSS_ANIM_EVENTS);
 
   div.style.animation = 'anim ' + ANIM_DUR_MS + 'ms ' + ANIM_DELAY_MS + 'ms';
 
   var player = div.getAnimationPlayers()[0];
 
   player.ready.then(t.step_func(function() {
     checkStateOnReadyPromiseResolved(player);
@@ -349,27 +337,26 @@ async_test(function(t) {
     checkStateAtNinetyPctOfActiveInterval(player);
 
     player.startTime = document.timeline.currentTime - ANIM_DELAY_MS - ANIM_DUR_MS; // end of active interval
     return eventWatcher.waitForEvent('animationend');
   })).then(t.step_func(function() {
     checkStateAtActiveIntervalEndTime(player);
 
     eventWatcher.stopWatching();
-    div.parentNode.removeChild(div);
   })).catch(t.step_func(function(reason) {
     assert_true(false, reason);
   })).then(function() {
     t.done();
   });
 }, 'Skipping forward through animation');
 
 
 async_test(function(t) {
-  var div = addDiv();
+  var div = addDiv(t, {'class': 'animated-div'});
   var eventWatcher = new EventWatcher(div, CSS_ANIM_EVENTS);
 
   div.style.animation = 'anim ' + ANIM_DUR_MS + 'ms ' + ANIM_DELAY_MS + 'ms';
 
   var player = div.getAnimationPlayers()[0];
 
   player.startTime = document.timeline.currentTime - ANIM_DELAY_MS - ANIM_DUR_MS; // end of active interval
 
@@ -401,17 +388,16 @@ async_test(function(t) {
     // 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() {
     checkStateOnReadyPromiseResolved(player);
 
     eventWatcher.stopWatching();
-    div.parentNode.removeChild(div);
   })).catch(t.step_func(function(reason) {
     assert_true(false, reason);
   })).then(function() {
     t.done();
   });
 
   // This must come after we've set up the Promise chain, since requesting
   // computed style will force events to be dispatched.
@@ -441,17 +427,17 @@ async_test(function(t) {
 // We do all these tests in a single async_test since that allows us to share
 // the timeout that we use to wait so that this test file isn't delayed by the
 // timeout time multiplied by number of tests.
 async_test(function(t) {
   var divs = new Array(6);
   var eventWatchers = new Array(6);
   var players = new Array(6);
   for (let i = 0; i < 6; i++) {
-    divs[i] = addDiv();
+    divs[i] = addDiv(t, {'class': 'animated-div'});
     eventWatchers[i] = new EventWatcher(divs[i], CSS_ANIM_EVENTS);
     divs[i].style.animation = 'anim ' + ANIM_DUR_MS + 'ms ' + ANIM_DELAY_MS + 'ms';
     players[i] = divs[i].getAnimationPlayers()[0];
   }
 
   var beforeTime = document.timeline.currentTime - ANIM_DELAY_MS / 2;
   var activeTime = document.timeline.currentTime - ANIM_DELAY_MS - ANIM_DUR_MS / 2;
   var afterTime = document.timeline.currentTime - ANIM_DELAY_MS - ANIM_DUR_MS - ANIM_DELAY_MS / 2;
@@ -492,61 +478,56 @@ async_test(function(t) {
   });
   players[5].startTime = afterTime; // get us into the initial state
 
   // See the long comment documenting this async_test for an explanation of
   // why we have this timeout and its relationship to intermittent failure.
   setTimeout(function() {
     for (let i = 0; i < 6; i++) {
       eventWatchers[i].stopWatching();
-      divs[i].parentNode.removeChild(divs[i]);
     }
     t.done();
   }, 1000);
 }, 'Redundant changes');
 
 
 async_test(function(t) {
-  var div = addDiv();
+  var div = addDiv(t, {'class': 'animated-div'});
   div.style.animation = 'anim ' + ANIM_DUR_MS + 'ms ' + ANIM_DELAY_MS + 'ms';
 
   var player = div.getAnimationPlayers()[0];
 
   player.ready.then(t.step_func(function() {
     player.startTime = null;
     return player.ready;
-  })).then(t.step_func(function() {
-    div.parentNode.removeChild(div);
   })).catch(t.step_func(function(reason) {
     assert_true(false, reason);
   })).then(function() {
     t.done();
   });
 }, 'Setting startTime to null');
 
 
 async_test(function(t) {
-  var div = addDiv();
+  var div = addDiv(t, {'class': 'animated-div'});
   div.style.animation = 'anim 100s';
 
   var player = div.getAnimationPlayers()[0];
 
   player.ready.then(t.step_func(function() {
     var savedStartTime = player.startTime;
 
     assert_not_equals(player.startTime, null,
       'AnimationPlayer.startTime not null on ready Promise resolve');
 
     player.pause();
     assert_equals(player.startTime, null,
       'AnimationPlayer.startTime is null after paused');
     assert_equals(player.playState, 'paused',
       'AnimationPlayer.playState is "paused" after pause() call');
-
-    div.parentNode.removeChild(div);
   })).catch(t.step_func(function(reason) {
     assert_true(false, reason);
   })).then(function() {
     t.done();
   });
 }, 'AnimationPlayer.startTime after paused');
 
     </script>