Bug 927349 part 30 - Cancel transitions when we have a change to a non-animatable style; r=heycam

This commit is contained in:
Brian Birtles 2015-01-06 10:55:59 +09:00
parent 97155a7290
commit 62ee098b80
2 changed files with 33 additions and 0 deletions

View File

@ -67,4 +67,36 @@ async_test(function(t) {
}, 'ready promise is rejected when a transition is cancelled by updating'
+ ' transition-property');
async_test(function(t) {
var div = addDiv(t);
// Set up pending transition
div.style.marginLeft = '0px';
window.getComputedStyle(div).marginLeft;
div.style.transition = 'margin-left 100s';
div.style.marginLeft = '100px';
window.getComputedStyle(div).marginLeft;
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 update the transition to animate to something not-interpolable
div.style.marginLeft = 'auto';
window.getComputedStyle(div).marginLeft;
}, 'ready promise is rejected when a transition is cancelled by changing'
+ ' the transition property to something not interpolable');
</script>

View File

@ -452,6 +452,7 @@ nsTransitionManager::ConsiderStartingTransition(
// currently in the 'transition-delay'). It also might happen because we
// just got a style change to a value that can't be interpolated.
AnimationPlayerPtrArray& players = aElementTransitions->mPlayers;
players[currentIndex]->Cancel();
oldPT = nullptr; // Clear pointer so it doesn't dangle
players.RemoveElementAt(currentIndex);
aElementTransitions->UpdateAnimationGeneration(mPresContext);