Bug 1067769 - Part 3: Test for KeyframeEffectReadOnly with null target. r=birtles

MozReview-Commit-ID: DQ5k6W1bgUC

--HG--
extra : rebase_source : 44b919cb3e227a3aa6b2d0adce582d4e8338b8f9
This commit is contained in:
Boris Chiou 2016-04-28 23:22:42 +08:00
Родитель ea72ffdf23
Коммит 6679d6416c
6 изменённых файлов: 109 добавлений и 0 удалений

Просмотреть файл

@ -1718,6 +1718,21 @@ addAsyncAnimTest("exclude_animations_targeting_pseudo_elements",
"records after animation is finished");
});
addAsyncAnimTest("create_animation_without_target",
{ observe: document, subtree: true }, function*() {
var effect = new KeyframeEffectReadOnly(null,
{ opacity: [ 0, 1 ] },
{ duration: 10000 });
var anim = new Animation(effect, document.timeline);
anim.play();
yield await_frame();
assert_records([], "no records after animation is added");
anim.cancel();
yield await_frame();
assert_records([], "no records after animation is removed");
});
// Run the tests.
SimpleTest.requestLongerTimeout(2);
SimpleTest.waitForExplicitFinish();

Просмотреть файл

@ -28849,6 +28849,10 @@
"path": "web-animations/animation/reverse.html",
"url": "/web-animations/animation/reverse.html"
},
{
"path": "web-animations/document/getAnimations.html",
"url": "/web-animations/document/getAnimations.html"
},
{
"path": "web-animations/keyframe-effect/constructor.html",
"url": "/web-animations/keyframe-effect/constructor.html"

Просмотреть файл

@ -55,5 +55,19 @@ gTestArguments.forEach(function(args) {
}, "Animation can be constructed " + args.description);
});
test(function(t) {
var effect = new KeyframeEffectReadOnly(null,
{ left: ["10px", "20px"] },
{ duration: 10000,
fill: "forwards" });
var anim = new Animation(effect, document.timeline);
anim.pause();
assert_equals(effect.getComputedTiming().progress, 0.0);
anim.currentTime += 5000;
assert_equals(effect.getComputedTiming().progress, 0.5);
anim.finish();
assert_equals(effect.getComputedTiming().progress, 1.0);
}, "Animation constructed by an effect with null target runs normally");
</script>
</body>

Просмотреть файл

@ -203,5 +203,45 @@ promise_test(function(t) {
'Animation.finish()');
});
}, 'Test finish() resolves finished promise synchronously');
promise_test(function(t) {
var effect = new KeyframeEffectReadOnly(null, gKeyFrames, 100 * MS_PER_SEC);
var animation = new Animation(effect, document.timeline);
var resolvedFinished = false;
animation.finished.then(function() {
resolvedFinished = true;
});
return animation.ready.then(function() {
animation.finish();
}).then(function() {
assert_true(resolvedFinished,
'Animation.finished should be resolved soon after ' +
'Animation.finish()');
});
}, 'Test finish() resolves finished promise synchronously with an animation ' +
'without a target');
promise_test(function(t) {
var effect = new KeyframeEffectReadOnly(null, gKeyFrames, 100 * MS_PER_SEC);
var animation = new Animation(effect, document.timeline);
animation.play();
var resolvedFinished = false;
animation.finished.then(function() {
resolvedFinished = true;
});
return animation.ready.then(function() {
animation.currentTime = animation.effect.getComputedTiming().endTime - 1;
return waitForAnimationFrames(2);
}).then(function() {
assert_true(resolvedFinished,
'Animation.finished should be resolved soon after ' +
'Animation finishes normally');
});
}, 'Test normally finished animation resolves finished promise synchronously ' +
'with an animation without a target');
</script>
</body>

Просмотреть файл

@ -0,0 +1,27 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>document.getAnimations tests</title>
<link rel="help" href="https://w3c.github.io/web-animations/#dom-document-getanimations">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../testcommon.js"></script>
<body>
<div id="log"></div>
<div id="target"></div>
<script>
"use strict";
test(function(t) {
var effect = new KeyframeEffectReadOnly(null,
{ left: ['10px', '20px'] },
100 * MS_PER_SEC);
var anim = new Animation(effect, document.timeline);
anim.play();
assert_equals(document.getAnimations().length, 0,
'document.getAnimations() only returns animations targeting ' +
'elements in this document');
}, 'Test document.getAnimations with null target');
</script>
</body>

Просмотреть файл

@ -246,6 +246,15 @@ gInvalidKeyframeEffectOptionTests.forEach(function(stest) {
}, "Invalid KeyframeEffectReadOnly option by " + stest.desc);
});
test(function(t) {
var effect = new KeyframeEffectReadOnly(null,
{ left: ["10px", "20px"] },
{ duration: 100 * MS_PER_SEC,
fill: "forwards" });
assert_equals(effect.target, null,
"Effect created with null target has correct target");
}, "a KeyframeEffectReadOnly constructed with null target");
test(function(t) {
var effect = new KeyframeEffect(target, null);
assert_class_string(effect, "KeyframeEffect");