Bug 1265611 - Add tests that we ignore disabled properties when creating animations from the Web Animations API; r=heycam

MozReview-Commit-ID: 81XkkwtyJLt
This commit is contained in:
Brian Birtles 2016-04-21 17:05:47 +09:00
parent 383f4aa97c
commit e82da4fa99
3 changed files with 89 additions and 0 deletions

View File

@ -36,6 +36,7 @@ support-files =
css-transitions/file_pseudoElement-get-animations.html css-transitions/file_pseudoElement-get-animations.html
document-timeline/file_document-timeline.html document-timeline/file_document-timeline.html
mozilla/file_deferred_start.html mozilla/file_deferred_start.html
mozilla/file_disabled_properties.html
mozilla/file_hide_and_show.html mozilla/file_hide_and_show.html
mozilla/file_partial_keyframes.html mozilla/file_partial_keyframes.html
testcommon.js testcommon.js
@ -78,5 +79,6 @@ skip-if = buildapp == 'mulet'
skip-if = buildapp == 'mulet' skip-if = buildapp == 'mulet'
[mozilla/test_deferred_start.html] [mozilla/test_deferred_start.html]
skip-if = (toolkit == 'gonk' && debug) skip-if = (toolkit == 'gonk' && debug)
[mozilla/test_disabled_properties.html]
[mozilla/test_hide_and_show.html] [mozilla/test_hide_and_show.html]
[mozilla/test_partial_keyframes.html] [mozilla/test_partial_keyframes.html]

View File

@ -0,0 +1,73 @@
<!doctype html>
<meta charset=utf-8>
<script src="../testcommon.js"></script>
<body>
<script>
'use strict';
function waitForSetPref(pref, value) {
return new Promise(function(resolve, reject) {
SpecialPowers.pushPrefEnv({ 'set': [[pref, value]] }, resolve);
});
}
/*
* These tests rely on the fact that the -webkit-text-fill-color property
* is disabled by the layout.css.prefixes.webkit pref. If we ever remove that
* pref we will need to substitute some other pref:property combination.
*/
promise_test(function(t) {
return waitForSetPref('layout.css.prefixes.webkit', true).then(() => {
var anim = addDiv(t).animate({ webkitTextFillColor: [ 'green', 'blue' ]});
assert_equals(anim.effect.getFrames().length, 2,
'A property-indexed keyframe specifying only enabled'
+ ' properties produces keyframes');
return waitForSetPref('layout.css.prefixes.webkit', false);
}).then(() => {
var anim = addDiv(t).animate({ webkitTextFillColor: [ 'green', 'blue' ]});
assert_equals(anim.effect.getFrames().length, 0,
'A property-indexed keyframe specifying only disabled'
+ ' properties produces no keyframes');
});
}, 'Specifying a disabled property using a property-indexed keyframe');
promise_test(function(t) {
var createAnim = () => {
var anim = addDiv(t).animate([ { webkitTextFillColor: 'green' },
{ webkitTextFillColor: 'blue' } ]);
assert_equals(anim.effect.getFrames().length, 2,
'Animation specified using a keyframe sequence should'
+ ' return the same number of keyframes regardless of'
+ ' whether or not the specified properties are disabled');
return anim;
};
var assert_has_property = (anim, index, descr, property) => {
assert_true(
anim.effect.getFrames()[index].hasOwnProperty(property),
`${descr} should have the '${property}' property`);
};
var assert_does_not_have_property = (anim, index, descr, property) => {
assert_false(
anim.effect.getFrames()[index].hasOwnProperty(property),
`${descr} should NOT have the '${property}' property`);
};
return waitForSetPref('layout.css.prefixes.webkit', true).then(() => {
var anim = createAnim();
assert_has_property(anim, 0, 'Initial keyframe', 'webkitTextFillColor');
assert_has_property(anim, 1, 'Final keyframe', 'webkitTextFillColor');
return waitForSetPref('layout.css.prefixes.webkit', false);
}).then(() => {
var anim = createAnim();
assert_does_not_have_property(anim, 0, 'Initial keyframe',
'webkitTextFillColor');
assert_does_not_have_property(anim, 1, 'Final keyframe',
'webkitTextFillColor');
});
}, 'Specifying a disabled property using a keyframe sequence');
done();
</script>
</body>

View File

@ -0,0 +1,14 @@
<!doctype html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
'use strict';
setup({explicit_done: true});
SpecialPowers.pushPrefEnv(
{ "set": [["dom.animations-api.core.enabled", true]]},
function() {
window.open("file_disabled_properties.html");
});
</script>