diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/infrastructure/assumptions/document-fonts-ready.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/infrastructure/assumptions/document-fonts-ready.html')
-rw-r--r-- | testing/web-platform/tests/infrastructure/assumptions/document-fonts-ready.html | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/testing/web-platform/tests/infrastructure/assumptions/document-fonts-ready.html b/testing/web-platform/tests/infrastructure/assumptions/document-fonts-ready.html new file mode 100644 index 0000000000..9fb0137025 --- /dev/null +++ b/testing/web-platform/tests/infrastructure/assumptions/document-fonts-ready.html @@ -0,0 +1,32 @@ +<!DOCTYPE HTML> +<title>document.fonts.ready resolves after layout depending on loaded fonts</title> +<link rel="help" href="https://drafts.csswg.org/css-font-loading/#fontfaceset-pending-on-the-environment"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> +<style> + #foo { + font: 100px/1 Ahem; + } +</style> +<div id="log"></div> +<span id="foo">X</span> +<script> + // The purpose of this test is to ensure that testharness.js tests can use + // `document.fonts.ready` to wait for a web font to load, without having to + // wait for the window load event before or requestAnimationFrame after. + // + // The spec says that a FontFaceSet is "pending on the environment" if "the + // document has pending layout operations which might cause the user agent to + // request a font, or which depend on recently-loaded fonts", and both are + // assumed to hold true in this test. + async_test(t => { + assert_equals(document.fonts.size, 1, 'one font is pending'); + document.fonts.ready.then(t.step_func_done(() => { + const span = document.getElementById('foo'); + const rect = span.getBoundingClientRect(); + // If Ahem has loaded, the X will be 100px wide. + assert_equals(rect.width, 100, 'span is 100px wide'); + })); + }); +</script> |