From 38de86937ee9af099b4c45c0704fa6cc627a59cd Mon Sep 17 00:00:00 2001 From: ldm0 Date: Wed, 23 Sep 2026 23:25:19 +0800 Subject: [PATCH] fix(fonts): load URL-backed FontFace resources asynchronously Fetch and validate font bytes through the owning Document resource loader, including URL fallback, CORS, CSP redirects, Service Workers and preload/SRI consumption. Preserve loaded promises and track pending FontFaceSet members, ready promises and queued loading events. Keep font tasks separate from author timer cancellation and dispatch child CSP violations at their source Document. Replace fake font fixtures and synchronous load assertions with real bytes and task-driven checks. --- moli-core/tests/fixtures/font-csp.js | 61 ++++++ moli-core/tests/fixtures/font-loading.js | 108 +++++++++ moli-core/tests/fixtures/font-preload.js | 38 ++++ moli-core/tests/scripts.rs | 2 + moli-core/tests/scripts/font_loading.rs | 44 ++++ .../tests/scripts/preload_consumption.rs | 22 +- moli-core/tests/web_apis.rs | 18 +- .../css_fontface_runtime/loading.rs | 8 +- moli-renderer-v8/src/document_runtime.rs | 4 +- .../src/document_runtime/security_policy.rs | 65 +++--- .../context_host/resource_loading.rs | 26 ++- .../context_host/security_policy.rs | 20 +- moli-renderer-v8/src/network_host.rs | 2 +- .../src/network_host/font_face.rs | 108 ++++++--- .../src/network_host/subresource.rs | 8 +- .../subresource_fetch/fetch_dispatch.rs | 23 +- .../script_vm/subresource_fetch/streaming.rs | 4 +- .../src/script_vm/tests/browser_api/misc.rs | 29 +++ .../tests/browser_api/misc/extracted/fonts.rs | 206 ++++++++++-------- moli-renderer-v8/src/types.rs | 13 +- moli-test-support/src/routes_core.rs | 8 + moli-test-support/src/server_routes.rs | 1 + .../wpt/ported/resources/font-fixture.js | 3 + 23 files changed, 636 insertions(+), 185 deletions(-) create mode 100644 moli-core/tests/fixtures/font-csp.js create mode 100644 moli-core/tests/fixtures/font-loading.js create mode 100644 moli-core/tests/fixtures/font-preload.js create mode 100644 moli-core/tests/scripts/font_loading.rs create mode 100644 moli-wpt-compat/fixtures/wpt/ported/resources/font-fixture.js diff --git a/moli-core/tests/fixtures/font-csp.js b/moli-core/tests/fixtures/font-csp.js new file mode 100644 index 00000000000..3603118b691 --- /dev/null +++ b/moli-core/tests/fixtures/font-csp.js @@ -0,0 +1,61 @@ +async function(crossOrigin) { + const rows = [], failures = []; + const control = (action, token, origin = location.origin) => + fetch(origin + '/probe-' + action + '?token=' + token).then(r => r.json()); + const url = (token, origin = location.origin, path = '/probe-asset') => + origin + path + '?as=font&token=' + token; + const frame = async (policy, reportOnly = false) => { + const iframe = document.createElement('iframe'); + const ready = new Promise(resolve => iframe.onload = resolve); + if (reportOnly) iframe.src = '/?reportPolicy=' + encodeURIComponent(policy); + else iframe.srcdoc = `font CSP`; + document.body.append(iframe); await ready; + return iframe; + }; + const outcome = face => face.load().then(() => 'loaded', e => e.name); + const check = (name, actual, expected) => { + rows.push({name, actual}); + if (JSON.stringify(actual) !== JSON.stringify(expected)) failures.push({name, actual, expected}); + }; + + const denied = await frame("font-src 'none'"); + const child = denied.contentWindow; + const violation = new Promise(resolve => child.addEventListener('securitypolicyviolation', resolve, {once: true})); + await control('release', 'child-block'); await control('release', 'parent-allow'); + const childFace = new child.FontFace('Blocked', `url("${url('child-block')}")`); + const childResult = await FontFace.prototype.load.call(childFace).then(() => 'loaded', e => e.name); + const event = await violation; + check('creation-document-csp', [childResult, event.effectiveDirective, event.target === child.document, + (await control('stats', 'child-block')).count, + await outcome(new FontFace('Allowed', `url("${url('parent-allow')}")`))], + ['NetworkError', 'font-src', true, 0, 'loaded']); + denied.remove(); + + const redirectFrame = await frame('font-src ' + location.origin + '/probe-asset'); + const other = redirectFrame.contentWindow; + await control('release', 'redirect-cross'); await control('release', 'blocked-final', crossOrigin); + const initial = url('redirect-cross') + '&status=302&redirect=' + encodeURIComponent(url('blocked-final', crossOrigin)); + const redirectedViolation = new Promise(resolve => other.addEventListener('securitypolicyviolation', resolve, {once: true})); + const redirected = await outcome(new other.FontFace('RedirectBlocked', `url("${initial}")`)); + const redirectEvent = await redirectedViolation; + check('redirect-blocks-before-wire', [redirected, redirectEvent.effectiveDirective, redirectEvent.blockedURI, + (await control('stats', 'redirect-cross')).count, (await control('stats', 'blocked-final', crossOrigin)).count], + ['NetworkError', 'font-src', initial, 1, 0]); + + await control('release', 'redirect-path'); await control('release', 'allowed-final'); + const pathRedirect = url('redirect-path') + '&status=302&redirect=' + encodeURIComponent(url('allowed-final', location.origin, '/probe-font-final')); + check('redirect-ignores-source-path', [await outcome(new other.FontFace('RedirectPath', `url("${pathRedirect}")`)), + (await control('stats', 'redirect-path')).count, (await control('stats', 'allowed-final')).count], ['loaded', 1, 1]); + redirectFrame.remove(); + + const reported = await frame("font-src 'none'", true); + const reporting = reported.contentWindow; + const report = new Promise(resolve => reporting.addEventListener('securitypolicyviolation', resolve, {once: true})); + await control('release', 'report-only'); + const reportedResult = await outcome(new reporting.FontFace('Reported', `url("${url('report-only')}")`)); + const reportEvent = await report; + check('report-only-does-not-block', [reportedResult, reportEvent.disposition, reportEvent.effectiveDirective, + (await control('stats', 'report-only')).count], ['loaded', 'report', 'font-src', 1]); + reported.remove(); + return {rows, failures}; +} diff --git a/moli-core/tests/fixtures/font-loading.js b/moli-core/tests/fixtures/font-loading.js new file mode 100644 index 00000000000..b9226acef39 --- /dev/null +++ b/moli-core/tests/fixtures/font-loading.js @@ -0,0 +1,108 @@ +async function(crossOrigin) { + const rows = [], failures = []; + const check = (name, actual, expected) => { + rows.push({name, actual}); + if (JSON.stringify(actual) !== JSON.stringify(expected)) failures.push({name, actual, expected}); + }; + const url = (token, query = '', origin = location.origin) => + origin + '/probe-asset?as=font&token=' + token + query; + const control = (action, token, origin = location.origin) => + fetch(origin + '/probe-' + action + '?token=' + token).then(r => r.json()); + const outcome = face => face.load().then(value => value === face ? 'loaded' : 'wrong value', e => e.name); + const event = name => new Promise(resolve => document.fonts.addEventListener(name, resolve, {once: true})); + + const face = new FontFace('AsyncFont', `url("${url('async')}")`); + document.fonts.add(face); + const previousReady = document.fonts.ready; + const done = event('loadingdone'); + const loaded = face.load(); + const setLoad = document.fonts.load('16px AsyncFont'); + const ready = document.fonts.ready; + let settled = false, setSettled = false, readySettled = false; + loaded.then(() => settled = true); + setLoad.then(() => setSettled = true); + ready.then(() => readySettled = true); + check('synchronous-state', [face.status, document.fonts.status, face.loaded === loaded, + face.load() === loaded, ready !== previousReady, document.fonts.check('16px AsyncFont')], + ['loading', 'loading', true, true, true, false]); + // Font loading and its events are native tasks, outside the public timer ids. + for (let id = 1; id < 100; id++) clearTimeout(id); + await control('started', 'async'); + await Promise.resolve(); + check('waits-for-bytes', [settled, setSettled, readySettled], [false, false, false]); + await control('release', 'async'); + const values = await setLoad; + await ready; + const completed = await done; + check('completed-state', [face.status, document.fonts.status, values.length, values[0] === face, + completed.fontfaces.length, completed.fontfaces[0] === face, document.fonts.check('16px AsyncFont'), + (await control('stats', 'async')).count, performance.getEntriesByName(url('async')).map(e => e.initiatorType)], + ['loaded', 'loaded', 1, true, 1, true, true, 1, ['css']]); + + const one = new FontFace('GroupOne', `url("${url('one')}")`); + const two = new FontFace('GroupTwo', `url("${url('two')}")`); + document.fonts.add(one); document.fonts.add(two); + const groupDone = event('loadingdone'); + const first = outcome(one), second = outcome(two); + const groupReady = document.fonts.ready; + let groupSettled = false; groupReady.then(() => groupSettled = true); + await control('started', 'one'); await control('started', 'two'); + await control('release', 'one'); await first; await Promise.resolve(); + check('ready-waits-for-all', [groupSettled, document.fonts.status], [false, 'loading']); + document.fonts.delete(two); + await groupReady; + const groupEvent = await groupDone; + await control('release', 'two'); await second; + check('removing-pending-face', [document.fonts.status, groupEvent.fontfaces.map(f => f.family)], ['loaded', ['GroupOne']]); + + for (const [token, query] of [['invalid', '&invalid=1'], ['http-error', '&status=404']]) { + await control('release', token); + check(token, await outcome(new FontFace(token, `url("${url(token, query)}")`)), 'NetworkError'); + } + await control('release', 'fallback-bad'); await control('release', 'fallback-good'); + const fallback = new FontFace('Fallback', `url("${url('fallback-bad', '&invalid=1')}"), url("${url('fallback-good')}")`); + check('fallback-after-decode-failure', [await outcome(fallback), (await control('stats', 'fallback-bad')).count, + (await control('stats', 'fallback-good')).count], ['loaded', 1, 1]); + + await control('release', 'cross-good', crossOrigin); await control('release', 'cross-bad', crossOrigin); + check('cors', [await outcome(new FontFace('CrossGood', `url("${url('cross-good', '', crossOrigin)}")`)), + await outcome(new FontFace('CrossBad', `url("${url('cross-bad', '&cors=none', crossOrigin)}")`))], ['loaded', 'NetworkError']); + + const base = document.createElement('base'); base.href = location.origin + '/before/'; document.head.append(base); + const relative = new FontFace('Relative', 'url("../probe-asset?as=font&token=relative")'); + base.href = location.origin + '/after/sub/'; await control('release', 'relative'); + check('creation-base-url', await outcome(relative), 'loaded'); base.remove(); + + await control('release', 'local'); + const bytes = await (await fetch(url('local'))).arrayBuffer(); + const blob = URL.createObjectURL(new Blob([bytes], {type: 'font/ttf'})); + const data = 'data:font/ttf;base64,' + btoa(String.fromCharCode(...new Uint8Array(bytes))); + check('local-font-validation', [await outcome(new FontFace('BlobFont', `url("${blob}")`)), + await outcome(new FontFace('DataFont', `url("${data}")`)), + await outcome(new FontFace('Truncated', 'url("data:font/ttf;base64,AAEAAA==")'))], ['loaded', 'loaded', 'NetworkError']); + URL.revokeObjectURL(blob); + + const iframe = document.createElement('iframe'); + const frameReady = new Promise(resolve => iframe.onload = resolve); + iframe.srcdoc = 'child'; document.body.append(iframe); await frameReady; + const other = iframe.contentWindow; + const childFace = new other.FontFace('ChildFont', `url("${url('child')}")`); + await control('release', 'child'); + const childLoad = FontFace.prototype.load.call(childFace); + check('cross-realm-load', [childLoad instanceof other.Promise, await childLoad === childFace, childFace.status], [true, true, 'loaded']); + iframe.remove(); + + const failed = new FontFace('RejectedSet', `url("${url('set-error', '&invalid=1')}")`); + document.fonts.add(failed); await control('release', 'set-error'); + const loadingError = event('loadingerror'); + const result = await document.fonts.load('16px RejectedSet').then(() => 'loaded', e => e.name); + await document.fonts.ready; + check('set-rejection-and-ready', [result, document.fonts.status, (await loadingError).fontfaces[0] === failed], ['NetworkError', 'loaded', true]); + + const meta = document.createElement('meta'); meta.httpEquiv = 'Content-Security-Policy'; meta.content = "font-src 'none'"; document.head.append(meta); + const violation = new Promise(resolve => addEventListener('securitypolicyviolation', e => resolve(e.effectiveDirective), {once: true})); + await control('release', 'csp'); + check('font-csp', [await outcome(new FontFace('BlockedFont', `url("${url('csp')}")`)), await violation, + (await control('stats', 'csp')).count], ['NetworkError', 'font-src', 0]); + return {rows, failures}; +} diff --git a/moli-core/tests/fixtures/font-preload.js b/moli-core/tests/fixtures/font-preload.js new file mode 100644 index 00000000000..be4a18bb1d4 --- /dev/null +++ b/moli-core/tests/fixtures/font-preload.js @@ -0,0 +1,38 @@ +async function() { + const control = (action, token) => fetch('/probe-' + action + '?token=' + token).then(r => r.json()); + await control('release', 'font-hash'); + const bytes = await (await fetch('/probe-asset?as=font&token=font-hash')).arrayBuffer(); + const hash = await crypto.subtle.digest('SHA-384', bytes); + const integrity = 'sha384-' + btoa(String.fromCharCode(...new Uint8Array(hash))); + const rows = [], failures = []; + for (const phase of ['pending', 'completed']) { + for (const crossOrigin of ['anonymous', 'use-credentials', null]) { + for (const valid of [true, false]) { + const token = 'font-preload-' + rows.length; + const url = new URL('/probe-asset?as=font&token=' + token, location.href).href; + const link = document.createElement('link'); + Object.assign(link, {rel: 'preload', as: 'font', href: url, integrity: valid ? integrity : 'sha384-AAAA==='}); + if (crossOrigin !== null) link.crossOrigin = crossOrigin; + const preload = new Promise(resolve => link.onload = link.onerror = e => resolve(e.type)); + document.head.append(link); + await control('started', token); + if (phase === 'completed') { await control('release', token); await preload; } + const face = new FontFace('Preloaded' + rows.length, `url("${url}")`); + const loaded = face.load().then(() => 'loaded', e => e.name); + if (phase === 'pending') { + if (face.status !== 'loading') failures.push({phase, crossOrigin, valid, status: face.status}); + await control('release', token); + } + const actual = [await preload, await loaded, (await control('stats', token)).count, + performance.getEntriesByName(url).map(e => e.initiatorType).sort()]; + const shared = crossOrigin === 'anonymous'; + const expected = [valid ? 'load' : 'error', shared && !valid ? 'NetworkError' : 'loaded', + shared ? 1 : 2, shared ? ['link'] : ['css', 'link']]; + rows.push({phase, crossOrigin, valid, actual}); + if (JSON.stringify(actual) !== JSON.stringify(expected)) failures.push({phase, crossOrigin, valid, actual, expected}); + link.remove(); + } + } + } + return {rows, failures}; +} diff --git a/moli-core/tests/scripts.rs b/moli-core/tests/scripts.rs index dcc96a4b89a..34532f78d51 100644 --- a/moli-core/tests/scripts.rs +++ b/moli-core/tests/scripts.rs @@ -1,5 +1,7 @@ #[path = "scripts/child_script_text.rs"] mod child_script_text; +#[path = "scripts/font_loading.rs"] +mod font_loading; #[path = "scripts/integrity.rs"] mod integrity; #[path = "scripts/worker_fetch_metadata.rs"] diff --git a/moli-core/tests/scripts/font_loading.rs b/moli-core/tests/scripts/font_loading.rs new file mode 100644 index 00000000000..28f436b253e --- /dev/null +++ b/moli-core/tests/scripts/font_loading.rs @@ -0,0 +1,44 @@ +use super::preload_consumption::PreloadServer; +use super::*; +use anyhow::Context; + +#[tokio::test(flavor = "multi_thread")] +async fn font_faces_fetch_validate_fallback_and_wait_for_font_sets() -> Result<()> { + run_font_probe(include_str!("../fixtures/font-loading.js"), 14).await +} + +#[tokio::test(flavor = "multi_thread")] +async fn font_faces_consume_matching_pending_and_completed_preloads() -> Result<()> { + run_font_probe(include_str!("../fixtures/font-preload.js"), 12).await +} + +#[tokio::test(flavor = "multi_thread")] +async fn font_faces_enforce_document_csp_before_initial_and_redirect_requests() -> Result<()> { + run_font_probe(include_str!("../fixtures/font-csp.js"), 4).await +} + +async fn run_font_probe(probe: &str, count: usize) -> Result<()> { + let server = PreloadServer::spawn().await?; + let cross = PreloadServer::spawn().await?; + let mut config = AppConfig::default(); + config.set_optional_resource_fetch_mask(moli_page_types::OptionalResourceFetchMask::ALL); + let browser = Browser::new(config)?; + let mut page = browser.fetch(&server.origin).await?; + let expression = format!( + "({probe})({}).then(JSON.stringify, error => JSON.stringify({{error: String(error.stack || error)}}))", + serde_json::to_string(&cross.origin)? + ); + let result = tokio::time::timeout( + Duration::from_secs(30), + page.evaluate_runtime_expression_with_await_async(&expression, true), + ) + .await??; + let value: serde_json::Value = serde_json::from_str( + result["value"] + .as_str() + .context("FontFace loading results")?, + )?; + assert_eq!(value["failures"], serde_json::json!([]), "{value}"); + assert_eq!(value["rows"].as_array().unwrap().len(), count, "{value}"); + Ok(()) +} diff --git a/moli-core/tests/scripts/preload_consumption.rs b/moli-core/tests/scripts/preload_consumption.rs index 869633ffdd3..2d78a181ac0 100644 --- a/moli-core/tests/scripts/preload_consumption.rs +++ b/moli-core/tests/scripts/preload_consumption.rs @@ -48,8 +48,8 @@ impl Asset { } } -struct PreloadServer { - origin: String, +pub(super) struct PreloadServer { + pub(super) origin: String, task: JoinHandle<()>, } @@ -60,7 +60,7 @@ impl Drop for PreloadServer { } impl PreloadServer { - async fn spawn() -> Result { + pub(super) async fn spawn() -> Result { let listener = TcpListener::bind("127.0.0.1:0").await?; let origin = format!("http://{}", listener.local_addr()?); let task = tokio::spawn(async move { @@ -86,7 +86,7 @@ impl PreloadServer { let mut cache = "no-store".to_owned(); let (mime, body) = match url.path() { "/probe-worker.js" => ("text/javascript", include_str!("../fixtures/preload-consumption-worker.js").to_owned()), - "/probe-asset" => { + "/probe-asset" | "/probe-font-final" => { asset.count.fetch_add(1, Ordering::AcqRel); asset.started.notify_waiters(); asset.wait(true).await; @@ -107,9 +107,21 @@ impl PreloadServer { } _ => ("text/html", "preload consumption".to_owned()), }; + let font = matches!(url.path(), "/probe-asset" | "/probe-font-final") && query.get("as").is_some_and(|kind| kind == "font"); + let body = if font { + if query.contains_key("invalid") { b"\0\x01\0\0".to_vec() } + else { include_bytes!("../../../moli-layout/tests/fixtures/moli-ahem.ttf").to_vec() } + } else { body.into_bytes() }; + let mime = if font { "font/ttf" } else { mime }; + let status = query.get("status").map(String::as_str).unwrap_or("200"); + let location = query.get("redirect").map(|url| format!("Location: {url}\r\n")).unwrap_or_default(); let origin = request.lines().find_map(|line| line.split_once(':').filter(|(name,_)| name.eq_ignore_ascii_case("Origin")).map(|(_,value)| value.trim())).unwrap_or("*"); - let response = format!("HTTP/1.1 200 OK\r\nContent-Type: {mime}\r\nCache-Control: {cache}\r\nAccess-Control-Allow-Origin: {origin}\r\nAccess-Control-Allow-Credentials: true\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{body}", body.len()); + let cors = if query.get("cors").is_some_and(|value| value == "none") { String::new() } + else { format!("Access-Control-Allow-Origin: {origin}\r\nAccess-Control-Allow-Credentials: true\r\n") }; + let policy = query.get("reportPolicy").map(|policy| format!("Content-Security-Policy-Report-Only: {policy}\r\n")).unwrap_or_default(); + let response = format!("HTTP/1.1 {status} OK\r\nContent-Type: {mime}\r\nCache-Control: {cache}\r\n{cors}{location}{policy}Content-Length: {}\r\nConnection: close\r\n\r\n", body.len()); let _ = stream.write_all(response.as_bytes()).await; + let _ = stream.write_all(&body).await; }); } _ = connections.join_next(), if !connections.is_empty() => {} diff --git a/moli-core/tests/web_apis.rs b/moli-core/tests/web_apis.rs index 6c926a2529c..d6c31318f52 100644 --- a/moli-core/tests/web_apis.rs +++ b/moli-core/tests/web_apis.rs @@ -2369,7 +2369,9 @@ async fn window_css_exposes_escape_and_supports() -> Result<()> { #[tokio::test] async fn document_fonts_remove_event_listener_keeps_other_event_types_intact() -> Result<()> { let server = FixtureServer::spawn().await?; - let browser = Browser::new(AppConfig::default())?; + let mut config = AppConfig::default(); + config.set_optional_resource_fetch_mask(moli_page_types::OptionalResourceFetchMask::ALL); + let browser = Browser::new(config)?; let mut page = browser .fetch(&server.url("/compat/document-fonts-events")) @@ -2382,6 +2384,9 @@ async fn document_fonts_remove_event_listener_keeps_other_event_types_intact() - ) .await?; + page.evaluate_runtime_expression_with_await_async("fontFixtureDone", true) + .await?; + assert!( page.serialize_html_async() .await @@ -4067,7 +4072,9 @@ async fn chrome_media_query_list_add_and_remove_listener_cover_wpt_subset() -> R #[tokio::test] async fn chrome_fontfaceset_event_handlers_fire_in_loading_then_done_order_subset() -> Result<()> { let server = FixtureServer::spawn().await?; - let browser = Browser::new(AppConfig::default())?; + let mut config = AppConfig::default(); + config.set_optional_resource_fetch_mask(moli_page_types::OptionalResourceFetchMask::ALL); + let browser = Browser::new(config)?; let mut page = browser .fetch(&server.url("/compat/chrome-fontfaceset-events-subset")) @@ -4080,6 +4087,9 @@ async fn chrome_fontfaceset_event_handlers_fire_in_loading_then_done_order_subse ) .await?; + page.evaluate_runtime_expression_with_await_async("fontFixtureDone", true) + .await?; + assert!( page.serialize_html_async() .await @@ -4922,7 +4932,9 @@ async fn servo_fontfaceset_delete_and_clear_do_not_remove_css_connected_faces() #[tokio::test] async fn servo_fontfaceset_load_replaces_ready_and_rejects_css_wide_keywords() -> Result<()> { let server = FixtureServer::spawn().await?; - let browser = Browser::new(AppConfig::default())?; + let mut config = AppConfig::default(); + config.set_optional_resource_fetch_mask(moli_page_types::OptionalResourceFetchMask::ALL); + let browser = Browser::new(config)?; let mut page = browser .fetch(&server.url("/compat/servo-fontfaceset-load-ready")) diff --git a/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/loading.rs b/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/loading.rs index 0fd6d568eb7..708b48db04a 100644 --- a/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/loading.rs +++ b/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/loading.rs @@ -448,12 +448,8 @@ fn advance_sources<'s>( let Some(url) = url else { break; }; - match crate::network_host::start_font_face_fetch(scope, face, request_context, &url) { - Ok(crate::network_host::FontFaceFetchStart::Pending) => return, - Ok(crate::network_host::FontFaceFetchStart::Local(bytes)) => { - let _ = load.borrow_mut().accept_response(Some(&bytes)); - } - Err(_) => {} + if crate::network_host::start_font_face_fetch(scope, face, request_context, &url).is_ok() { + return; } } publish_font_face_load_changes(scope); diff --git a/moli-renderer-v8/src/document_runtime.rs b/moli-renderer-v8/src/document_runtime.rs index 0b527e246cc..f6590a0a930 100644 --- a/moli-renderer-v8/src/document_runtime.rs +++ b/moli-renderer-v8/src/document_runtime.rs @@ -92,8 +92,8 @@ pub(crate) use script_lifecycle::{ pub(crate) use security_policy::{ DocumentConnectPolicySnapshot, DocumentContentSecurityPolicyCheck, DocumentContentSecurityPolicyViolation, DocumentNavigationEmbeddingContext, - DocumentSubresourceCspKind, create_content_security_policy_violation_event, - document_content_security_policy_error_message, + DocumentRequestPolicySnapshot, DocumentSubresourceCspKind, + create_content_security_policy_violation_event, document_content_security_policy_error_message, }; pub(crate) use stylesheet_runtime::attribute_reprocesses_connected_stylesheet; #[cfg(test)] diff --git a/moli-renderer-v8/src/document_runtime/security_policy.rs b/moli-renderer-v8/src/document_runtime/security_policy.rs index f3e4e6e6bac..f660b7dd20b 100644 --- a/moli-renderer-v8/src/document_runtime/security_policy.rs +++ b/moli-renderer-v8/src/document_runtime/security_policy.rs @@ -82,14 +82,17 @@ pub(crate) enum DocumentNavigationEmbeddingContext<'a> { } #[derive(Debug, Clone)] -pub(crate) struct DocumentConnectPolicySnapshot { +pub(crate) struct DocumentRequestPolicySnapshot { + resource_kind: ContentSecurityPolicyResourceKind, policy_self_url: Option>, enforce_policies: Vec, report_only_policies: Vec, reporting_endpoints: ContentSecurityPolicyReportingEndpoints, } -impl DocumentConnectPolicySnapshot { +pub(crate) type DocumentConnectPolicySnapshot = DocumentRequestPolicySnapshot; + +impl DocumentRequestPolicySnapshot { pub(crate) fn font_violation( &self, document_url: &Url, @@ -120,12 +123,18 @@ impl DocumentConnectPolicySnapshot { } } + pub(crate) fn for_resource_kind(mut self, kind: ContentSecurityPolicyResourceKind) -> Self { + self.resource_kind = kind; + self + } + pub(crate) fn from_policies( - enforce_policies: Vec, + enforce_policies: Vec, report_only_policies: Vec, reporting_endpoints: ContentSecurityPolicyReportingEndpoints, ) -> Self { Self { + resource_kind: ContentSecurityPolicyResourceKind::DocumentConnect, policy_self_url: None, enforce_policies: document_response_content_security_policy_strings( &enforce_policies, @@ -165,22 +174,37 @@ impl DocumentConnectPolicySnapshot { &self, document_url: &Url, request_url: &Url, + ) -> DocumentContentSecurityPolicyCheck { + self.check_url( + document_url, + request_url, + ContentSecurityPolicyRedirectStatus::FollowedRedirect, + ) + } + + pub(crate) fn check_url( + &self, + document_url: &Url, + request_url: &Url, + redirect_status: ContentSecurityPolicyRedirectStatus, ) -> DocumentContentSecurityPolicyCheck { let policy_url = self.policy_self_url.as_deref().unwrap_or(document_url); let mut result = DocumentContentSecurityPolicyCheck { - report_only_violations: document_connect_policy_violations( + report_only_violations: document_url_policy_violations( &self.report_only_policies, &self.reporting_endpoints, policy_url, request_url, - ContentSecurityPolicyRedirectStatus::FollowedRedirect, + self.resource_kind, + redirect_status, ContentSecurityPolicyDisposition::Report, ), - enforced_violations: document_connect_policy_violations_from_document_policies( + enforced_violations: document_url_policy_violations_from_document_policies( self.enforce_policies.clone(), policy_url, request_url, - ContentSecurityPolicyRedirectStatus::FollowedRedirect, + self.resource_kind, + redirect_status, ContentSecurityPolicyDisposition::Enforce, ), }; @@ -219,7 +243,7 @@ impl DocumentConnectPolicySnapshot { self.enforce_policies.clone(), self.policy_self_url.as_deref().unwrap_or(document_url), request_url, - ContentSecurityPolicyResourceKind::DocumentConnect, + self.resource_kind, redirect_status, ContentSecurityPolicyDisposition::Enforce, ) @@ -238,11 +262,12 @@ impl DocumentConnectPolicySnapshot { request_url: &Url, redirect_status: ContentSecurityPolicyRedirectStatus, ) -> Option { - document_connect_policy_violation( + document_url_policy_violation( &self.report_only_policies, &self.reporting_endpoints, self.policy_self_url.as_deref().unwrap_or(document_url), request_url, + self.resource_kind, redirect_status, ContentSecurityPolicyDisposition::Report, ) @@ -1154,6 +1179,7 @@ pub(crate) fn set_response_content_security_report_only_policies( ); } DocumentConnectPolicySnapshot { + resource_kind: ContentSecurityPolicyResourceKind::DocumentConnect, policy_self_url: policy .content_security_policy_self_url .clone() @@ -2051,7 +2077,7 @@ pub(crate) fn set_response_content_security_report_only_policies( ) } - fn queue_content_security_policy_violation_event_for_target<'s>( + pub(crate) fn queue_content_security_policy_violation_event_for_target<'s>( &mut self, scope: &mut v8::PinScope<'s, '_>, host_ptr: *mut JsContextHost, @@ -2320,25 +2346,6 @@ fn content_security_policy_frame_ancestors_violations_with_disposition_and_repor }).collect() } -fn document_connect_policy_violation( - policies: &[ContentSecurityPolicy], - reporting_endpoints: &ContentSecurityPolicyReportingEndpoints, - document_url: &Url, - request_url: &Url, - redirect_status: ContentSecurityPolicyRedirectStatus, - disposition: ContentSecurityPolicyDisposition, -) -> Option { - document_url_policy_violation( - policies, - reporting_endpoints, - document_url, - request_url, - ContentSecurityPolicyResourceKind::DocumentConnect, - redirect_status, - disposition, - ) -} - fn document_connect_policy_violations( policies: &[ContentSecurityPolicy], reporting_endpoints: &ContentSecurityPolicyReportingEndpoints, diff --git a/moli-renderer-v8/src/native_bridge/context_host/resource_loading.rs b/moli-renderer-v8/src/native_bridge/context_host/resource_loading.rs index d70dd85266d..5c9069bbd66 100644 --- a/moli-renderer-v8/src/native_bridge/context_host/resource_loading.rs +++ b/moli-renderer-v8/src/native_bridge/context_host/resource_loading.rs @@ -1255,7 +1255,7 @@ impl JsContextHost { pub(crate) fn record_async_font_face_fetch( &mut self, context: v8::Global, - face: v8::Global, + font: crate::types::PendingFontFaceFetch, owner: OwnerDispatchScope, cancel_handle: moli_fetch::FetchCancelHandle, network_partition_key: Option, @@ -1285,10 +1285,11 @@ impl JsContextHost { request_mode: moli_fetch::RequestMode::Cors, network_partition_key, policy_context, - continuation: PendingSubresourceContinuation::FontFace(face), + continuation: PendingSubresourceContinuation::FontFace(Box::new(font)), request_origin, redirect_headers: None, deferred_request_started: false, + blob_url_entry: None, }, ); self.note_subresource_activity(); @@ -1660,14 +1661,25 @@ impl JsContextHost { .get(&internal_id) .map(|state| &state.pending) })?; - let fetch = pending.continuation.window_fetch()?; - if !fetch.connect_policy().has_policies() { + let (policy, redirect_state, report_context) = + if let Some(fetch) = pending.continuation.window_fetch() { + ( + fetch.connect_policy(), + fetch.redirect_csp_state(), + fetch.csp_report_context(), + ) + } else if let PendingSubresourceContinuation::FontFace(font) = &pending.continuation { + (&font.policy, &font.redirect_state, &font.report_context) + } else { + return None; + }; + if !policy.has_policies() { return None; } - let report_context = fetch.csp_report_context().clone(); + let report_context = report_context.clone(); let completion_tx = self.resource_completion_sender(); - fetch.redirect_csp_state().redirect_check( - fetch.connect_policy().clone(), + redirect_state.redirect_check( + policy.clone(), pending.info.document_url.clone(), pending.info.url.clone(), move |violation| { diff --git a/moli-renderer-v8/src/native_bridge/context_host/security_policy.rs b/moli-renderer-v8/src/native_bridge/context_host/security_policy.rs index 6e4b85190a4..6cf3ace2f80 100644 --- a/moli-renderer-v8/src/native_bridge/context_host/security_policy.rs +++ b/moli-renderer-v8/src/native_bridge/context_host/security_policy.rs @@ -1288,8 +1288,24 @@ impl JsContextHost { handle: DomHandle, violation: &DocumentContentSecurityPolicyViolation, ) { - if let Err(error) = self - .dispatch_child_content_security_policy_violation_event(scope, handle, violation, false) + let Some(document) = self.child_browsing_context_document_handle(handle) else { + return; + }; + let Some(owner) = self.current_child_document_task_owner(handle) else { + return; + }; + let host_ptr: *mut JsContextHost = self; + // Preserve the source Document as the event target and enqueue the + // event on its lifecycle, just as for a top-level Document. + if let Err(error) = unsafe { &mut *self.runtime } + .queue_content_security_policy_violation_event_for_target( + scope, + host_ptr, + Some(document), + violation, + false, + Some(owner), + ) { tracing::error!( blocked_uri = violation.blocked_uri.as_str(), diff --git a/moli-renderer-v8/src/network_host.rs b/moli-renderer-v8/src/network_host.rs index 8eccd8d562b..e102af3cebf 100644 --- a/moli-renderer-v8/src/network_host.rs +++ b/moli-renderer-v8/src/network_host.rs @@ -26,7 +26,7 @@ mod url_helpers; mod xhr; pub(crate) use font_face::{ - FontFaceFetchStart, capture_font_face_request_context, resolve_font_face_sources, + capture_font_face_request_context, resolve_font_face_sources, start_font_face_fetch, }; use moli_fetch::{Request, Response, observe_cookie_access_report_for_request}; diff --git a/moli-renderer-v8/src/network_host/font_face.rs b/moli-renderer-v8/src/network_host/font_face.rs index 9332d0f753b..5de068f8411 100644 --- a/moli-renderer-v8/src/network_host/font_face.rs +++ b/moli-renderer-v8/src/network_host/font_face.rs @@ -2,14 +2,9 @@ use super::subresource::{PreparedSubresourceFetch, SubresourceFetchOptions}; use super::*; use crate::{ native_bridge::{JsContextHost, WindowExecutionContextIdentity}, - types::{SubresourceRequestInitiatorType, SubresourceResourceType}, + types::{AsyncSubresourceFetchCompletion, PendingFontFaceFetch, SubresourceResourceType}, }; -use anyhow::{Context, Result, anyhow, ensure}; - -pub(crate) enum FontFaceFetchStart { - Local(Vec), - Pending, -} +use anyhow::{Context, Result, anyhow}; /// Freeze the constructor's relevant Window, independently of an enclosing /// child request callback. The identity contains no strong V8 handles. @@ -57,7 +52,7 @@ pub(crate) fn start_font_face_fetch( face: v8::Local<'_, v8::Object>, request_context: Option, source: &str, -) -> Result { +) -> Result<()> { let host_ptr = crate::util::context_host_ptr_from_global_bridge(scope) .context("FontFace URL loader is unavailable in this realm")?; // SAFETY: the current live realm owns the bridge. No author callback runs @@ -77,55 +72,102 @@ pub(crate) fn start_font_face_fetch( .base_url .join(source) .context("failed to resolve FontFace source URL")?; - ensure!( - host.font_request_allowed_by_csp( - scope, - owner, + let policy = host + .document_connect_policy_snapshot_for_owner(owner) + .ok_or("FontFace policy owner is unavailable")? + .for_resource_kind( + crate::content_security_policy::ContentSecurityPolicyResourceKind::DocumentFont, + ); + let report_context = capture_window_csp_report_request_context(scope, host, owner) + .ok_or("FontFace reporting owner is unavailable")?; + let (reports, enforced) = policy + .check_url( &environment.document_url, &request_url, crate::content_security_policy::ContentSecurityPolicyRedirectStatus::NoRedirect, - ), - "Font request blocked by Content Security Policy" - ); - if let Some(response) = local_url_response(&request_url) { - let response: crate::types::NavigationResponse = response.into(); - let result = if (200..300).contains(&response.status) { - Ok(FontFaceFetchStart::Local(response.body_bytes().to_vec())) - } else { - Err(anyhow!("Font request failed")) - }; - host.record_get_subresource_network_result_with_initiator( - environment.frame_id, - environment.document_url, - request_url, - SubresourceResourceType::Font, - SubresourceRequestInitiatorType::Script, - &Ok(response), + ) + .into_violations(); + let blocked = !enforced.is_empty(); + for violation in reports.into_iter().chain(enforced) { + send_content_security_policy_violation_report_from_window_context( + host, + &report_context, + &violation, + ); + host.dispatch_document_connect_csp_violation_event_for_exact_owner_without_report_best_effort( + scope, host_ptr, report_context.identity(), &violation, ); - return result; } + if blocked { + return Err(anyhow!( + "FontFace request blocked by Content Security Policy" + )); + } + moli_fetch::FetchUrlList::new(&request_url, &[]) + .validate_request_mode(moli_fetch::RequestMode::Cors, &environment.request_origin) + .map_err(anyhow::Error::msg)?; + if matches!(request_url.scheme(), "http" | "https") + && !resource_loader + .request_client() + .optional_resource_fetch_enabled(SubresourceResourceType::Font) + { + return Err(anyhow!( + "FontFace requests are disabled by the resource policy" + )); + } + let font = PendingFontFaceFetch { + face: v8::Global::new(scope, face), + redirect_state: FetchCspRedirectState::new(&policy), + policy, + report_context, + }; let prepared = PreparedSubresourceFetch::prepare( scope, host, owner, &resource_loader, environment, - request_url, + request_url.clone(), SubresourceFetchOptions::FONT, )?; let internal_id = host.record_async_font_face_fetch( v8::Global::new(scope, scope.get_current_context()), - v8::Global::new(scope, face), + font, owner, prepared.cancel_handle.clone(), prepared.network_partition_key.clone(), prepared.network_context.policy_context, prepared.pending_info.clone(), ); + // Local URL responses use the same resource completion task as network + // responses, preserving the observable loading state before settlement. + let blob = CapturedBlobUrl::capture(&request_url); + if let Some(response) = + local_url_response_with_blob_entry(&request_url, "GET", &[], blob.as_ref()) + { + let result = response + .map(Into::into) + .map_err(|error| error.into_message()); + let _ = host.resource_completion_sender().send_async_subresource( + AsyncSubresourceFetchCompletion { + internal_id, + request_url, + request_method: "GET".to_owned(), + request_headers: Default::default(), + request_body: None, + response_status_text: None, + skip_fetch_security_validation: false, + response_filter: None, + network_error_text: None, + result: result.into(), + }, + ); + return Ok(()); + } prepared.dispatch( host, internal_id, "service worker font request dispatch failed", ); - Ok(FontFaceFetchStart::Pending) + Ok(()) } diff --git a/moli-renderer-v8/src/network_host/subresource.rs b/moli-renderer-v8/src/network_host/subresource.rs index 9e3798300a4..09ae9892c4e 100644 --- a/moli-renderer-v8/src/network_host/subresource.rs +++ b/moli-renderer-v8/src/network_host/subresource.rs @@ -132,11 +132,15 @@ impl PreparedSubresourceFetch { } pub(super) fn dispatch( - self, + mut self, host: &mut JsContextHost, internal_id: u64, service_worker_failure: &str, ) { + let redirect_check = host.window_fetch_redirect_check(internal_id); + if let Some(check) = redirect_check.clone() { + self.request = self.request.with_redirect_check(check); + } let loader = self.resource_loader.request_client().clone(); let task_runner = self.resource_loader.task_runner(); let info = self.pending_info; @@ -147,7 +151,7 @@ impl PreparedSubresourceFetch { .is_some() { let dispatch = ServiceWorkerFetchDispatch { - redirect_check: None, + redirect_check, internal_id, request: host.service_worker_fetch_request( client_id, diff --git a/moli-renderer-v8/src/script_vm/subresource_fetch/fetch_dispatch.rs b/moli-renderer-v8/src/script_vm/subresource_fetch/fetch_dispatch.rs index 3957a7bed6a..f6bc2156148 100644 --- a/moli-renderer-v8/src/script_vm/subresource_fetch/fetch_dispatch.rs +++ b/moli-renderer-v8/src/script_vm/subresource_fetch/fetch_dispatch.rs @@ -517,11 +517,22 @@ impl ScriptVm { let security_started = moli_trace::cdp_runtime_trace_enabled().then(Instant::now); let mut opaque_response_blocked = false; let result = result.and_then(|response| { - if matches!(pending.continuation, PendingSubresourceContinuation::FontFace(_)) - && !response.redirect_chain.is_empty() - && !context_host.borrow_mut().font_request_allowed_by_csp(scope, pending.execution_context.dispatch_scope(), &pending.info.document_url, &response.final_url, crate::content_security_policy::ContentSecurityPolicyRedirectStatus::FollowedRedirect) { - return Err("Font redirect blocked by Content Security Policy".to_owned()); + if let PendingSubresourceContinuation::FontFace(font) = &pending.continuation + && response.final_url != pending.info.url + && !font.redirect_state.was_checked(&response.final_url) { + let redirect_status = if response.redirect_chain.is_empty() { + ContentSecurityPolicyRedirectStatus::NoRedirect + } else { ContentSecurityPolicyRedirectStatus::FollowedRedirect }; + let (reports, enforced) = font.policy.check_url(&pending.info.document_url, &response.final_url, redirect_status).into_violations(); + let error = enforced.first().map(|violation| crate::document_runtime::document_content_security_policy_error_message(violation, "FontFace")); + for mut violation in reports.into_iter().chain(enforced) { + report_window_fetch_csp_redirect_violation(scope, &context_host, &font.report_context, &pending.info.url, &mut violation); + } + if let Some(error) = error { + return Err(error); + } } + if !response.redirect_chain.is_empty() && let Some(message) = document_connect_csp_redirect_failure_message( scope, @@ -787,7 +798,7 @@ impl ScriptVm { ), ), PendingSubresourceContinuation::FontFace(face) => { - let face = v8::Local::new(scope, face); + let face = v8::Local::new(scope, &face.face); let bytes = ((200..300).contains(&response_status) && !opaque_response_blocked) .then(|| observable_response.body_bytes()); crate::context_bootstrap::finish_font_face_url_load(scope, face, bytes); @@ -931,7 +942,7 @@ impl ScriptVm { Err(error_text.clone()), ), PendingSubresourceContinuation::FontFace(face) => { - let face = v8::Local::new(scope, face); + let face = v8::Local::new(scope, &face.face); crate::context_bootstrap::finish_font_face_url_load(scope, face, None); } PendingSubresourceContinuation::StylesheetSubresource { diff --git a/moli-renderer-v8/src/script_vm/subresource_fetch/streaming.rs b/moli-renderer-v8/src/script_vm/subresource_fetch/streaming.rs index 5f8ded23dd4..3326120a157 100644 --- a/moli-renderer-v8/src/script_vm/subresource_fetch/streaming.rs +++ b/moli-renderer-v8/src/script_vm/subresource_fetch/streaming.rs @@ -861,7 +861,7 @@ impl ScriptVm { Err(error_text.clone()), ), PendingSubresourceContinuation::FontFace(face) => { - let face = v8::Local::new(scope, face); + let face = v8::Local::new(scope, &face.face); crate::context_bootstrap::finish_font_face_url_load(scope, face, None); } PendingSubresourceContinuation::StylesheetSubresource { binding, .. } => { @@ -1108,7 +1108,7 @@ impl ScriptVm { Err("text-track response unexpectedly used streaming transport".to_owned()), ), PendingSubresourceContinuation::FontFace(face) => { - let face = v8::Local::new(scope, face); + let face = v8::Local::new(scope, &face.face); crate::context_bootstrap::finish_font_face_url_load(scope, face, None); } PendingSubresourceContinuation::StylesheetSubresource { binding, .. } => { diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/misc.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/misc.rs index 9feab96dfb2..e81a2cfcd6e 100644 --- a/moli-renderer-v8/src/script_vm/tests/browser_api/misc.rs +++ b/moli-renderer-v8/src/script_vm/tests/browser_api/misc.rs @@ -89,6 +89,35 @@ fn service_worker_csp_report_seen( report_body_seen || report_record_seen } +async fn eval_font_loading_fixture(url: &str, script: &str) -> String { + use base64::Engine as _; + let loader = ResourceRequestClient::new(&moli_fetch::FetchConfig::default()).unwrap(); + let mut page = + crate::runtime::PageVmTaskExecutorTestHarness::new(url::Url::parse(url).unwrap(), &loader); + let source = format!( + "url(data:font/ttf;base64,{})", + base64::engine::general_purpose::STANDARD.encode(include_bytes!( + "../../../../../moli-layout/tests/fixtures/moli-ahem.ttf" + )) + ); + page.eval(&format!( + "globalThis.fontFixtureSource = {};", + serde_json::to_string(&source).unwrap() + )) + .unwrap(); + page.eval(&format!("({script}).then(value => globalThis.fontFixtureResult = value, error => globalThis.fontFixtureResult = String(error.stack || error))")).unwrap(); + for _ in 0..64 { + let result = page.eval("String(globalThis.fontFixtureResult)").unwrap(); + if result != "undefined" { + return result; + } + wait_for_one_selected_page_task_executor_test_turn(&mut page, &loader) + .await + .unwrap(); + } + panic!("font loading fixture did not settle"); +} + async fn assert_popup_consecutive_history_back(from_popup: bool) { let loader = ResourceRequestClient::new(&moli_fetch::FetchConfig::default()).expect("loader"); let mut vm = diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/misc/extracted/fonts.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/misc/extracted/fonts.rs index f9fa23fbd65..5abc1a6219f 100644 --- a/moli-renderer-v8/src/script_vm/tests/browser_api/misc/extracted/fonts.rs +++ b/moli-renderer-v8/src/script_vm/tests/browser_api/misc/extracted/fonts.rs @@ -193,22 +193,13 @@ fn font_face_variation_settings_use_stylo_descriptor_serialization() { r#"{"values":["\"wght\" 850","\"wdth\" 120.5","\"wdth\" 120.5"],"setterError":"SyntaxError","constructorStatus":"error","descriptor":["function",0,"function",1,true,true,false]}"# ); } -#[test] -fn font_face_set_load_event_copies_and_freezes_fontfaces() { - let mut vm = new_storage_test_vm("https://font-face-set-load-event.test/"); - vm.eval(&format!( - "globalThis.fixtureFontSource = {:?}", - format!( - "url({:?})", - crate::script_vm::tests::browser_api::fonts::fixture_font_url() - ) - )) - .unwrap(); - - vm.eval( +#[tokio::test] +async fn font_face_set_load_event_copies_and_freezes_fontfaces() { + let result = eval_font_loading_fixture( + "https://font-face-set-load-event.test/", r#" -(() => { - const face = new FontFace('Demo', fixtureFontSource); +(async () => { + const face = new FontFace('Demo', fontFixtureSource); const source = [face]; const empty = new FontFaceSetLoadEvent('loading'); const configured = new FontFaceSetLoadEvent('loadingdone', { @@ -250,13 +241,15 @@ fn font_face_set_load_event_copies_and_freezes_fontfaces() { Object.isFrozen(event.fontfaces) ].join(':'); }); - fonts.load('10px Demo'); + const done = new Promise(resolve => fonts.addEventListener('loadingdone', resolve, {once: true})); + await fonts.load('10px Demo'); + await done; const descriptor = Object.getOwnPropertyDescriptor( FontFaceSetLoadEvent.prototype, 'fontfaces' ); - globalThis.__fontFaceSetEventProbe = { + return JSON.stringify({ surface: [ typeof FontFaceSetLoadEvent, FontFaceSetLoadEvent.length, @@ -293,17 +286,13 @@ fn font_face_set_load_event_copies_and_freezes_fontfaces() { throwsTypeError(() => new FontFaceSetLoadEvent('loading', { fontfaces: [{}] })), throwsTypeError(() => new FontFaceSetLoadEvent('loading', { fontfaces: null })) ], - get dispatched() { return [loadingShape, doneShape]; } - }; + dispatched: [loadingShape, doneShape] + }); })() "#, ) - .expect("FontFaceSetLoadEvent FrozenArray semantics should evaluate"); + .await; - run_font_tasks(&mut vm); - let result = vm - .eval("JSON.stringify(globalThis.__fontFaceSetEventProbe)") - .unwrap(); assert_eq!( result, r#"{"surface":["function",1,true,true,"[object FontFaceSetLoadEvent]"],"empty":[true,0,true,true],"configured":["loadingdone",true,true,true,1,true,true,true],"descriptor":["function","undefined","true","true","false"],"errors":[true,true,true,true],"dispatched":["true:true:true:0","true:true:true:1:true:true"]}"# @@ -466,22 +455,13 @@ fn font_face_set_listener_uses_callback_realm_and_exact_window_lifetime() { r#"{"facts":[[true,true,true,true]],"childDetached":true}"# ); } -#[test] -fn font_face_load_updates_owner_sets_once_and_unlinks_removed_faces() { - let mut vm = new_storage_test_vm("https://font-face-owner-sets.test/"); - vm.eval(&format!( - "globalThis.fixtureFontSource = {:?}", - format!( - "url({:?})", - crate::script_vm::tests::browser_api::fonts::fixture_font_url() - ) - )) - .unwrap(); - - vm.eval( +#[tokio::test] +async fn font_face_load_updates_owner_sets_once_and_unlinks_removed_faces() { + let result = eval_font_loading_fixture( + "https://font-face-owner-sets.test/", r#" -(() => { - const face = new FontFace('Demo', fixtureFontSource); +(async () => { + const face = new FontFace('Demo', fontFixtureSource); const documentFonts = document.fonts; const secondary = document.implementation.createHTMLDocument('').fonts; documentFonts.add(face); @@ -509,13 +489,14 @@ fn font_face_load_updates_owner_sets_once_and_unlinks_removed_faces() { const documentReadyBefore = documentFonts.ready; const secondaryReadyBefore = secondary.ready; + const done = Promise.all([documentFonts, secondary].map(set => new Promise(resolve => set.addEventListener('loadingdone', resolve, {once: true})))); const firstLoad = face.load(); const documentReadyAfter = documentFonts.ready; const secondaryReadyAfter = secondary.ready; const eventCountAfterFirstLoad = events.length; const secondLoad = face.load(); - const removed = new FontFace('Removed', 'local("Missing Removed Font 1337")'); + const removed = new FontFace('Removed', fontFixtureSource); documentFonts.add(removed); const removedDeleted = documentFonts.delete(removed); const documentReadyBeforeRemovedLoad = documentFonts.ready; @@ -523,14 +504,14 @@ fn font_face_load_updates_owner_sets_once_and_unlinks_removed_faces() { removed.load(); const clearedSet = document.implementation.createHTMLDocument('').fonts; - const cleared = new FontFace('Cleared', 'local("Missing Cleared Font 1337")'); + const cleared = new FontFace('Cleared', fontFixtureSource); clearedSet.add(cleared); const clearedReadyBeforeLoad = clearedSet.ready; clearedSet.clear(); const eventCountBeforeClearedLoad = events.length; cleared.load(); - globalThis.__fontFaceOwnerProbe = { + const result = { loads: [firstLoad === face.loaded, secondLoad === face.loaded], ready: [ documentReadyBefore !== documentReadyAfter, @@ -538,7 +519,7 @@ fn font_face_load_updates_owner_sets_once_and_unlinks_removed_faces() { documentReadyAfter === documentFonts.ready, secondaryReadyAfter === secondary.ready ], - get status() { return [documentFonts.status, secondary.status]; }, + during: [documentFonts.status, secondary.status], events, repeated: events.length === eventCountAfterFirstLoad, removed: [ @@ -552,35 +533,24 @@ fn font_face_load_updates_owner_sets_once_and_unlinks_removed_faces() { clearedSet.status === 'loaded' ] }; + await Promise.all([firstLoad, removed.loaded, cleared.loaded, done]); + result.status = [documentFonts.status, secondary.status]; + return JSON.stringify(result); })() "#, - ) - .expect("FontFace loads should update each current owner set once"); + ).await; - run_font_tasks(&mut vm); - let result = vm - .eval("JSON.stringify(globalThis.__fontFaceOwnerProbe)") - .unwrap(); assert_eq!( result, - r#"{"loads":[true,true],"ready":[true,true,true,true],"status":["loaded","loaded"],"events":["document:loading:true:true:true:0:true:true","secondary:loading:true:true:true:0:true:true","document:loadingdone:true:true:true:1:true:true","secondary:loadingdone:true:true:true:1:true:true"],"repeated":true,"removed":[true,true,true],"cleared":[true,true,true]}"# + r#"{"loads":[true,true],"ready":[true,true,true,true],"during":["loading","loading"],"events":["document:loading:true:true:true:0:true:true","secondary:loading:true:true:true:0:true:true","document:loadingdone:true:true:true:1:true:true","secondary:loadingdone:true:true:true:1:true:true"],"repeated":true,"removed":[true,true,true],"cleared":[true,true,true],"status":["loaded","loaded"]}"# ); } -#[test] -fn stylesheet_font_face_load_updates_document_font_set() { - let mut vm = new_storage_test_vm("https://stylesheet-font-face-owner.test/"); - vm.eval(&format!( - "globalThis.fixtureFontSource = {:?}", - format!( - "url({:?})", - crate::script_vm::tests::browser_api::fonts::fixture_font_url() - ) - )) - .unwrap(); - - vm.eval( +#[tokio::test] +async fn stylesheet_font_face_load_updates_document_font_set() { + let result = eval_font_loading_fixture( + "https://stylesheet-font-face-owner.test/", r#" -(() => { +(async () => { const observed = []; let face; for (const type of ['loading', 'loadingdone']) { @@ -594,27 +564,25 @@ fn stylesheet_font_face_load_updates_document_font_set() { }); } const style = document.createElement('style'); - style.textContent = `@font-face { font-family: "StylesheetOwner"; src: ${fixtureFontSource}; }`; + style.textContent = '@font-face { font-family: "StylesheetOwner"; src: ' + fontFixtureSource + '; }'; (document.head || document.documentElement || document).appendChild(style); face = [...document.fonts].find(face => face.family === 'StylesheetOwner'); const readyBefore = document.fonts.ready; + const done = new Promise(resolve => document.fonts.addEventListener('loadingdone', resolve, {once: true})); const loaded = face.load(); - globalThis.__stylesheetFontFaceProbe = { + await loaded; + await done; + return JSON.stringify({ face: face instanceof FontFace, loaded: loaded === face.loaded, ready: readyBefore !== document.fonts.ready, - get status() { return document.fonts.status; }, + status: document.fonts.status, observed - }; + }); })() "#, - ) - .expect("stylesheet FontFace loads should update document.fonts"); + ).await; - run_font_tasks(&mut vm); - let result = vm - .eval("JSON.stringify(globalThis.__stylesheetFontFaceProbe)") - .unwrap(); assert_eq!( result, r#"{"face":true,"loaded":true,"ready":true,"status":"loaded","observed":["loading:0:true:true","loadingdone:1:true:true"]}"# @@ -789,14 +757,14 @@ JSON.stringify({ r#"{"names":["ScreenOnly"],"beforeDescriptor":true,"descriptorChangedIdentity":true,"unrelatedInsertIdentity":true,"replaceChangedIdentity":true,"reinsertChangedIdentity":true,"unadoptedReinsertChangedIdentity":true}"# ); } -#[test] -fn font_face_binary_source_union_rejects_invalid_font_data() { - let mut vm = new_storage_test_vm("https://font-face-binary-source.test/"); - - vm.eval( +#[tokio::test] +async fn font_face_binary_source_union_rejects_invalid_font_data() { + let result = eval_font_loading_fixture( + "https://font-face-binary-source.test/", r#" -(() => { +(async () => { const face = new FontFace('InvalidBinary', new ArrayBuffer(8)); + await face.loaded.catch(() => {}); const fonts = document.implementation.createHTMLDocument('').fonts; fonts.add(face); const events = []; @@ -820,18 +788,16 @@ fn font_face_binary_source_union_rejects_invalid_font_data() { events, rejection: 'pending' }; - loaded.then( + await loaded.then( () => { globalThis.__fontFaceBinarySourceProbe.rejection = 'resolved'; }, error => { globalThis.__fontFaceBinarySourceProbe.rejection = error.name; } ); + return JSON.stringify(globalThis.__fontFaceBinarySourceProbe); })() "#, ) - .expect("invalid binary FontFace source should initialize"); + .await; - let result = vm - .eval("JSON.stringify(globalThis.__fontFaceBinarySourceProbe)") - .expect("invalid binary FontFace rejection should settle"); assert_eq!( result, r#"{"source":"","status":"error","samePromise":true,"readyChanged":false,"setStatus":"loaded","events":[],"rejection":"SyntaxError"}"# @@ -1569,3 +1535,73 @@ async fn invalid_font_face_defers_loaded_rejection_until_promise_is_observed() { "SyntaxError", ); } + +#[tokio::test] +async fn font_face_string_sources_follow_load_state_and_connected_style_use() { + let result = eval_font_loading_fixture( + "https://font-face-string-source-state.test/", + r#" +(async () => { + const remote = new FontFace('RemoteFace', fontFixtureSource); + const remoteLoaded = remote.loaded; + const invalid = new FontFace('InvalidFace', 'not a font source'); + const local = new FontFace( + 'MissingLocalFace', + 'local("definitely-missing-moli-font")' + ); + document.fonts.add(local); + + globalThis.__fontFaceStringSourceProbe = { + remote: { + before: remote.status, + stablePromise: remote.loaded === remoteLoaded, + loadReturnsLoaded: remote.load() === remoteLoaded, + after: remote.status, + settlement: 'pending' + }, + invalid: { + status: invalid.status, + settlement: 'pending' + }, + local: { + beforeStyle: local.status, + afterDetachedStyle: '', + afterConnection: '', + settlement: 'pending' + } + }; + remoteLoaded.then( + value => { + globalThis.__fontFaceStringSourceProbe.remote.settlement = + value === remote ? 'resolved-self' : 'resolved-other'; + }, + error => { + globalThis.__fontFaceStringSourceProbe.remote.settlement = error.name; + } + ); + invalid.loaded.then( + () => { globalThis.__fontFaceStringSourceProbe.invalid.settlement = 'resolved'; }, + error => { globalThis.__fontFaceStringSourceProbe.invalid.settlement = error.name; } + ); + local.loaded.then( + () => { globalThis.__fontFaceStringSourceProbe.local.settlement = 'resolved'; }, + error => { globalThis.__fontFaceStringSourceProbe.local.settlement = error.name; } + ); + + const target = document.createElement('div'); + target.style.fontFamily = 'MissingLocalFace'; + globalThis.__fontFaceStringSourceProbe.local.afterDetachedStyle = local.status; + (document.body || document.documentElement || document).appendChild(target); + globalThis.__fontFaceStringSourceProbe.local.afterConnection = local.status; + await Promise.allSettled([remoteLoaded, invalid.loaded, local.loaded]); + return JSON.stringify(globalThis.__fontFaceStringSourceProbe); +})() +"#, + ) + .await; + + assert_eq!( + result, + r#"{"remote":{"before":"unloaded","stablePromise":true,"loadReturnsLoaded":true,"after":"loading","settlement":"resolved-self"},"invalid":{"status":"error","settlement":"SyntaxError"},"local":{"beforeStyle":"unloaded","afterDetachedStyle":"unloaded","afterConnection":"loading","settlement":"NetworkError"}}"# + ); +} diff --git a/moli-renderer-v8/src/types.rs b/moli-renderer-v8/src/types.rs index ff641ede288..1ae450c2982 100644 --- a/moli-renderer-v8/src/types.rs +++ b/moli-renderer-v8/src/types.rs @@ -80,6 +80,13 @@ pub use crate::protocol_types::{ WebSocketLifecycleEvent, WebSocketLifecycleKind, WebSocketNetworkEvent, }; +pub(super) struct PendingFontFaceFetch { + pub(super) face: v8::Global, + pub(super) policy: crate::document_runtime::DocumentRequestPolicySnapshot, + pub(super) redirect_state: crate::network_host::FetchCspRedirectState, + pub(super) report_context: crate::network_host::WindowCspReportRequestContext, +} + pub(super) enum PendingSubresourceContinuation { Beacon, CspReport { @@ -87,6 +94,7 @@ pub(super) enum PendingSubresourceContinuation { }, EventSource(v8::Global), Fetch(PendingWindowFetchContinuation), + FontFace(Box), Image { image_handle: crate::document_runtime::DomHandle, sequence: crate::native_bridge::ImageLoadEventId, @@ -100,7 +108,6 @@ pub(super) enum PendingSubresourceContinuation { track_handle: crate::document_runtime::DomHandle, sequence: crate::native_bridge::TextTrackLoadSequenceId, }, - FontFace(v8::Global), StylesheetSubresource { binding: crate::frame_owner_model::StylesheetSubresourceLoadDelayBinding, target: crate::css_resource_urls::StylesheetSubresourceTarget, @@ -176,7 +183,9 @@ impl PendingSubresourceContinuation { .. } => *request_initiator_type, Self::Media { .. } | Self::TextTrack { .. } => SubresourceRequestInitiatorType::Other, - Self::StylesheetSubresource { .. } => SubresourceRequestInitiatorType::Css, + Self::StylesheetSubresource { .. } | Self::FontFace(_) => { + SubresourceRequestInitiatorType::Css + } _ => SubresourceRequestInitiatorType::Script, } } diff --git a/moli-test-support/src/routes_core.rs b/moli-test-support/src/routes_core.rs index b12b6b0dfc7..413c1331851 100644 --- a/moli-test-support/src/routes_core.rs +++ b/moli-test-support/src/routes_core.rs @@ -1404,6 +1404,14 @@ pub(super) async fn servo_fontfaceset_load_ready_page() -> Html<&'static str> { Html(SERVO_FONTFACESET_LOAD_READY_HTML) } +pub(super) async fn font_loading_fixture() -> Response { + ( + [(CONTENT_TYPE, HeaderValue::from_static("font/ttf"))], + include_bytes!("../../moli-layout/tests/fixtures/moli-ahem.ttf").as_slice(), + ) + .into_response() +} + pub(super) async fn servo_fontfaceset_empty_family_load_page() -> Html<&'static str> { Html(SERVO_FONTFACESET_EMPTY_FAMILY_LOAD_HTML) } diff --git a/moli-test-support/src/server_routes.rs b/moli-test-support/src/server_routes.rs index c79ff1966ba..82b22e16d37 100644 --- a/moli-test-support/src/server_routes.rs +++ b/moli-test-support/src/server_routes.rs @@ -3,6 +3,7 @@ use super::*; pub(super) fn build_router() -> Router { routes_wait::add_wait_routes(Router::new()) .route("/static", get(static_page)) + .route("/compat/font.ttf", get(font_loading_fixture)) .route("/compat/preload-count", get(preload_request_counter)) .route( "/compat/child-dynamic-markup-document", diff --git a/moli-wpt-compat/fixtures/wpt/ported/resources/font-fixture.js b/moli-wpt-compat/fixtures/wpt/ported/resources/font-fixture.js new file mode 100644 index 00000000000..29268b96d2c --- /dev/null +++ b/moli-wpt-compat/fixtures/wpt/ported/resources/font-fixture.js @@ -0,0 +1,3 @@ +// Valid TTF bytes from moli-layout/tests/fixtures/moli-ahem.ttf. +// Use a data URL so these API tests do not depend on optional network resources. +const fontFixtureSource = 'url("data:font/ttf;base64,AAEAAAAKAIAAAwAgT1MvMkgiSDMAAAEoAAAAYGNtYXABEgIlAAACUAAAAERnbHlmyb+UdAAAA1wAAAkYaGVhZFm5pQAAAACsAAAANmhoZWEFegGSAAAA5AAAACRobXR4AlgAAAAAAYgAAADGbG9jYXCMbkwAAAKUAAAAxm1heHAAZAAGAAABCAAAACBuYW1liiBnMwAADHQAAAGPcG9zdIMIFxAAAA4EAAAD5gABAAAAAQAAwGeQDl8PPPUAAwPoAAAAAHwlsIAAAAAAfCWwgAAAAAACWAMgAAAAAwACAAAAAAAAAAEAAAMg/zgAAAJYAAAAAAJYAAEAAAAAAAAAAAAAAAAAAAABAAEAAABiAAQAAQAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAwJYAZAABQAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAPz8/PwBAACAA3wMg/zgAAAMgAMgAAAAAAAAAAAMgAyAAAAAgAAACWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAADAAAAFAADAAEAAAAUAAQAMAAAAAgACAACAAAAfgCgAN///wAAACAAoADf////4f/A/4IAAQAAAAAAAAAAAAAADAAMABgAJAAwADwASABUAGAAbAB4AIQAkACcAKgAtADAAMwA2ADkAPAA/AEIARQBIAEsATgBRAFQAVwBaAF0AYABjAGYAaQBsAG8AcgB1AHgAewB+AIEAhACHAIoAjQCQAJMAlgCZAJwAnwCiAKUAqACrAK4AsQC0ALcAugC9AMAAwwDGAMkAzADPANIA1QDYANsA3gDhAOQA5wDqAO0A8ADzAPYA+QD8AP8BAgEFAQgBCwEOAREBFAEXARoBHQEgASMAAAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAQAAAAACWAMgAAMAADEhESECWP2oAyAAAAAMAJYAAQAAAAAAAQAJAAAAAQAAAAAAAgAHAAkAAQAAAAAAAwAVABAAAQAAAAAABAARACUAAQAAAAAABQANADYAAQAAAAAABgAQAEMAAwABBAkAAQASAFMAAwABBAkAAgAOAGUAAwABBAkAAwAqAHMAAwABBAkABAAiAJ0AAwABBAkABQAaAL8AAwABBAkABgAgANlNb2xpIEFoZW1SZWd1bGFyTW9saSBBaGVtIFJlZ3VsYXIgMS4wTW9saSBBaGVtIFJlZ3VsYXJWZXJzaW9uIDEuMDAwTW9saUFoZW0tUmVndWxhcgBNAG8AbABpACAAQQBoAGUAbQBSAGUAZwB1AGwAYQByAE0AbwBsAGkAIABBAGgAZQBtACAAUgBlAGcAdQBsAGEAcgAgADEALgAwAE0AbwBsAGkAIABBAGgAZQBtACAAUgBlAGcAdQBsAGEAcgBWAGUAcgBzAGkAbwBuACAAMQAuADAAMAAwAE0AbwBsAGkAQQBoAGUAbQAtAFIAZQBnAHUAbABhAHIAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYgAAAAMBAgEDAQQBBQEGAQcBCAEJAQoBCwEMAQ0BDgEPARABEQESARMBFAEVARYBFwEYARkBGgEbARwBHQEeAR8BIAEhASIBIwEkASUBJgEnASgBKQEqASsBLAEtAS4BLwEwATEBMgEzATQBNQE2ATcBOAE5AToBOwE8AT0BPgE/AUABQQFCAUMBRAFFAUYBRwFIAUkBSgFLAUwBTQFOAU8BUAFRAVIBUwFUAVUBVgFXAVgBWQFaAVsBXAFdAV4BXwFgAWEHdW5pMDAyMQd1bmkwMDIyB3VuaTAwMjMHdW5pMDAyNAd1bmkwMDI1B3VuaTAwMjYHdW5pMDAyNwd1bmkwMDI4B3VuaTAwMjkHdW5pMDAyQQd1bmkwMDJCB3VuaTAwMkMHdW5pMDAyRAd1bmkwMDJFB3VuaTAwMkYHdW5pMDAzMAd1bmkwMDMxB3VuaTAwMzIHdW5pMDAzMwd1bmkwMDM0B3VuaTAwMzUHdW5pMDAzNgd1bmkwMDM3B3VuaTAwMzgHdW5pMDAzOQd1bmkwMDNBB3VuaTAwM0IHdW5pMDAzQwd1bmkwMDNEB3VuaTAwM0UHdW5pMDAzRgd1bmkwMDQwB3VuaTAwNDEHdW5pMDA0Mgd1bmkwMDQzB3VuaTAwNDQHdW5pMDA0NQd1bmkwMDQ2B3VuaTAwNDcHdW5pMDA0OAd1bmkwMDQ5B3VuaTAwNEEHdW5pMDA0Qgd1bmkwMDRDB3VuaTAwNEQHdW5pMDA0RQd1bmkwMDRGB3VuaTAwNTAHdW5pMDA1MQd1bmkwMDUyB3VuaTAwNTMHdW5pMDA1NAd1bmkwMDU1B3VuaTAwNTYHdW5pMDA1Nwd1bmkwMDU4B3VuaTAwNTkHdW5pMDA1QQd1bmkwMDVCB3VuaTAwNUMHdW5pMDA1RAd1bmkwMDVFB3VuaTAwNUYHdW5pMDA2MAd1bmkwMDYxB3VuaTAwNjIHdW5pMDA2Mwd1bmkwMDY0B3VuaTAwNjUHdW5pMDA2Ngd1bmkwMDY3B3VuaTAwNjgHdW5pMDA2OQd1bmkwMDZBB3VuaTAwNkIHdW5pMDA2Qwd1bmkwMDZEB3VuaTAwNkUHdW5pMDA2Rgd1bmkwMDcwB3VuaTAwNzEHdW5pMDA3Mgd1bmkwMDczB3VuaTAwNzQHdW5pMDA3NQd1bmkwMDc2B3VuaTAwNzcHdW5pMDA3OAd1bmkwMDc5B3VuaTAwN0EHdW5pMDA3Qgd1bmkwMDdDB3VuaTAwN0QHdW5pMDA3RQd1bmkwMEEwB3VuaTAwREYAAA==")';