Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement onremove event for web animations.
Spec: https://drafts.csswg.org/web-animations-1/#remove-replaced-animations Intent: https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/H5sz_dg6fKc/1X7K7U4XCgAJ Bug: 981905 Change-Id: I9267e3e4fda14133f2edcc0e8aea1e8a031959a1
- Loading branch information
1 parent
ccb23a9
commit a5f1446
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
|