Skip to content

Commit

Permalink
Implement onremove event for web animations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Ellis authored and chromium-wpt-export-bot committed Jan 24, 2020
1 parent ccb23a9 commit a5f1446
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions web-animations/interfaces/Animation/onremove.html
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animation.onremove</title>
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-onremove">
<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';

async_test(t => {
const div = createDiv(t);
const animA = div.animate({ opacity: 1 }, { duration: 1, fill: 'forwards' });
const animB = div.animate({ opacity: 1 }, { duration: 1, fill: 'forwards' });

animA.onremove = t.step_func_done(event => {
assert_equals(animA.replaceState, 'removed');
assert_equals(event.currentTime, 1);
assert_true(event.timelineTime != null, 'timeline time is set');
});

}, 'onremove event is fired when replaced animation is removed.');

promise_test(async t => {
const div = createDiv(t);
const animA = div.animate({ opacity: 1 }, { duration: 1, fill: 'forwards' });
const animB = div.animate({ opacity: 1 }, { duration: 1, fill: 'forwards' });
const animC = div.animate({ opacity: 1 }, { duration: 1, fill: 'forwards' });
const animD = div.animate({ opacity: 1 }, { duration: 1, fill: 'forwards' });

const removed = [];

animA.onremove = () => { removed.push('A'); };
animB.onremove = () => { removed.push('B'); };
animC.onremove = () => { removed.push('C'); };

animD.onremove = event => {
assert_unreached('onremove event should not be fired');
};

await waitForAnimationFrames(2);

assert_equals(removed.join(''), 'ABC');

}, 'onremove events are fired in the correct order');

</script>
</body>

0 comments on commit a5f1446

Please sign in to comment.