mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
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.
46 lines
1.6 KiB
HTML
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>
|