Skip to content

Commit

Permalink
[web-animations] Fix timeout/0 tests in unsupporting browsers
Browse files Browse the repository at this point in the history
Part of #11269.
  • Loading branch information
zcorpan committed Jun 1, 2018
1 parent dcdd59c commit ee6c9d3
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,43 @@
<script>
'use strict';

for (const property in gCSSProperties) {
if (!isSupported(property)) {
continue;
}

const setupFunction = gCSSProperties[property].setup;
for (const animationType of gCSSProperties[property].types) {
let typeObject;
let animationTypeString;
if (typeof animationType === 'string') {
typeObject = types[animationType];
animationTypeString = animationType;
} else if (typeof animationType === 'object' &&
animationType.type && typeof animationType.type === 'string') {
typeObject = types[animationType.type];
animationTypeString = animationType.type;
test(function() {
for (const property in gCSSProperties) {
if (!isSupported(property)) {
continue;
}

// First, test that the animation type object has 'testAccumulation'.
// We use test() function here so that we can continue the remainder tests
// even if this test fails.
test(t => {
assert_own_property(typeObject, 'testAccumulation', animationTypeString +
' should have testAccumulation property');
assert_equals(typeof typeObject.testAccumulation, 'function',
'testAccumulation method should be a function');
}, `${property} (type: ${animationTypeString}) has testAccumulation`
+ ' function');
const setupFunction = gCSSProperties[property].setup;
for (const animationType of gCSSProperties[property].types) {
let typeObject;
let animationTypeString;
if (typeof animationType === 'string') {
typeObject = types[animationType];
animationTypeString = animationType;
} else if (typeof animationType === 'object' &&
animationType.type && typeof animationType.type === 'string') {
typeObject = types[animationType.type];
animationTypeString = animationType.type;
}

if (typeObject.testAccumulation &&
typeof typeObject.testAccumulation === 'function') {
typeObject.testAccumulation(property,
setupFunction,
animationType.options);
// First, test that the animation type object has 'testAccumulation'.
// We use test() function here so that we can continue the remainder tests
// even if this test fails.
test(t => {
assert_own_property(typeObject, 'testAccumulation', animationTypeString +
' should have testAccumulation property');
assert_equals(typeof typeObject.testAccumulation, 'function',
'testAccumulation method should be a function');
}, `${property} (type: ${animationTypeString}) has testAccumulation`
+ ' function');

if (typeObject.testAccumulation &&
typeof typeObject.testAccumulation === 'function') {
typeObject.testAccumulation(property,
setupFunction,
animationType.options);
}
}
}
}
}, 'Setup');
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,43 @@
<script>
'use strict';

for (const property in gCSSProperties) {
if (!isSupported(property)) {
continue;
}

const setupFunction = gCSSProperties[property].setup;
for (const animationType of gCSSProperties[property].types) {
let typeObject;
let animationTypeString;
if (typeof animationType === 'string') {
typeObject = types[animationType];
animationTypeString = animationType;
} else if (typeof animationType === 'object' &&
animationType.type && typeof animationType.type === 'string') {
typeObject = types[animationType.type];
animationTypeString = animationType.type;
test(function() {
for (const property in gCSSProperties) {
if (!isSupported(property)) {
continue;
}

// First, test that the animation type object has 'testAddition'.
// We use test() function here so that we can continue the remainder tests
// even if this test fails.
test(t => {
assert_own_property(typeObject, 'testAddition', animationTypeString +
' should have testAddition property');
assert_equals(typeof typeObject.testAddition, 'function',
'testAddition method should be a function');
}, `${property} (type: ${animationTypeString}) has testAddition`
+ ' function');
const setupFunction = gCSSProperties[property].setup;
for (const animationType of gCSSProperties[property].types) {
let typeObject;
let animationTypeString;
if (typeof animationType === 'string') {
typeObject = types[animationType];
animationTypeString = animationType;
} else if (typeof animationType === 'object' &&
animationType.type && typeof animationType.type === 'string') {
typeObject = types[animationType.type];
animationTypeString = animationType.type;
}

if (typeObject.testAddition &&
typeof typeObject.testAddition === 'function') {
typeObject.testAddition(property,
setupFunction,
animationType.options);
// First, test that the animation type object has 'testAddition'.
// We use test() function here so that we can continue the remainder tests
// even if this test fails.
test(t => {
assert_own_property(typeObject, 'testAddition', animationTypeString +
' should have testAddition property');
assert_equals(typeof typeObject.testAddition, 'function',
'testAddition method should be a function');
}, `${property} (type: ${animationTypeString}) has testAddition`
+ ' function');

if (typeObject.testAddition &&
typeof typeObject.testAddition === 'function') {
typeObject.testAddition(property,
setupFunction,
animationType.options);
}
}
}
}
}, "Setup");
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,43 @@
<script>
'use strict';

for (const property in gCSSProperties) {
if (!isSupported(property)) {
continue;
}

const setupFunction = gCSSProperties[property].setup;
for (const animationType of gCSSProperties[property].types) {
let typeObject;
let animationTypeString;
if (typeof animationType === 'string') {
typeObject = types[animationType];
animationTypeString = animationType;
} else if (typeof animationType === 'object' &&
animationType.type && typeof animationType.type === 'string') {
typeObject = types[animationType.type];
animationTypeString = animationType.type;
test(function() {
for (const property in gCSSProperties) {
if (!isSupported(property)) {
continue;
}

// First, test that the animation type object has 'testInterpolation'.
// We use test() function() here so that we can continue the remainder tests
// even if this test fails.
test(t => {
assert_own_property(typeObject, 'testInterpolation', animationTypeString +
' should have testInterpolation property');
assert_equals(typeof typeObject.testInterpolation, 'function',
'testInterpolation method should be a function');
}, `${property} (type: ${animationTypeString}) has testInterpolation`
+ ' function');
const setupFunction = gCSSProperties[property].setup;
for (const animationType of gCSSProperties[property].types) {
let typeObject;
let animationTypeString;
if (typeof animationType === 'string') {
typeObject = types[animationType];
animationTypeString = animationType;
} else if (typeof animationType === 'object' &&
animationType.type && typeof animationType.type === 'string') {
typeObject = types[animationType.type];
animationTypeString = animationType.type;
}

if (typeObject.testInterpolation &&
typeof typeObject.testInterpolation === 'function') {
typeObject.testInterpolation(property,
setupFunction,
animationType.options);
// First, test that the animation type object has 'testInterpolation'.
// We use test() function() here so that we can continue the remainder tests
// even if this test fails.
test(t => {
assert_own_property(typeObject, 'testInterpolation', animationTypeString +
' should have testInterpolation property');
assert_equals(typeof typeObject.testInterpolation, 'function',
'testInterpolation method should be a function');
}, `${property} (type: ${animationTypeString}) has testInterpolation`
+ ' function');

if (typeObject.testInterpolation &&
typeof typeObject.testInterpolation === 'function') {
typeObject.testInterpolation(property,
setupFunction,
animationType.options);
}
}
}
}
}, 'Setup');
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,7 @@ function createTestElement(t, setup) {

function isSupported(property) {
const testKeyframe = new TestKeyframe(propertyToIDL(property));
assert_not_equals(window.KeyframeEffect, undefined, 'window.KeyframeEffect');
try {
// Since TestKeyframe returns 'undefined' for |property|,
// the KeyframeEffect constructor will throw
Expand Down

0 comments on commit ee6c9d3

Please sign in to comment.