blob: 761e7a55c1c45bc7c15cf623d95efdb4f90b185f [file] [log] [blame]
<!DOCTYPE html>
<meta charset=utf-8>
<title>Get Animations</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>
<div id='container'>
<div id='element'></div>
</div>
<script>
var container = document.getElementById('container');
var element = document.getElementById('element');
test(function() {
assert_equals(document.getAnimations().length, 0);
assert_equals(container.getAnimations().length, 0);
assert_equals(element.getAnimations().length, 0);
var animation = element.animate([], 1000);
assert_equals(document.getAnimations().length, 1);
assert_equals(document.getAnimations()[0], animation);
assert_equals(container.getAnimations().length, 0);
assert_equals(element.getAnimations().length, 1);
assert_equals(element.getAnimations()[0], animation);
var animation2 = container.animate([], 1000);
assert_equals(document.getAnimations().length, 2);
assert_equals(document.getAnimations()[0], animation);
assert_equals(document.getAnimations()[1], animation2);
assert_equals(container.getAnimations().length, 1);
assert_equals(container.getAnimations()[0], animation2);
assert_equals(element.getAnimations().length, 1);
assert_equals(element.getAnimations()[0], animation);
animation.finish();
assert_equals(document.getAnimations().length, 1);
assert_equals(document.getAnimations()[0], animation2);
assert_equals(container.getAnimations().length, 1);
assert_equals(container.getAnimations()[0], animation2);
assert_equals(element.getAnimations().length, 0);
animation2.finish();
assert_equals(document.getAnimations().length, 0);
assert_equals(container.getAnimations().length, 0);
assert_equals(element.getAnimations().length, 0);
}, 'getAnimations() normal behaviour (without delays)');
test(function() {
assert_equals(document.getAnimations().length, 0);
assert_equals(container.getAnimations().length, 0);
assert_equals(element.getAnimations().length, 0);
var animation = element.animate([], {duration: 1000, delay: 500});
assert_equals(document.getAnimations().length, 1);
assert_equals(document.getAnimations()[0], animation);
assert_equals(container.getAnimations().length, 0);
assert_equals(element.getAnimations().length, 1);
assert_equals(element.getAnimations()[0], animation);
animation.finish();
assert_equals(document.getAnimations().length, 0);
assert_equals(container.getAnimations().length, 0);
assert_equals(element.getAnimations().length, 0);
}, 'getAnimations() with animation delays');
test(function() {
assert_equals(document.getAnimations().length, 0);
assert_equals(container.getAnimations().length, 0);
assert_equals(element.getAnimations().length, 0);
var animation = element.animate([], {duration: 1000, delay: 500, fill: 'both'});
assert_equals(document.getAnimations().length, 1);
assert_equals(document.getAnimations()[0], animation);
assert_equals(container.getAnimations().length, 0);
assert_equals(element.getAnimations().length, 1);
assert_equals(element.getAnimations()[0], animation);
animation.finish();
assert_equals(document.getAnimations().length, 1);
assert_equals(container.getAnimations().length, 0);
assert_equals(element.getAnimations().length, 1);
}, 'getAnimations() with in effect animations');
</script>