LibWeb: Resolve FontFaceSet::load promise with all loaded FontFaces
Some checks failed
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Build Dev Container Image / build (push) Has been cancelled

The resulting array is required on https://www.canva.com/
This commit is contained in:
Luke Wilde 2025-07-21 13:15:47 +01:00 committed by Sam Atkins
commit 8210a7b3e3
Notes: github-actions[bot] 2025-07-21 15:31:12 +00:00
6 changed files with 60 additions and 2 deletions

View file

@ -264,9 +264,10 @@ JS::ThrowCompletionOr<GC::Ref<WebIDL::Promise>> FontFaceSet::load(String const&
WebIDL::wait_for_all( WebIDL::wait_for_all(
realm, promises, realm, promises,
[&realm, promise](auto const&) { [&realm, promise](auto const& fonts) {
HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes }; HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
WebIDL::resolve_promise(realm, promise); auto fonts_array = JS::Array::create_from(realm, fonts);
WebIDL::resolve_promise(realm, promise, fonts_array);
}, },
[&realm, promise](auto error) { [&realm, promise](auto error) {
HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes }; HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass empty-family-load

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass fontfaceset-load-css-connected

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" title="Dominik Röttsches" href="drott@chromium.org">
<link rel="help" href="https://drafts.csswg.org/css-font-loading/#font-face-load">
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/4510">
<meta name="assert" content="Ensure that an empty font family name loads and resolves to array." />
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
promise_test(function(t) {
var testFontFace = new FontFace('a', 'url(a)');
document.fonts.add(testFontFace);
return document.fonts.load("1px \"\"").then(function(result) {
assert_true(Array.isArray(result),
"Resolved promise's value must be an array.") });
})
</script>
</html>

View file

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head id="head">
<meta charset="utf-8">
<link rel="author" title="Myles C. Maxfield" href="mmaxfield@apple.com">
<link rel="help" href="https://drafts.csswg.org/css-font-loading-3/#document-font-face-set">
<meta name="assert" content="Ensure that calling FontFaceSet.load() operates on the up-to-date @font-face blocks." />
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<style id="style">
@font-face {
font-family: "WebFont";
src: url("resources/Rochester.otf") format("opentype");
}
</style>
</head>
<body>
<script>
promise_test(async function(t) {
let fonts = document.fonts;
document.getElementById("head").removeChild(document.getElementById("style"));
let result = await fonts.load("12px 'WebFont'");
assert_equals(result.length, 0);
});
</script>
</body>
</html>