From 3dd7a8fe94dbe46e273e8900da06b3a55f2b28f5 Mon Sep 17 00:00:00 2001 From: mnovak Date: Fri, 4 Dec 2026 12:56:26 +0100 Subject: [PATCH] [domistream] HTTP: test that a full applist at MAX_APPS fits the XML element cap (fails: 4096 apps need 16385 elements) Hosts write four elements per app; MAX_APPS of them plus the root must fit MAX_XML_ELEMENTS, so the app cap is reachable. --- crates/domistream/tests/http.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/domistream/tests/http.rs b/crates/domistream/tests/http.rs index 477981f..ff81ea5 100644 --- a/crates/domistream/tests/http.rs +++ b/crates/domistream/tests/http.rs @@ -497,6 +497,24 @@ fn applist_caps() { ); } +#[test] +fn applist_cap_is_reachable_with_full_apps() { + // Hosts write four elements per app (App, AppTitle, ID, IsHdrSupported; the host writer does too): a list of + // MAX_APPS such apps plus the root must fit the XML element cap, so a list at the app cap parses (one app more is + // refused, by whichever cap comes first; `applist_caps` checks the app cap itself with three-element apps). + use domistream::http::applist::MAX_APPS; + let full = |n: usize| { + (0..n) + .map(|i| format!("g{i}1")) + .collect::() + }; + assert!(1 + 4 * MAX_APPS <= MAX_XML_ELEMENTS, "root + 4 per app = {} elements", 1 + 4 * MAX_APPS); + let apps = http::parse_app_list(&xml_root(200, &full(MAX_APPS))).expect("a full list at the app cap"); + assert_eq!(apps.len(), MAX_APPS); + assert!(apps.iter().all(|a| a.hdr_supported)); + assert_err!(http::parse_app_list(&xml_root(200, &full(MAX_APPS + 1))), Error::TooLarge { .. }); +} + // ================================================================================================ launch #[test]