Files
sousa-gecko/testing/web-platform/tests/css/css-values/random-in-animations.tentative.html
T
moonira 3f9fa52756 Bug 2021404 [wpt PR 58293] - Support random() property sharing in custom property animations, a=testonly
Automatic update from web-platform-tests
Support random() property sharing in custom property animations

Bug: 413385732
Change-Id: I49f35b864788a5c2435900ee9768b2e056f772f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7638231
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Commit-Queue: Munira Tursunova <moonira@google.com>
Cr-Commit-Position: refs/heads/main@{#1594683}

--

wpt-commits: 8e52b693ac78f9050007c3914fb7db9fe435d732
wpt-pr: 58293
2026-03-12 15:56:52 +00:00

94 lines
2.3 KiB
HTML

<!DOCTYPE html>
<title>CSS Values and Units Test: random() in animations</title>
<link rel="help" href="https://drafts.csswg.org/css-values-5/#random">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/interpolation-testcommon.js"></script>
<style>
@property --number {
syntax: "<number>";
inherits: true;
initial-value: 0;
}
</style>
<body>
<div id="target"></div>
</body>
<script>
test_interpolation({
property: '--number',
from: '100',
to: 'random(300, 100)',
}, [
{at: -0.5, expect: '0'},
{at: 0, expect: '100'},
{at: 0.5, expect: '200'},
{at: 1, expect: '300'},
{at: 1.5, expect: '400'},
]);
test_interpolation({
property: 'font-weight',
from: '100',
to: 'random(300, 100)',
}, [
{at: -0.5, expect: '1'},
{at: 0, expect: '100'},
{at: 0.5, expect: '200'},
{at: 1, expect: '300'},
{at: 1.5, expect: '400'},
]);
test(t => {
var target = document.getElementById('target');
target.animate(
{ '--number': ['random(0, 100, 1)', '300'] },
{
duration: 1000
}
);
document.getAnimations().forEach((animation) => {
animation.pause();
animation.currentTime = 0;
});
let from = parseInt(getComputedStyle(target).getPropertyValue('--number'));
let expected = from + (300 - from) / 2;
document.getAnimations().forEach((animation) => {
animation.pause();
animation.currentTime = 500;
});
assert_equals(parseFloat(getComputedStyle(target).getPropertyValue('--number')), expected);
}, "Test custom property animation with random() endpoints");
test(t => {
var target = document.getElementById('target');
target.animate(
{ fontWeight: ['random(100, 200, 1)', '300'] },
{
duration: 1000
}
);
document.getAnimations().forEach((animation) => {
animation.pause();
animation.currentTime = 0;
});
let from = parseInt(getComputedStyle(target).getPropertyValue('font-weight'));
let expected = from + (300 - from) / 2;
document.getAnimations().forEach((animation) => {
animation.pause();
animation.currentTime = 500;
});
assert_equals(parseFloat(getComputedStyle(target).getPropertyValue('font-weight')), expected);
}, "Test font-weight animation with random() endpoints");
</script>