Bug 1466031 - Update event-dispatch test now that we can use the updated EventWatcher; r?hiro draft
authorBrian Birtles <birtles@gmail.com>
Fri, 01 Jun 2018 17:00:58 +0900
changeset 802601 477c258b01e75d7c11101ec4c0658ea031b416d5
parent 802600 ebd646aea7bc72f5f7f02aa2a8fd5a86565f4497
push id111925
push userbmo:bbirtles@mozilla.com
push dateFri, 01 Jun 2018 08:01:47 +0000
reviewershiro
bugs1466031
milestone62.0a1
Bug 1466031 - Update event-dispatch test now that we can use the updated EventWatcher; r?hiro MozReview-Commit-ID: J4JPsOWIL8a
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/css/css-animations/event-dispatch.tentative.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -494279,17 +494279,17 @@
    "15d495003fa9616fc54a4f6072e531341d51185f",
    "testharness"
   ],
   "css/css-animations/animationstart-and-animationend-events.html": [
    "d4692e2ac84a6dbbc9efd7937964d43ecd9dd109",
    "manual"
   ],
   "css/css-animations/event-dispatch.tentative.html": [
-   "e1940173a00e421b4d730db538259643b55db5c4",
+   "e5343fdccf63d69332fa1ad7a51460ac5284e4c8",
    "testharness"
   ],
   "css/css-animations/event-order.tentative.html": [
    "0115580619b629e47ae0f2635cc84e1e80442a8f",
    "testharness"
   ],
   "css/css-animations/pending-style-changes-001.html": [
    "5f2bf4b6712dd230109be62407cd31800451a271",
--- a/testing/web-platform/tests/css/css-animations/event-dispatch.tentative.html
+++ b/testing/web-platform/tests/css/css-animations/event-dispatch.tentative.html
@@ -1,157 +1,127 @@
 <!doctype html>
 <meta charset=utf-8>
 <title>Tests for CSS animation event dispatch</title>
 <link rel="help" href="https://drafts.csswg.org/css-animations-2/#event-dispatch"/>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script src="support/testcommon.js"></script>
 <style>
-  @keyframes anim {
-    from { margin-left: 0px; }
-    to { margin-left: 100px; }
-  }
+@keyframes anim {
+  from { margin-left: 0px; }
+  to { margin-left: 100px; }
+}
 </style>
 <body>
 <div id="log"></div>
 <script>
 'use strict';
 
-/**
- * Helper class to record the elapsedTime member of each event.
- * The EventWatcher class in testharness.js allows us to wait on
- * multiple events in a certain order but only records the event
- * parameters of the most recent event.
- */
-function AnimationEventHandler(target) {
-  this.target = target;
-  this.target.onanimationstart = evt => {
-   this.animationstart = evt.elapsedTime;
-  };
-  this.target.onanimationiteration = evt => {
-    this.animationiteration = evt.elapsedTime;
-  };
-  this.target.onanimationend = evt => {
-    this.animationend = evt.elapsedTime;
-  };
-  this.target.onanimationcancel = evt => {
-    this.animationcancel = evt.elapsedTime;
-  };
-}
-AnimationEventHandler.prototype.clear = () => {
-  this.animationstart     = undefined;
-  this.animationiteration = undefined;
-  this.animationend       = undefined;
-  this.animationcancel    = undefined;
-}
-
 const setupAnimation = (t, animationStyle) => {
   const div = addDiv(t, { style: 'animation: ' + animationStyle });
-  // Note that this AnimationEventHandler should be created before EventWatcher
-  // to capture all events in the handler prior to the EventWatcher since
-  // testharness.js proceeds when the EventWatcher received watching events.
-  const handler = new AnimationEventHandler(div);
   const watcher = new EventWatcher(t, div, [ 'animationstart',
                                              'animationiteration',
                                              'animationend',
                                              'animationcancel' ]);
   const animation = div.getAnimations()[0];
 
-  return { animation, watcher, div, handler };
+  return { animation, watcher, div };
 };
 
 promise_test(async t => {
   // Add 1ms delay to ensure that the delay is not included in the elapsedTime.
   const { animation, watcher } = setupAnimation(t, 'anim 100s 1ms');
 
   const evt = await watcher.wait_for('animationstart');
   assert_equals(evt.elapsedTime, 0.0);
 }, 'Idle -> Active');
 
 promise_test(async t => {
-  const { animation, watcher, div, handler } = setupAnimation(t, 'anim 100s');
+  const { animation, watcher } = setupAnimation(t, 'anim 100s');
 
   // Seek to After phase.
   animation.finish();
 
-  await watcher.wait_for([ 'animationstart', 'animationend' ]);
-  assert_equals(handler.animationstart, 0.0);
-  assert_equals(handler.animationend, 100);
+  const events = await watcher.wait_for(['animationstart', 'animationend'], {
+    record: 'all',
+  });
+  assert_equals(events[0].elapsedTime, 0.0);
+  assert_equals(events[1].elapsedTime, 100);
 }, 'Idle -> After');
 
 promise_test(async t => {
-  const { animation, watcher } =
-    setupAnimation(t, 'anim 100s 100s paused');
+  const { animation, watcher } = setupAnimation(t, 'anim 100s 100s paused');
 
   await animation.ready;
 
   // Seek to Active phase.
   animation.currentTime = 100 * MS_PER_SEC;
 
   const evt = await watcher.wait_for('animationstart');
   assert_equals(evt.elapsedTime, 0.0);
 }, 'Before -> Active');
 
 promise_test(async t => {
-  const { animation, watcher, div, handler } =
-    setupAnimation(t, 'anim 100s 100s paused');
+  const { animation, watcher } = setupAnimation(t, 'anim 100s 100s paused');
+  const allEvents = watcher.wait_for(['animationstart', 'animationend'], {
+    record: 'all',
+  });
 
   await animation.ready;
 
   // Seek to After phase.
   animation.finish();
 
-  await watcher.wait_for([ 'animationstart', 'animationend' ]);
-  assert_equals(handler.animationstart, 0.0);
-  assert_equals(handler.animationend, 100.0);
+  const events = await allEvents;
+  assert_equals(events[0].elapsedTime, 0.0);
+  assert_equals(events[1].elapsedTime, 100.0);
 }, 'Before -> After');
 
 promise_test(async t => {
   const { animation, watcher, div } = setupAnimation(t, 'anim 100s paused');
 
   await watcher.wait_for('animationstart');
 
   // Make idle
   div.style.display = 'none';
 
   const evt = await watcher.wait_for('animationcancel');
   assert_equals(evt.elapsedTime, 0.0);
 }, 'Active -> Idle, display: none');
 
 promise_test(async t => {
-  const { animation, watcher, div } = setupAnimation(t, 'anim 100s');
+  const { animation, watcher } = setupAnimation(t, 'anim 100s');
 
   await watcher.wait_for('animationstart');
 
   animation.currentTime = 100.0;
 
   // Make idle
   animation.timeline = null;
 
   const evt = await watcher.wait_for('animationcancel');
   assert_time_equals_literal(evt.elapsedTime, 0.1);
 }, 'Active -> Idle, setting Animation.timeline = null');
 
 promise_test(async t => {
   // We should NOT pause animation since calling cancel synchronously.
-  const { animation, watcher, div } = setupAnimation(t, 'anim 100s');
+  const { animation, watcher } = setupAnimation(t, 'anim 100s');
 
   await watcher.wait_for('animationstart');
 
   animation.currentTime = 50.0;
   animation.cancel();
 
   const evt = await watcher.wait_for('animationcancel');
   assert_time_equals_literal(evt.elapsedTime, 0.05);
 }, 'Active -> Idle, calling Animation.cancel()');
 
 promise_test(async t => {
-  const { animation, watcher } =
-    setupAnimation(t, 'anim 100s 100s paused');
+  const { animation, watcher } = setupAnimation(t, 'anim 100s 100s paused');
 
   // Seek to Active phase.
   animation.currentTime = 100 * MS_PER_SEC;
   await watcher.wait_for('animationstart');
 
   // Seek to Before phase.
   animation.currentTime = 0;
 
@@ -167,50 +137,48 @@ promise_test(async t => {
   // Seek to After phase.
   animation.finish();
 
   const evt = await watcher.wait_for('animationend');
   assert_equals(evt.elapsedTime, 100.0);
 }, 'Active -> After');
 
 promise_test(async t => {
-  const { animation, watcher, div, handler } =
-    setupAnimation(t, 'anim 100s 100s paused');
+  const { animation, watcher } = setupAnimation(t, 'anim 100s 100s paused');
 
   // Seek to After phase.
   animation.finish();
   await watcher.wait_for([ 'animationstart', 'animationend' ]);
 
   // Seek to Before phase.
   animation.currentTime = 0;
 
-  handler.clear();
-  await watcher.wait_for([ 'animationstart', 'animationend' ]);
-  assert_equals(handler.animationstart, 100.0);
-  assert_equals(handler.animationend, 0.0);
+  const events = await watcher.wait_for(['animationstart', 'animationend'], {
+    record: 'all',
+  });
+  assert_equals(events[0].elapsedTime, 100.0);
+  assert_equals(events[1].elapsedTime, 0.0);
 }, 'After -> Before');
 
 promise_test(async t => {
-  const { animation, watcher, div } =
-    setupAnimation(t, 'anim 100s 100s paused');
+  const { animation, watcher } = setupAnimation(t, 'anim 100s 100s paused');
 
   // Seek to After phase.
   animation.finish();
   await watcher.wait_for([ 'animationstart', 'animationend' ]);
 
   // Seek to Active phase.
   animation.currentTime = 100 * MS_PER_SEC;
 
   const evt = await watcher.wait_for('animationstart');
   assert_equals(evt.elapsedTime, 100.0);
 }, 'After -> Active');
 
 promise_test(async t => {
-  const { animation, watcher, div }
-    = setupAnimation(t, 'anim 100s 100s 3 paused');
+  const { animation, watcher } = setupAnimation(t, 'anim 100s 100s 3 paused');
 
   await animation.ready;
 
   // Seek to iteration 0 (no animationiteration event should be dispatched)
   animation.currentTime = 100 * MS_PER_SEC;
   await watcher.wait_for('animationstart');
 
   // Seek to iteration 2