--- a/testing/web-platform/tests/web-animations/timing-model/animation-effects/current-iteration.html
+++ b/testing/web-platform/tests/web-animations/timing-model/animation-effects/current-iteration.html
@@ -6,36 +6,50 @@
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<div id="log"></div>
<script>
'use strict';
function runTests(tests, description) {
- tests.forEach(function(currentTest) {
- var testParams = '';
- for (var attr in currentTest.input) {
- testParams += ' ' + attr + ':' + currentTest.input[attr];
- }
- test(function(t) {
- var div = createDiv(t);
- var anim = div.animate({ opacity: [ 0, 1 ] }, currentTest.input);
+ for (const currentTest of tests) {
+ const testParams = Object.entries(currentTest.input)
+ .map(([attr, value]) => `${attr}:${value}`)
+ .join(' ');
+
+ test(t => {
+ const div = createDiv(t);
+ const anim = div.animate({}, currentTest.input);
+
+ // Before phase
assert_equals(anim.effect.getComputedTiming().currentIteration,
currentTest.before);
- anim.currentTime = currentTest.input.delay || 0;
- assert_equals(anim.effect.getComputedTiming().currentIteration,
- currentTest.active);
- if (typeof currentTest.after !== 'undefined') {
+
+ // Active phase
+ if (anim.effect.getComputedTiming().activeDuration > 0) {
+ anim.currentTime = currentTest.input.delay || 0;
+ assert_equals(anim.effect.getComputedTiming().currentIteration,
+ currentTest.active);
+ } else if (currentTest.active !== undefined) {
+ assert_false('Test specifies an active phase iteration to check but the'
+ + ' animation has a zero duration');
+ }
+
+ // After phase
+ if (anim.effect.getComputedTiming().activeDuration !== Infinity) {
anim.finish();
assert_equals(anim.effect.getComputedTiming().currentIteration,
currentTest.after);
+ } else if (currentTest.after !== undefined) {
+ assert_false('Test specifies an after phase iteration to check but the'
+ + ' animation has an infinite duration');
}
- }, description + ':' + testParams);
- });
+ }, `${description}: ${testParams}`);
+ }
}
async_test(function(t) {
var div = createDiv(t);
var anim = div.animate({ opacity: [ 0, 1 ] }, { delay: 1 });
assert_equals(anim.effect.getComputedTiming().currentIteration, null);
anim.finished.then(t.step_func(function() {
assert_equals(anim.effect.getComputedTiming().currentIteration, null);
@@ -53,105 +67,96 @@ async_test(function(t) {
runTests([
{
input: { iterations: 0,
iterationStart: 0,
duration: 0,
delay: 1,
fill: 'both' },
before: 0,
- active: 0,
after: 0
},
{
input: { iterations: 0,
iterationStart: 0,
duration: 100,
delay: 1,
fill: 'both' },
before: 0,
- active: 0,
after: 0
},
{
input: { iterations: 0,
iterationStart: 0,
duration: Infinity,
delay: 1,
fill: 'both' },
before: 0,
- active: 0,
after: 0
},
{
input: { iterations: 0,
iterationStart: 2.5,
duration: 0,
delay: 1,
fill: 'both' },
before: 2,
- active: 2,
after: 2
},
{
input: { iterations: 0,
iterationStart: 2.5,
duration: 100,
delay: 1,
fill: 'both' },
before: 2,
- active: 2,
after: 2
},
{
input: { iterations: 0,
iterationStart: 2.5,
duration: Infinity,
delay: 1,
fill: 'both' },
before: 2,
- active: 2,
after: 2
},
{
input: { iterations: 0,
iterationStart: 3,
duration: 0,
delay: 1,
fill: 'both' },
before: 3,
- active: 3,
after: 3
},
{
input: { iterations: 0,
iterationStart: 3,
duration: 100,
delay: 1,
fill: 'both' },
before: 3,
- active: 3,
after: 3
},
{
input: { iterations: 0,
iterationStart: 3,
duration: Infinity,
delay: 1,
fill: 'both' },
before: 3,
- active: 3,
after: 3
}
], 'Test zero iterations');
// --------------------------------------------------------------------
//
// Tests where the iteration count is an integer
@@ -161,17 +166,16 @@ runTests([
runTests([
{
input: { iterations: 3,
iterationStart: 0,
duration: 0,
delay: 1,
fill: 'both' },
before: 0,
- active: 2,
after: 2
},
{
input: { iterations: 3,
iterationStart: 0,
duration: 100,
delay: 1,
@@ -193,17 +197,16 @@ runTests([
{
input: { iterations: 3,
iterationStart: 2.5,
duration: 0,
delay: 1,
fill: 'both' },
before: 2,
- active: 5,
after: 5
},
{
input: { iterations: 3,
iterationStart: 2.5,
duration: 100,
delay: 1,
@@ -225,17 +228,16 @@ runTests([
{
input: { iterations: 3,
iterationStart: 3,
duration: 0,
delay: 1,
fill: 'both' },
before: 3,
- active: 5,
after: 5
},
{
input: { iterations: 3,
iterationStart: 3,
duration: 100,
delay: 1,
@@ -266,17 +268,16 @@ runTests([
runTests([
{
input: { iterations: 3.5,
iterationStart: 0,
duration: 0,
delay: 1,
fill: 'both' },
before: 0,
- active: 3,
after: 3
},
{
input: { iterations: 3.5,
iterationStart: 0,
duration: 100,
delay: 1,
@@ -298,17 +299,16 @@ runTests([
{
input: { iterations: 3.5,
iterationStart: 2.5,
duration: 0,
delay: 1,
fill: 'both' },
before: 2,
- active: 5,
after: 5
},
{
input: { iterations: 3.5,
iterationStart: 2.5,
duration: 100,
delay: 1,
@@ -330,17 +330,16 @@ runTests([
{
input: { iterations: 3.5,
iterationStart: 3,
duration: 0,
delay: 1,
fill: 'both' },
before: 3,
- active: 6,
after: 6
},
{
input: { iterations: 3.5,
iterationStart: 3,
duration: 100,
delay: 1,
@@ -371,17 +370,16 @@ runTests([
runTests([
{
input: { iterations: Infinity,
iterationStart: 0,
duration: 0,
delay: 1,
fill: 'both' },
before: 0,
- active: Infinity,
after: Infinity
},
{
input: { iterations: Infinity,
iterationStart: 0,
duration: 100,
delay: 1,
@@ -402,17 +400,16 @@ runTests([
{
input: { iterations: Infinity,
iterationStart: 2.5,
duration: 0,
delay: 1,
fill: 'both' },
before: 2,
- active: Infinity,
after: Infinity
},
{
input: { iterations: Infinity,
iterationStart: 2.5,
duration: 100,
delay: 1,
@@ -433,17 +430,16 @@ runTests([
{
input: { iterations: Infinity,
iterationStart: 3,
duration: 0,
delay: 1,
fill: 'both' },
before: 3,
- active: Infinity,
after: Infinity
},
{
input: { iterations: Infinity,
iterationStart: 3,
duration: 100,
delay: 1,
--- a/testing/web-platform/tests/web-animations/timing-model/animation-effects/simple-iteration-progress.html
+++ b/testing/web-platform/tests/web-animations/timing-model/animation-effects/simple-iteration-progress.html
@@ -7,36 +7,50 @@
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<div id="log"></div>
<script>
'use strict';
function runTests(tests, description) {
- tests.forEach(function(currentTest) {
- var testParams = '';
- for (var attr in currentTest.input) {
- testParams += ' ' + attr + ':' + currentTest.input[attr];
- }
- test(function(t) {
- var div = createDiv(t);
- var anim = div.animate({ opacity: [ 0, 1 ] }, currentTest.input);
+ for (const currentTest of tests) {
+ const testParams = Object.entries(currentTest.input)
+ .map(([attr, value]) => `${attr}:${value}`)
+ .join(' ');
+
+ test(t => {
+ const div = createDiv(t);
+ const anim = div.animate({}, currentTest.input);
+
+ // Before phase
assert_equals(anim.effect.getComputedTiming().progress,
currentTest.before);
- anim.currentTime = currentTest.input.delay || 0;
- assert_equals(anim.effect.getComputedTiming().progress,
- currentTest.active);
- if (typeof currentTest.after !== 'undefined') {
+
+ // Active phase
+ if (anim.effect.getComputedTiming().activeDuration > 0) {
+ anim.currentTime = currentTest.input.delay || 0;
+ assert_equals(anim.effect.getComputedTiming().progress,
+ currentTest.active);
+ } else if (currentTest.active !== undefined) {
+ assert_false('Test specifies an active progress to check but the'
+ + ' animation has a zero duration');
+ }
+
+ // After phase
+ if (anim.effect.getComputedTiming().activeDuration !== Infinity) {
anim.finish();
assert_equals(anim.effect.getComputedTiming().progress,
currentTest.after);
+ } else if (currentTest.after !== undefined) {
+ assert_false('Test specifies an after phase progress to check but the'
+ + ' animation has an infinite duration');
}
- }, description + ':' + testParams);
- });
+ }, `${description}: ${testParams}`);
+ }
}
// --------------------------------------------------------------------
//
// Zero iteration duration tests
//
// --------------------------------------------------------------------
@@ -44,105 +58,96 @@ function runTests(tests, description) {
runTests([
{
input: { iterations: 0,
iterationStart: 0,
duration: 0,
delay: 1,
fill: 'both' },
before: 0,
- active: 0,
after: 0
},
{
input: { iterations: 0,
iterationStart: 0,
duration: 100,
delay: 1,
fill: 'both' },
before: 0,
- active: 0,
after: 0
},
{
input: { iterations: 0,
iterationStart: 0,
duration: Infinity,
delay: 1,
fill: 'both' },
before: 0,
- active: 0,
after: 0
},
{
input: { iterations: 0,
iterationStart: 2.5,
duration: 0,
delay: 1,
fill: 'both' },
before: 0.5,
- active: 0.5,
after: 0.5
},
{
input: { iterations: 0,
iterationStart: 2.5,
duration: 100,
delay: 1,
fill: 'both' },
before: 0.5,
- active: 0.5,
after: 0.5
},
{
input: { iterations: 0,
iterationStart: 2.5,
duration: Infinity,
delay: 1,
fill: 'both' },
before: 0.5,
- active: 0.5,
after: 0.5
},
{
input: { iterations: 0,
iterationStart: 3,
duration: 0,
delay: 1,
fill: 'both' },
before: 0,
- active: 0,
after: 0
},
{
input: { iterations: 0,
iterationStart: 3,
duration: 100,
delay: 1,
fill: 'both' },
before: 0,
- active: 0,
after: 0
},
{
input: { iterations: 0,
iterationStart: 3,
duration: Infinity,
delay: 1,
fill: 'both' },
before: 0,
- active: 0,
after: 0
}
], 'Test zero iterations');
// --------------------------------------------------------------------
//
// Tests where the iteration count is an integer
@@ -152,17 +157,16 @@ runTests([
runTests([
{
input: { iterations: 3,
iterationStart: 0,
duration: 0,
delay: 1,
fill: 'both' },
before: 0,
- active: 1,
after: 1
},
{
input: { iterations: 3,
iterationStart: 0,
duration: 100,
delay: 1,
@@ -184,17 +188,16 @@ runTests([
{
input: { iterations: 3,
iterationStart: 2.5,
duration: 0,
delay: 1,
fill: 'both' },
before: 0.5,
- active: 0.5,
after: 0.5
},
{
input: { iterations: 3,
iterationStart: 2.5,
duration: 100,
delay: 1,
@@ -216,17 +219,16 @@ runTests([
{
input: { iterations: 3,
iterationStart: 3,
duration: 0,
delay: 1,
fill: 'both' },
before: 0,
- active: 1,
after: 1
},
{
input: { iterations: 3,
iterationStart: 3,
duration: 100,
delay: 1,
@@ -257,17 +259,16 @@ runTests([
runTests([
{
input: { iterations: 3.5,
iterationStart: 0,
duration: 0,
delay: 1,
fill: 'both' },
before: 0,
- active: 0.5,
after: 0.5
},
{
input: { iterations: 3.5,
iterationStart: 0,
duration: 100,
delay: 1,
@@ -289,17 +290,16 @@ runTests([
{
input: { iterations: 3.5,
iterationStart: 2.5,
duration: 0,
delay: 1,
fill: 'both' },
before: 0.5,
- active: 1,
after: 1
},
{
input: { iterations: 3.5,
iterationStart: 2.5,
duration: 100,
delay: 1,
@@ -321,17 +321,16 @@ runTests([
{
input: { iterations: 3.5,
iterationStart: 3,
duration: 0,
delay: 1,
fill: 'both' },
before: 0,
- active: 0.5,
after: 0.5
},
{
input: { iterations: 3.5,
iterationStart: 3,
duration: 100,
delay: 1,
@@ -362,17 +361,16 @@ runTests([
runTests([
{
input: { iterations: Infinity,
iterationStart: 0,
duration: 0,
delay: 1,
fill: 'both' },
before: 0,
- active: 1,
after: 1
},
{
input: { iterations: Infinity,
iterationStart: 0,
duration: 100,
delay: 1,
@@ -393,17 +391,16 @@ runTests([
{
input: { iterations: Infinity,
iterationStart: 2.5,
duration: 0,
delay: 1,
fill: 'both' },
before: 0.5,
- active: 0.5,
after: 0.5
},
{
input: { iterations: Infinity,
iterationStart: 2.5,
duration: 100,
delay: 1,
@@ -424,17 +421,16 @@ runTests([
{
input: { iterations: Infinity,
iterationStart: 3,
duration: 0,
delay: 1,
fill: 'both' },
before: 0,
- active: 1,
after: 1
},
{
input: { iterations: Infinity,
iterationStart: 3,
duration: 100,
delay: 1,