mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
Tests/LibWeb: Add tests for @font-face load behavior
This commit is contained in:
committed by
Andreas Kling
parent
f916b3e11f
commit
0de26af387
Notes:
github-actions[bot]
2026-04-25 15:08:05 +00:00
Author: https://github.com/jdahlin Commit: https://github.com/LadybirdBrowser/ladybird/commit/0de26af387f Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/9032 Reviewed-by: https://github.com/Psychpsyo
@@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: 'MultiFont';
|
||||
src: url('../../../Assets/HashSans.woff');
|
||||
unicode-range: U+0041; /* A */
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'MultiFont';
|
||||
src: url('unused-b.woff');
|
||||
unicode-range: U+0042; /* B */
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'MultiFont';
|
||||
src: url('unused-c.woff');
|
||||
unicode-range: U+0043; /* C */
|
||||
}
|
||||
.text { font-family: 'MultiFont', 'SerenitySans'; font-size: 40px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="text">A</div>
|
||||
<!-- Text inside a display:none element (a <script> in this case) must not trigger font loads.
|
||||
Here "BBBCCC" sits in a JSON script block and is never laid out; faceB and faceC therefore
|
||||
stay "unloaded" below even though the content contains codepoints in their unicode-ranges. -->
|
||||
<script type="application/json" id="blob">{"letters":"BBBCCC","more":"B and C should not be rendered"}</script>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
promiseTest(async () => {
|
||||
const faces = [...document.fonts].filter(f => f.family === 'MultiFont');
|
||||
faces.sort((a, b) => a.unicodeRange.localeCompare(b.unicodeRange));
|
||||
|
||||
// Force layout so text shaping runs — this is what triggers the render-path
|
||||
// load for faceA once deferral is implemented.
|
||||
document.body.offsetHeight;
|
||||
// Wait for every in-flight @font-face load to settle. At the pre-fix baseline
|
||||
// faceB and faceC are eagerly fetched and then reject with NetworkError; after
|
||||
// the fix only faceA is loaded and ready resolves immediately.
|
||||
await document.fonts.ready;
|
||||
|
||||
println(`MultiFont face count: ${faces.length}`);
|
||||
for (const f of faces)
|
||||
println(`range=${f.unicodeRange} status=${f.status}`);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user