blob: 6a7d10166d2c3ec4e4f9992e780d58c9ca1960b6 [file] [log] [blame]
<!doctype html>
<meta charset=utf-8>
<title>Animation.frameRate</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../imported/w3c/web-platform-tests/web-animations/testcommon.js"></script>
<body>
<script>
'use strict';
const presets = ["low", "high", "highest", "auto"];
const invalidValues = ["default", "120", null, [], {}];
test(t => {
const animation = new Animation;
assert_equals(animation.frameRate, "auto", "The default value for frameRate is 'auto'");
// AnimationFrameRatePreset values.
for (let value of presets) {
animation.frameRate = value;
assert_equals(animation.frameRate, value, `The value "${value}" can be set`);
}
// Numeric value.
animation.frameRate = 60;
assert_equals(animation.frameRate, 60, `A numeric value can be set`);
}, "Valid animation.frameRate values");
test(t => {
const animation = new Animation;
for (let value of invalidValues.concat(undefined)) {
assert_throws_js(TypeError, () => animation.frameRate = value, `Setting the value ${value} throws`);
assert_equals(animation.frameRate, "auto", `Setting the invalid value "${value}" does not change the value`);
}
}, "Invalid animation.frameRate values");
test(t => {
const target = document.createElement("div");
const animation = frameRate => target.animate(null, { frameRate });
// Numeric value.
assert_equals(animation(30).frameRate, 30, "frameRate can be set to a numeric value");
// Presets.
for (let value of presets)
assert_equals(animation(value).frameRate, value, "frameRate can be set to a preset value");
// Invalid values.
for (let value of invalidValues)
assert_throws_js(TypeError, () => animation(value), `providing the invalid value "${value}" throws`);
}, "Calling element.animate() allows setting animation.frameRate");
test(t => {
const animation = frameRate => document.timeline.animate(() => { }, { frameRate });
// Numeric value.
assert_equals(animation(30).frameRate, 30, "frameRate can be set to a numeric value");
// Presets.
for (let value of presets)
assert_equals(animation(value).frameRate, value, "frameRate can be set to a preset value");
// Invalid values.
for (let value of invalidValues)
assert_throws_js(TypeError, () => animation(value), `providing the invalid value "${value}" throws`);
}, "Calling document.timeline.animate() allows setting animation.frameRate");
</script>
</body>