Bug 1354501 - Rewrite async_test in onfinish.html with promise_test with async/await. r?birtles
MozReview-Commit-ID: Di6yw1suwlP
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -604621,17 +604621,17 @@
"c73f39e1c27f1b04b4c44ac4e1e747ef3d24b287",
"testharness"
],
"web-animations/interfaces/Animation/oncancel.html": [
"82abc08a0b416f5198239464fb4fc01d2edd6e1c",
"testharness"
],
"web-animations/interfaces/Animation/onfinish.html": [
- "29b37a8ba9e653d2db88f628dd84bd99cb8be8db",
+ "eae6918f35a29c4fde575d4110f707f7fc863166",
"testharness"
],
"web-animations/interfaces/Animation/pause.html": [
"f044cc7ac09c38f127e399f7d6f9a0714046aa8e",
"testharness"
],
"web-animations/interfaces/Animation/pending.html": [
"5677f7e8b076dc096d636aaaa4d4191c286f1d90",
--- a/testing/web-platform/tests/web-animations/interfaces/Animation/onfinish.html
+++ b/testing/web-platform/tests/web-animations/interfaces/Animation/onfinish.html
@@ -5,75 +5,78 @@
<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 => {
+promise_test(async t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
let finishedTimelineTime;
animation.finished.then(() => {
finishedTimelineTime = animation.timeline.currentTime;
});
- animation.onfinish = t.step_func_done(event => {
- assert_equals(event.currentTime, 0,
- 'event.currentTime should be zero');
- assert_equals(event.timelineTime, finishedTimelineTime,
- 'event.timelineTime should equal to the animation timeline ' +
- 'when finished promise is resolved');
- });
+ const eventWatcher = new EventWatcher(t, animation, 'finish');
+ animation.playbackRate = -1;
+
+ const event = await eventWatcher.wait_for('finish');
- animation.playbackRate = -1;
+ assert_equals(event.currentTime, 0,
+ 'event.currentTime should be zero');
+ assert_equals(event.timelineTime, finishedTimelineTime,
+ 'event.timelineTime should equal to the animation timeline ' +
+ 'when finished promise is resolved');
}, 'onfinish event is fired when the currentTime < 0 and ' +
'the playbackRate < 0');
-async_test(t => {
+promise_test(async t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
let finishedTimelineTime;
animation.finished.then(() => {
finishedTimelineTime = animation.timeline.currentTime;
});
- animation.onfinish = t.step_func_done(event => {
- assert_equals(event.currentTime, 100 * MS_PER_SEC,
- 'event.currentTime should be the effect end');
- assert_equals(event.timelineTime, finishedTimelineTime,
- 'event.timelineTime should equal to the animation timeline ' +
- 'when finished promise is resolved');
- });
+ const eventWatcher = new EventWatcher(t, animation, 'finish');
+ animation.currentTime = 100 * MS_PER_SEC;
+
+ const event = await eventWatcher.wait_for('finish');
- animation.currentTime = 100 * MS_PER_SEC;
+ assert_equals(event.currentTime, 100 * MS_PER_SEC,
+ 'event.currentTime should be the effect end');
+ assert_equals(event.timelineTime, finishedTimelineTime,
+ 'event.timelineTime should equal to the animation timeline ' +
+ 'when finished promise is resolved');
}, 'onfinish event is fired when the currentTime > 0 and ' +
'the playbackRate > 0');
-async_test(t => {
+promise_test(async t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
let finishedTimelineTime;
animation.finished.then(() => {
finishedTimelineTime = animation.timeline.currentTime;
});
- animation.onfinish = t.step_func_done(event => {
- assert_equals(event.currentTime, 100 * MS_PER_SEC,
- 'event.currentTime should be the effect end');
- assert_equals(event.timelineTime, finishedTimelineTime,
- 'event.timelineTime should equal to the animation timeline ' +
- 'when finished promise is resolved');
- });
+ const eventWatcher = new EventWatcher(t, animation, 'finish');
+ animation.finish();
+
+ const event = await eventWatcher.wait_for('finish');
- animation.finish();
+ assert_equals(event.currentTime, 100 * MS_PER_SEC,
+ 'event.currentTime should be the effect end');
+ assert_equals(event.timelineTime, finishedTimelineTime,
+ 'event.timelineTime should equal to the animation timeline ' +
+ 'when finished promise is resolved');
}, 'onfinish event is fired when animation.finish() is called');
promise_test(async t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
animation.onfinish = event => {
assert_unreached('onfinish event should not be fired');