Files
ladybird/Tests/LibWeb/Text/input/wpt-import/web-animations/resources/timing-utils.js
Callum Law a1c9b86ad3 LibWeb: Account for non-shorthand sub-properties when serializing border
When parsing values in `process_a_keyframes_argument` we don't expand
properties using `StyleComputer::for_each_property_expanding_shorthands`
unlike most other places - this means that if we parse a `border` we end
up with the `border`'s sub-properties (`border-width`, `border-style`,
`border-color`) still in their unexpanded forms (`CSSKeywordValue`,
`LengthStyleValue`, `StyleValueList`, etc) rather than
`ShorthandStyleValue`s which causes a crash when serializing the
`border` value in `KeyframeEffect::get_keyframes`.

The proper fix here is to parse `border`'s sub-properties directly to
`ShorthandStyleValue`s instead of relying on
`StyleComputer::for_each_property_expanding_shorthand` to do this
conversion for us but this may be a while off.

This commit also imports the previously crashing tests.
2025-07-16 06:49:38 +01:00

53 lines
1.1 KiB
JavaScript

'use strict';
// =======================================
//
// Utility functions for testing timing
//
// =======================================
// ------------------------------
// Helper functions
// ------------------------------
// Utility function to check that a subset of timing properties have their
// default values.
function assert_default_timing_except(effect, propertiesToSkip) {
const defaults = {
delay: 0,
endDelay: 0,
fill: 'auto',
iterationStart: 0,
iterations: 1,
duration: 'auto',
direction: 'normal',
easing: 'linear',
};
for (const prop of Object.keys(defaults)) {
if (propertiesToSkip.includes(prop)) {
continue;
}
assert_equals(
effect.getTiming()[prop],
defaults[prop],
`${prop} parameter has default value:`
);
}
}
function waitForAnimationTime(animation, time) {
return new Promise((resolve) => {
function raf() {
if (animation.currentTime < time) {
requestAnimationFrame(raf);
} else {
resolve();
}
}
requestAnimationFrame(raf);
});
}