Skip to content

Commit 6ffdf2e

Browse files
committed
[web-animations] Fix timeout/0 tests in unsupporting browsers
Part of #11269.
1 parent 89dc776 commit 6ffdf2e

File tree

4 files changed

+103
-96
lines changed

4 files changed

+103
-96
lines changed

web-animations/animation-model/animation-types/accumulation-per-property.html

+34-32
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,43 @@
1717
<script>
1818
'use strict';
1919

20-
for (const property in gCSSProperties) {
21-
if (!isSupported(property)) {
22-
continue;
23-
}
24-
25-
const setupFunction = gCSSProperties[property].setup;
26-
for (const animationType of gCSSProperties[property].types) {
27-
let typeObject;
28-
let animationTypeString;
29-
if (typeof animationType === 'string') {
30-
typeObject = types[animationType];
31-
animationTypeString = animationType;
32-
} else if (typeof animationType === 'object' &&
33-
animationType.type && typeof animationType.type === 'string') {
34-
typeObject = types[animationType.type];
35-
animationTypeString = animationType.type;
20+
test(function() {
21+
for (const property in gCSSProperties) {
22+
if (!isSupported(property)) {
23+
continue;
3624
}
3725

38-
// First, test that the animation type object has 'testAccumulation'.
39-
// We use test() function here so that we can continue the remainder tests
40-
// even if this test fails.
41-
test(t => {
42-
assert_own_property(typeObject, 'testAccumulation', animationTypeString +
43-
' should have testAccumulation property');
44-
assert_equals(typeof typeObject.testAccumulation, 'function',
45-
'testAccumulation method should be a function');
46-
}, `${property} (type: ${animationTypeString}) has testAccumulation`
47-
+ ' function');
26+
const setupFunction = gCSSProperties[property].setup;
27+
for (const animationType of gCSSProperties[property].types) {
28+
let typeObject;
29+
let animationTypeString;
30+
if (typeof animationType === 'string') {
31+
typeObject = types[animationType];
32+
animationTypeString = animationType;
33+
} else if (typeof animationType === 'object' &&
34+
animationType.type && typeof animationType.type === 'string') {
35+
typeObject = types[animationType.type];
36+
animationTypeString = animationType.type;
37+
}
4838

49-
if (typeObject.testAccumulation &&
50-
typeof typeObject.testAccumulation === 'function') {
51-
typeObject.testAccumulation(property,
52-
setupFunction,
53-
animationType.options);
39+
// First, test that the animation type object has 'testAccumulation'.
40+
// We use test() function here so that we can continue the remainder tests
41+
// even if this test fails.
42+
test(t => {
43+
assert_own_property(typeObject, 'testAccumulation', animationTypeString +
44+
' should have testAccumulation property');
45+
assert_equals(typeof typeObject.testAccumulation, 'function',
46+
'testAccumulation method should be a function');
47+
}, `${property} (type: ${animationTypeString}) has testAccumulation`
48+
+ ' function');
49+
50+
if (typeObject.testAccumulation &&
51+
typeof typeObject.testAccumulation === 'function') {
52+
typeObject.testAccumulation(property,
53+
setupFunction,
54+
animationType.options);
55+
}
5456
}
5557
}
56-
}
58+
}, 'Setup');
5759
</script>

web-animations/animation-model/animation-types/addition-per-property.html

+34-32
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,43 @@
1717
<script>
1818
'use strict';
1919

20-
for (const property in gCSSProperties) {
21-
if (!isSupported(property)) {
22-
continue;
23-
}
24-
25-
const setupFunction = gCSSProperties[property].setup;
26-
for (const animationType of gCSSProperties[property].types) {
27-
let typeObject;
28-
let animationTypeString;
29-
if (typeof animationType === 'string') {
30-
typeObject = types[animationType];
31-
animationTypeString = animationType;
32-
} else if (typeof animationType === 'object' &&
33-
animationType.type && typeof animationType.type === 'string') {
34-
typeObject = types[animationType.type];
35-
animationTypeString = animationType.type;
20+
test(function() {
21+
for (const property in gCSSProperties) {
22+
if (!isSupported(property)) {
23+
continue;
3624
}
3725

38-
// First, test that the animation type object has 'testAddition'.
39-
// We use test() function here so that we can continue the remainder tests
40-
// even if this test fails.
41-
test(t => {
42-
assert_own_property(typeObject, 'testAddition', animationTypeString +
43-
' should have testAddition property');
44-
assert_equals(typeof typeObject.testAddition, 'function',
45-
'testAddition method should be a function');
46-
}, `${property} (type: ${animationTypeString}) has testAddition`
47-
+ ' function');
26+
const setupFunction = gCSSProperties[property].setup;
27+
for (const animationType of gCSSProperties[property].types) {
28+
let typeObject;
29+
let animationTypeString;
30+
if (typeof animationType === 'string') {
31+
typeObject = types[animationType];
32+
animationTypeString = animationType;
33+
} else if (typeof animationType === 'object' &&
34+
animationType.type && typeof animationType.type === 'string') {
35+
typeObject = types[animationType.type];
36+
animationTypeString = animationType.type;
37+
}
4838

49-
if (typeObject.testAddition &&
50-
typeof typeObject.testAddition === 'function') {
51-
typeObject.testAddition(property,
52-
setupFunction,
53-
animationType.options);
39+
// First, test that the animation type object has 'testAddition'.
40+
// We use test() function here so that we can continue the remainder tests
41+
// even if this test fails.
42+
test(t => {
43+
assert_own_property(typeObject, 'testAddition', animationTypeString +
44+
' should have testAddition property');
45+
assert_equals(typeof typeObject.testAddition, 'function',
46+
'testAddition method should be a function');
47+
}, `${property} (type: ${animationTypeString}) has testAddition`
48+
+ ' function');
49+
50+
if (typeObject.testAddition &&
51+
typeof typeObject.testAddition === 'function') {
52+
typeObject.testAddition(property,
53+
setupFunction,
54+
animationType.options);
55+
}
5456
}
5557
}
56-
}
58+
}, "Setup");
5759
</script>

web-animations/animation-model/animation-types/interpolation-per-property.html

+34-32
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,43 @@
1717
<script>
1818
'use strict';
1919

20-
for (const property in gCSSProperties) {
21-
if (!isSupported(property)) {
22-
continue;
23-
}
24-
25-
const setupFunction = gCSSProperties[property].setup;
26-
for (const animationType of gCSSProperties[property].types) {
27-
let typeObject;
28-
let animationTypeString;
29-
if (typeof animationType === 'string') {
30-
typeObject = types[animationType];
31-
animationTypeString = animationType;
32-
} else if (typeof animationType === 'object' &&
33-
animationType.type && typeof animationType.type === 'string') {
34-
typeObject = types[animationType.type];
35-
animationTypeString = animationType.type;
20+
test(function() {
21+
for (const property in gCSSProperties) {
22+
if (!isSupported(property)) {
23+
continue;
3624
}
3725

38-
// First, test that the animation type object has 'testInterpolation'.
39-
// We use test() function() here so that we can continue the remainder tests
40-
// even if this test fails.
41-
test(t => {
42-
assert_own_property(typeObject, 'testInterpolation', animationTypeString +
43-
' should have testInterpolation property');
44-
assert_equals(typeof typeObject.testInterpolation, 'function',
45-
'testInterpolation method should be a function');
46-
}, `${property} (type: ${animationTypeString}) has testInterpolation`
47-
+ ' function');
26+
const setupFunction = gCSSProperties[property].setup;
27+
for (const animationType of gCSSProperties[property].types) {
28+
let typeObject;
29+
let animationTypeString;
30+
if (typeof animationType === 'string') {
31+
typeObject = types[animationType];
32+
animationTypeString = animationType;
33+
} else if (typeof animationType === 'object' &&
34+
animationType.type && typeof animationType.type === 'string') {
35+
typeObject = types[animationType.type];
36+
animationTypeString = animationType.type;
37+
}
4838

49-
if (typeObject.testInterpolation &&
50-
typeof typeObject.testInterpolation === 'function') {
51-
typeObject.testInterpolation(property,
52-
setupFunction,
53-
animationType.options);
39+
// First, test that the animation type object has 'testInterpolation'.
40+
// We use test() function() here so that we can continue the remainder tests
41+
// even if this test fails.
42+
test(t => {
43+
assert_own_property(typeObject, 'testInterpolation', animationTypeString +
44+
' should have testInterpolation property');
45+
assert_equals(typeof typeObject.testInterpolation, 'function',
46+
'testInterpolation method should be a function');
47+
}, `${property} (type: ${animationTypeString}) has testInterpolation`
48+
+ ' function');
49+
50+
if (typeObject.testInterpolation &&
51+
typeof typeObject.testInterpolation === 'function') {
52+
typeObject.testInterpolation(property,
53+
setupFunction,
54+
animationType.options);
55+
}
5456
}
5557
}
56-
}
58+
}, 'Setup');
5759
</script>

web-animations/animation-model/animation-types/property-list.js

+1
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,7 @@ function createTestElement(t, setup) {
15561556

15571557
function isSupported(property) {
15581558
const testKeyframe = new TestKeyframe(propertyToIDL(property));
1559+
assert_not_equals(window.KeyframeEffect, undefined, 'window.KeyframeEffect');
15591560
try {
15601561
// Since TestKeyframe returns 'undefined' for |property|,
15611562
// the KeyframeEffect constructor will throw

0 commit comments

Comments
 (0)