Bug 1033881 part 2 - Add tests to test_element-get-animation-players.html which checks for animation-name: missing; r=dbaron
authorBrian Birtles <birtles@gmail.com>
Thu, 17 Jul 2014 10:04:56 +0900
changeset 194534 40a3b13a460b12e84853ebd5d6752486edc250db
parent 194533 8418588984742f485dfb382f146d6d82ee28aebf
child 194535 eb7dda331d9941916537b4a0949eda94c35f5f5b
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersdbaron
bugs1033881
milestone33.0a1
Bug 1033881 part 2 - Add tests to test_element-get-animation-players.html which checks for animation-name: missing; r=dbaron
dom/animation/test/css-integration/test_element-get-animation-players.html
--- a/dom/animation/test/css-integration/test_element-get-animation-players.html
+++ b/dom/animation/test/css-integration/test_element-get-animation-players.html
@@ -191,16 +191,64 @@ test(function() {
     'getAnimationPlayers returns players only for those CSS Animations whose'
     + ' animation-name is not none');
 
   div.remove();
 }, 'getAnimationPlayers for CSS Animations with animation-name: none');
 
 test(function() {
   var div = addDiv();
+  div.style.animation = 'missing 100s';
+  window.getComputedStyle(div).animationName;
+
+  var players = div.getAnimationPlayers();
+  assert_equals(players.length, 0,
+    'getAnimationPlayers returns an empty sequence for an element'
+    + ' with animation-name: missing');
+
+  div.style.animation = 'anim1 100s, missing 100s';
+  window.getComputedStyle(div).animationName;
+  players = div.getAnimationPlayers();
+  assert_equals(players.length, 1,
+    'getAnimationPlayers returns players only for those CSS Animations whose'
+    + ' animation-name is found');
+
+  div.remove();
+}, 'getAnimationPlayers for CSS Animations with animation-name: missing');
+
+async_test(function(t) {
+  var div = addDiv();
+  div.style.animation = 'anim1 100s, notyet 100s';
+  window.getComputedStyle(div).animationName;
+
+  var players = div.getAnimationPlayers();
+  assert_equals(players.length, 1,
+    'getAnimationPlayers initally only returns players for CSS Animations whose'
+    + ' animation-name is found');
+
+  window.requestAnimationFrame(t.step_func(function() {
+    var keyframes = '@keyframes notyet { to { left: 100px; } }';
+    document.styleSheets[0].insertRule(keyframes, 0);
+    window.getComputedStyle(div).animationName;
+
+    players = div.getAnimationPlayers();
+    assert_equals(players.length, 2,
+      'getAnimationPlayers includes player when @keyframes rule is added'
+      + ' later');
+    assert_true(players[0].startTime < players[1].startTime,
+      'Newly added player has a later start time');
+    document.styleSheets[0].deleteRule(0);
+    div.remove();
+    t.done();
+  }));
+}, 'getAnimationPlayers for CSS Animations where the @keyframes rule is added'
+   + ' later');
+
+test(function() {
+  var div = addDiv();
   div.style.animation = 'anim1 100s, anim1 100s';
   window.getComputedStyle(div).animationName;
 
   assert_equals(div.getAnimationPlayers().length, 2,
     'getAnimationPlayers returns one player for each CSS animation-name'
     + ' even if the names are duplicated');
   div.remove();
 }, 'getAnimationPlayers for CSS Animations with duplicated animation-name');