--- 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="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