Bug 1354501 - Rewrite async_test in onfinish.html with promise_test with async/await. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Fri, 20 Apr 2018 08:05:22 +0900
changeset 785385 93067255bb2ed35ad0c7f844ccadf85fd0bd7d4e
parent 785384 66c174d37a0db23ebe8a1b5e82e5485b45249886
child 785386 7e0c96791b5f7de605040f396e70ef3d3c985172
push id107210
push userhikezoe@mozilla.com
push dateFri, 20 Apr 2018 00:11:06 +0000
reviewersbirtles
bugs1354501
milestone61.0a1
Bug 1354501 - Rewrite async_test in onfinish.html with promise_test with async/await. r?birtles MozReview-Commit-ID: Di6yw1suwlP
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/web-animations/interfaces/Animation/onfinish.html
--- 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');