Files
ladybird/Tests/LibWeb/Text/input/css/FontFace-arraybuffer-matching.html
Tim Ledbetter 2c728abd9f Tests: Use wider test string in FontFace arraybuffer matching test
This test relies on the width of the test font and the fallback font
being different to determine whether they matched or not. The
`offsetWidth` rounding change introduced in 51c7afdf5f caused these
widths to appear the same, meaning the test failed. This change avoids
the issue by using a longer string with a deliberately wide glyph.
2026-04-05 09:19:37 +02:00

46 lines
1.6 KiB
HTML

<!DOCTYPE html>
<script src="../include.js"></script>
<script>
promiseTest(async () => {
const fontData = await fetch("../../../Assets/HashSans.woff").then(
response => response.arrayBuffer());
const face = new FontFace("TestFont", fontData);
document.fonts.add(face);
await face.loaded;
const element = document.createElement("span");
element.style.fontFamily = "TestFont, serif";
element.style.fontSize = "20px";
// We use a deliberately long string and a wide glyph here to ensure the width of the test font and the fallback
// font will be different.
const testString = "WWWWWWWWWWWWWWWWWWWW"
element.textContent = testString;
document.body.appendChild(element);
const fallbackElement = document.createElement("span");
fallbackElement.style.fontFamily = "serif";
fallbackElement.style.fontSize = "20px";
fallbackElement.textContent = testString;
document.body.appendChild(fallbackElement);
// Force layout
document.body.offsetHeight;
const testWidth = element.offsetWidth;
const fallbackWidth = fallbackElement.offsetWidth;
println(`face.status: ${face.status}`);
println(`font matched: ${testWidth !== fallbackWidth}`);
document.fonts.delete(face);
// Force layout after removal
document.body.offsetHeight;
const afterDeleteWidth = element.offsetWidth;
println(`font unmatched after delete: ${afterDeleteWidth === fallbackWidth}`);
});
</script>