mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
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.
52 lines
1.7 KiB
JavaScript
52 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
// =======================================
|
|
//
|
|
// Utility functions for testing keyframes
|
|
//
|
|
// =======================================
|
|
|
|
|
|
// ------------------------------
|
|
// Helper functions
|
|
// ------------------------------
|
|
|
|
/**
|
|
* Test equality between two lists of computed keyframes
|
|
* @param {Array.<ComputedKeyframe>} a - actual computed keyframes
|
|
* @param {Array.<ComputedKeyframe>} b - expected computed keyframes
|
|
*/
|
|
function assert_frame_lists_equal(a, b, message) {
|
|
assert_equals(a.length, b.length, `number of frames: ${(message || '')}`);
|
|
for (let i = 0; i < Math.min(a.length, b.length); i++) {
|
|
assert_frames_equal(a[i], b[i],
|
|
`ComputedKeyframe #${i}: ${(message || '')}`);
|
|
}
|
|
}
|
|
|
|
/** Helper for assert_frame_lists_equal */
|
|
function assert_frames_equal(a, b, name) {
|
|
assert_equals(Object.keys(a).sort().toString(),
|
|
Object.keys(b).sort().toString(),
|
|
`properties on ${name} should match`);
|
|
// Iterates sorted keys to ensure stable failures.
|
|
for (const p of Object.keys(a).sort()) {
|
|
if (typeof b[p] == 'number')
|
|
assert_approx_equals(a[p], b[p], 1e-6, `value for '${p}' on ${name}`);
|
|
else if (typeof b[p] == 'object') {
|
|
for (const key in b[p]) {
|
|
if (typeof b[p][key] == 'number') {
|
|
assert_approx_equals(a[p][key], b[p][key], 1e-6,
|
|
`value for '${p}.${key}' on ${name}`);
|
|
} else {
|
|
assert_equals((a[p][key] || 'undefined').toString(),
|
|
b[p][key].toString(),
|
|
`value for '${p}.${key}' on ${name}`);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
assert_equals(a[p], b[p], `value for '${p}' on ${name}`);
|
|
}
|
|
}
|