Files
tubestation/dom/animation/test/css-transitions/test_setting-effect.html
Brian Birtles eecc3b000d Bug 1382841 - Rename test_XXX_to_rename.html files in dom/animation/test to test_XXX.html; r=hiro
See the description in this changeset's parent which describes why we do this in
two steps.

MozReview-Commit-ID: GtO0SCb0UOF
2018-03-12 16:08:35 +09:00

103 lines
3.4 KiB
HTML

<!doctype html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src='../testcommon.js'></script>
<body>
<div id="log"></div>
<script>
'use strict';
promise_test(function(t) {
var div = addDiv(t);
var watcher = new EventWatcher(t, div, [ 'transitionend',
'transitioncancel' ]);
div.style.left = '0px';
div.style.transition = 'left 100s';
flushComputedStyle(div);
div.style.left = '100px';
var transition = div.getAnimations()[0];
return transition.ready.then(function() {
transition.currentTime = 50 * MS_PER_SEC;
transition.effect = null;
assert_equals(transition.transitionProperty, 'left');
assert_equals(transition.playState, 'finished');
assert_equals(getComputedStyle(div).left, '100px');
return watcher.wait_for('transitionend');
});
}, 'Test for removing a transition effect');
promise_test(function(t) {
var div = addDiv(t);
var watcher = new EventWatcher(t, div, [ 'transitionend',
'transitioncancel' ]);
div.style.left = '0px';
div.style.transition = 'left 100s';
flushComputedStyle(div);
div.style.left = '100px';
var transition = div.getAnimations()[0];
return transition.ready.then(function() {
transition.currentTime = 50 * MS_PER_SEC;
transition.effect = new KeyframeEffect(div,
{ marginLeft: [ '0px' , '100px'] },
100 * MS_PER_SEC);
assert_equals(transition.transitionProperty, 'left');
assert_equals(transition.playState, 'running');
assert_equals(getComputedStyle(div).left, '100px');
assert_equals(getComputedStyle(div).marginLeft, '50px');
});
}, 'Test for replacing the transition effect by a new keyframe effect');
promise_test(function(t) {
var div = addDiv(t);
var watcher = new EventWatcher(t, div, [ 'transitionend',
'transitioncancel' ]);
div.style.left = '0px';
div.style.width = '0px';
div.style.transition = 'left 100s';
flushComputedStyle(div);
div.style.left = '100px';
var transition = div.getAnimations()[0];
return transition.ready.then(function() {
transition.currentTime = 50 * MS_PER_SEC;
transition.effect = new KeyframeEffect(div,
{ marginLeft: [ '0px' , '100px'] },
20 * MS_PER_SEC);
assert_equals(transition.playState, 'finished');
});
}, 'Test for setting a new keyframe effect with a shorter duration');
promise_test(function(t) {
var div = addDiv(t);
var watcher = new EventWatcher(t, div, [ 'transitionend',
'transitioncancel' ]);
div.style.left = '0px';
div.style.width = '0px';
div.style.transition = 'left 100s';
flushComputedStyle(div);
div.style.left = '100px';
var transition = div.getAnimations()[0];
assert_true(transition.pending);
transition.effect = new KeyframeEffect(div,
{ marginLeft: [ '0px' , '100px'] },
100 * MS_PER_SEC);
assert_equals(transition.transitionProperty, 'left');
assert_true(transition.pending);
return transition.ready.then(function() {
assert_false(transition.pending);
});
}, 'Test for setting a new keyframe effect to a pending transition');
</script>
</body>