Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement onremove event for web animations. #21418

Merged
merged 1 commit into from Jan 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 58 additions & 0 deletions web-animations/interfaces/Animation/onremove.html
@@ -0,0 +1,58 @@
<!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' });

let finishedTimelineTime = null;
animB.onfinish = event => {
finishedTimelineTime = event.timelineTime;
};

animA.onremove = t.step_func_done(event => {
assert_equals(animA.replaceState, 'removed');
assert_equals(event.currentTime, 1);
assert_true(finishedTimelineTime != null, 'finished event fired');
assert_true(event.timelineTime == finishedTimelineTime,
'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>