summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/infrastructure/assumptions/document-fonts-ready.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/infrastructure/assumptions/document-fonts-ready.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
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.html32
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>