Bug 1302007 part 1 - Use the promise_test in transition cancel tests. r?birtles
MozReview-Commit-ID: 7cXfwkT7kaH
--- a/dom/animation/test/css-transitions/file_animation-cancel.html
+++ b/dom/animation/test/css-transitions/file_animation-cancel.html
@@ -1,106 +1,101 @@
<!doctype html>
<meta charset=utf-8>
<script src="../testcommon.js"></script>
<body>
<script>
'use strict';
-async_test(function(t) {
+promise_test(function(t) {
var div = addDiv(t, { style: 'margin-left: 0px' });
flushComputedStyle(div);
div.style.transition = 'margin-left 100s';
div.style.marginLeft = '1000px';
flushComputedStyle(div);
var animation = div.getAnimations()[0];
- animation.ready.then(waitForFrame).then(t.step_func(function() {
+ return animation.ready.then(waitForFrame).then(function() {
assert_not_equals(getComputedStyle(div).marginLeft, '1000px',
'transform style is animated before cancelling');
animation.cancel();
assert_equals(getComputedStyle(div).marginLeft, div.style.marginLeft,
'transform style is no longer animated after cancelling');
- t.done();
- }));
+ });
}, 'Animated style is cleared after cancelling a running CSS transition');
-async_test(function(t) {
+promise_test(function(t) {
var div = addDiv(t, { style: 'margin-left: 0px' });
flushComputedStyle(div);
div.style.transition = 'margin-left 100s';
div.style.marginLeft = '1000px';
flushComputedStyle(div);
- div.addEventListener('transitionend', t.step_func(function() {
+ div.addEventListener('transitionend', function() {
assert_unreached('Got unexpected end event on cancelled transition');
- }));
+ });
var animation = div.getAnimations()[0];
- animation.ready.then(t.step_func(function() {
+ return animation.ready.then(function() {
// Seek to just before the end then cancel
animation.currentTime = 99.9 * 1000;
animation.cancel();
// Then wait a couple of frames and check that no event was dispatched
return waitForAnimationFrames(2);
- })).then(t.step_func(function() {
- t.done();
- }));
+ });
}, 'Cancelled CSS transitions do not dispatch events');
-async_test(function(t) {
+promise_test(function(t) {
var div = addDiv(t, { style: 'margin-left: 0px' });
flushComputedStyle(div);
div.style.transition = 'margin-left 100s';
div.style.marginLeft = '1000px';
flushComputedStyle(div);
var animation = div.getAnimations()[0];
- animation.ready.then(t.step_func(function() {
+ return animation.ready.then(function() {
animation.cancel();
assert_equals(getComputedStyle(div).marginLeft, '1000px',
'margin-left style is not animated after cancelling');
animation.play();
assert_equals(getComputedStyle(div).marginLeft, '0px',
'margin-left style is animated after re-starting transition');
return animation.ready;
- })).then(t.step_func(function() {
+ }).then(function() {
assert_equals(animation.playState, 'running',
'Transition succeeds in running after being re-started');
- t.done();
- }));
+ });
}, 'After cancelling a transition, it can still be re-used');
-async_test(function(t) {
+promise_test(function(t) {
var div = addDiv(t, { style: 'margin-left: 0px' });
flushComputedStyle(div);
div.style.transition = 'margin-left 100s';
div.style.marginLeft = '1000px';
flushComputedStyle(div);
var animation = div.getAnimations()[0];
- animation.ready.then(t.step_func(function() {
+ return animation.ready.then(function() {
animation.finish();
animation.cancel();
assert_equals(getComputedStyle(div).marginLeft, '1000px',
'margin-left style is not animated after cancelling');
animation.play();
assert_equals(getComputedStyle(div).marginLeft, '0px',
'margin-left style is animated after re-starting transition');
return animation.ready;
- })).then(t.step_func(function() {
+ }).then(function() {
assert_equals(animation.playState, 'running',
'Transition succeeds in running after being re-started');
- t.done();
- }));
+ });
}, 'After cancelling a finished transition, it can still be re-used');
test(function(t) {
var div = addDiv(t, { style: 'margin-left: 0px' });
flushComputedStyle(div);
div.style.transition = 'margin-left 100s';
div.style.marginLeft = '1000px';