Bug 1453568 - Rewrite async_test in oncancel.html with promise_test with async/await. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Tue, 17 Apr 2018 08:26:41 +0900
changeset 783341 8ecd4e30e4a9ec05c5572e9b4bef919ed6504eb7
parent 782894 ceb3db3b31a07a2aaa164bdacb21f4135373aadb
child 783342 6722e3e218a7043a90a0bb7ecd8e648cccd8430e
push id106674
push userhikezoe@mozilla.com
push dateTue, 17 Apr 2018 01:36:18 +0000
reviewersbirtles
bugs1453568
milestone61.0a1
Bug 1453568 - Rewrite async_test in oncancel.html with promise_test with async/await. r?birtles MozReview-Commit-ID: CevZBM20koz
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/web-animations/interfaces/Animation/oncancel.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -599696,17 +599696,17 @@
    "4e3dd92351d76c5c7d09ddd1ca025520f4c8875d",
    "testharness"
   ],
   "web-animations/interfaces/Animation/idlharness.html": [
    "d61aa2d95ea31809a275183408e822c8c1eec87d",
    "testharness"
   ],
   "web-animations/interfaces/Animation/oncancel.html": [
-   "82abc08a0b416f5198239464fb4fc01d2edd6e1c",
+   "04d9893cd9968f71971bafd7a9bcbb6e3c955cdd",
    "testharness"
   ],
   "web-animations/interfaces/Animation/onfinish.html": [
    "db82fabeaf2b646647f134634fef30f05e5ec7f8",
    "testharness"
   ],
   "web-animations/interfaces/Animation/pause.html": [
    "f044cc7ac09c38f127e399f7d6f9a0714046aa8e",
--- a/testing/web-platform/tests/web-animations/interfaces/Animation/oncancel.html
+++ b/testing/web-platform/tests/web-animations/interfaces/Animation/oncancel.html
@@ -5,29 +5,30 @@
 <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().catch(() => {
     finishedTimelineTime = animation.timeline.currentTime;
   });
 
-  animation.oncancel = t.step_func_done(event => {
-    assert_equals(event.currentTime, null,
-      'event.currentTime should be null');
-    assert_equals(event.timelineTime, finishedTimelineTime,
-      'event.timelineTime should equal to the animation timeline ' +
-      'when finished promise is rejected');
-  });
+  const eventWatcher = new EventWatcher(t, animation, 'cancel');
+  animation.cancel();
+
+  const event = await eventWatcher.wait_for('cancel');
 
-  animation.cancel();
+  assert_equals(event.currentTime, null,
+    'event.currentTime should be null');
+  assert_equals(event.timelineTime, finishedTimelineTime,
+    'event.timelineTime should equal to the animation timeline ' +
+    'when finished promise is rejected');
 }, 'oncancel event is fired when animation.cancel() is called.');
 
 </script>
 </body>