Bug 927349 part 25 - Test cancelling of players; r=heycam
authorBrian Birtles <birtles@gmail.com>
Thu, 25 Dec 2014 16:28:24 +0900
changeset 221977 48523f909ffb989ea6db0938b0e3648bb902a2f7
parent 221976 413db6659fef3370473fc2511b7cc819c10999f9
child 221978 0f50d69bc63f17828782f3ba8fe81f7a4ddb2782
push id53485
push userbbirtles@mozilla.com
push dateMon, 05 Jan 2015 11:10:01 +0000
treeherdermozilla-inbound@7d7ac60fb354 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs927349
milestone37.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 927349 part 25 - Test cancelling of players; r=heycam
dom/animation/test/css-animations/test_animation-player-ready.html
dom/animation/test/css-transitions/test_animation-player-ready.html
--- a/dom/animation/test/css-animations/test_animation-player-ready.html
+++ b/dom/animation/test/css-animations/test_animation-player-ready.html
@@ -70,9 +70,67 @@ async_test(function(t) {
   player.ready.then(function(resolvedPlayer) {
     assert_equals(resolvedPlayer, player,
                   'Object identity of player passed to Promise callback'
                   + ' matches the player object owning the Promise');
     t.done();
   });
 }, 'The ready promise is fulfilled with its AnimationPlayer');
 
+async_test(function(t) {
+  var div = addDiv(t);
+
+  // Set up pending animation
+  div.style.animation = 'abc 100s';
+  var player = div.getAnimationPlayers()[0];
+  assert_equals(player.playState, 'pending', 'Player is initially pending');
+
+  // Set up listeners on ready promise
+  player.ready.then(t.step_func(function() {
+    assert_unreached('ready promise is fulfilled');
+  })).catch(t.step_func(function(err) {
+    assert_equals(err.name, 'AbortError',
+                  'ready promise is rejected with AbortError');
+    assert_equals(player.playState, 'idle',
+                  'Player is idle after animation was cancelled');
+  })).then(t.step_func(function() {
+    t.done();
+  }));
+
+  // Now cancel the animation and flush styles
+  div.style.animation = '';
+  window.getComputedStyle(div).animation;
+
+}, 'ready promise is rejected when an animation is cancelled by resetting'
+   + ' the animation property');
+
+async_test(function(t) {
+  var div = addDiv(t);
+
+  // As before, but this time instead of removing all animations, simply update
+  // the list of animations. At least for Firefox, updating is a different
+  // code path.
+
+  // Set up pending animation
+  div.style.animation = 'abc 100s';
+  var player = div.getAnimationPlayers()[0];
+  assert_equals(player.playState, 'pending', 'Player is initially pending');
+
+  // Set up listeners on ready promise
+  player.ready.then(t.step_func(function() {
+    assert_unreached('ready promise was fulfilled');
+  })).catch(t.step_func(function(err) {
+    assert_equals(err.name, 'AbortError',
+                  'ready promise is rejected with AbortError');
+    assert_equals(player.playState, 'idle',
+                  'Player is idle after animation was cancelled');
+  })).then(t.step_func(function() {
+    t.done();
+  }));
+
+  // Now update the animation and flush styles
+  div.style.animation = 'def 100s';
+  window.getComputedStyle(div).animation;
+
+}, 'ready promise is rejected when an animation is cancelled by updating'
+   + ' the animation property');
+
 </script>
--- a/dom/animation/test/css-transitions/test_animation-player-ready.html
+++ b/dom/animation/test/css-transitions/test_animation-player-ready.html
@@ -30,9 +30,41 @@ async_test(function(t) {
     assert_not_equals(player.ready, originalReadyPromise,
                       'Ready promise object identity differs after calling'
                       + ' play()');
     t.done();
   }));
 }, 'A new ready promise is created each time play() is called'
    + ' the animation property');
 
+async_test(function(t) {
+  var div = addDiv(t);
+
+  // Set up pending transition
+  div.style.transform = 'translate(0px)';
+  window.getComputedStyle(div).transform;
+  div.style.transition = 'transform 100s';
+  div.style.transform = 'translate(10px)';
+  window.getComputedStyle(div).transform;
+
+  var player = div.getAnimationPlayers()[0];
+  assert_equals(player.playState, 'pending', 'Player is initially pending');
+
+  // Set up listeners on ready promise
+  player.ready.then(t.step_func(function() {
+    assert_unreached('ready promise was fulfilled');
+  })).catch(t.step_func(function(err) {
+    assert_equals(err.name, 'AbortError',
+                  'ready promise is rejected with AbortError');
+    assert_equals(player.playState, 'idle',
+                  'Player is idle after transition was cancelled');
+  })).then(t.step_func(function() {
+    t.done();
+  }));
+
+  // Now remove transform from transition-property and flush styles
+  div.style.transitionProperty = 'none';
+  window.getComputedStyle(div).transitionProperty;
+
+}, 'ready promise is rejected when a transition is cancelled by updating'
+   + ' transition-property');
+
 </script>