From 0806611caed3e12eaee4f66596a54a40365b5caa Mon Sep 17 00:00:00 2001 From: astar76 Date: Sat, 14 Nov 2026 15:31:38 -0600 Subject: [PATCH] S054: default user agent names Safari 26 (Discord), interaction smoke (WIP) Co-Authored-By: Claude Opus 5.5 --- Plans/08 WebKit engine/S054-site-pass.md | 6 +- src/engine/host.rs | 32 +++++++++- tests/smoke/site-interact.txt | 81 ++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 tests/smoke/site-interact.txt diff --git a/Plans/08 WebKit engine/S054-site-pass.md b/Plans/08 WebKit engine/S054-site-pass.md index e944d74..b6191f4 100644 --- a/Plans/08 WebKit engine/S054-site-pass.md +++ b/Plans/08 WebKit engine/S054-site-pass.md @@ -31,5 +31,7 @@ Open differences ranked by daily impact. ## Resume (WIP) Boxes 1–2 done: `tests/smoke/site-pass.txt`, `docs/engine/site-pass-webkit.md` (pairs table), shots in -`docs/engine/site-pass/`. Box 3 started: autoplay fix in `src/engine/host.rs` (built, site-pass green). Next: other -Nacre-side causes, then the interaction checks (box 4). +`docs/engine/site-pass/`. Box 3: autoplay allowed and default UA `Version/26.0` (Discord) in `src/engine/host.rs`, +built, tests 86+1 green. Box 4: `tests/smoke/site-interact.txt` passes every check, but the UI process segfaults +inside WebKit during the Discord step after the full sequence (twice; not with Reddit→pop-up→Discord alone): +coredumpctl nacre, symbolize with gdb + debuginfod; bisect the sequence. diff --git a/src/engine/host.rs b/src/engine/host.rs index 98d8ff1..de6e255 100644 --- a/src/engine/host.rs +++ b/src/engine/host.rs @@ -107,6 +107,18 @@ fn attach_filters(web: &webkit::WebView, hub: &Hub, filters: &RefCell String { + match ua.split_once("Version/") { + Some((head, tail)) => { + let rest = tail.find(' ').map_or("", |i| &tail[i..]); + format!("{head}Version/26.0{rest}") + }, + None => ua.to_owned(), + } +} + fn env(name: &str) -> Option { std::env::var(name).ok().filter(|v| !v.is_empty()) } @@ -184,7 +196,9 @@ impl Engine { context.cache_model(), settings.hardware_acceleration_policy() ); - if !setup.user_agent.trim().is_empty() { + if setup.user_agent.trim().is_empty() { + settings.set_user_agent(Some(&safari_version(&settings.user_agent().unwrap_or_default()))); + } else { settings.set_user_agent(Some(setup.user_agent.trim())); } // The web process extension (D-036): headers, ad blocker stand-ins, blocked counts. @@ -391,7 +405,12 @@ impl Engine { } pub fn set_user_agent(&self, ua: &str) { - self.settings.set_user_agent(if ua.trim().is_empty() { None } else { Some(ua.trim()) }); + if ua.trim().is_empty() { + self.settings.set_user_agent(None); + self.settings.set_user_agent(Some(&safari_version(&self.settings.user_agent().unwrap_or_default()))); + } else { + self.settings.set_user_agent(Some(ua.trim())); + } } /// Accept-Language and `navigator.languages`. @@ -873,7 +892,14 @@ fn media_dirs(selftest: bool) -> Vec { #[cfg(test)] mod tests { - use super::media_dirs; + use super::{media_dirs, safari_version}; + + #[test] + fn default_user_agent_names_a_real_safari() { + let webkit = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/60.5 Safari/605.1.15"; + assert_eq!(safari_version(webkit), "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15"); + assert_eq!(safari_version("Firefox/140.0"), "Firefox/140.0"); + } #[test] fn media_dirs_never_home() { diff --git a/tests/smoke/site-interact.txt b/tests/smoke/site-interact.txt new file mode 100644 index 0000000..e843e4b --- /dev/null +++ b/tests/smoke/site-interact.txt @@ -0,0 +1,81 @@ +# Site interactions (S054): what people do on the daily sites, with real compositor input (hidden only: rclick and +# the pop-up need tools/wl-input). YouTube: autoplay, seek by key and by script, page full screen and back; Google +# sign-in: the email field takes typing (nothing sent); Reddit: infinite scroll, Nacre's context menu on a link, the +# "Continue with Google" button opens a sign-in pop-up (closed, nothing signed in); Discord: the login form. +# NEEDS INTERNET. Direct connections only: never a VPN, Tor or proxy. +# Run with SMOKE_SIZE=1280x800 SMOKE_TIMEOUT=900 tools/smoke.sh tests/smoke/site-interact.txt; read the PNGs. +wait 3 +open https://www.youtube.com/watch?v=aqz-KE-bpKQ +waitfor 120 location.pathname === "/watch" && !!document.querySelector("video") +waitfor 60 document.querySelector("video").currentTime > 0 && !document.querySelector("video").paused +js (() => { const v = document.querySelector("video"); window.__t0 = v.currentTime; v.currentTime = 120; return "seek"; })() +waitfor 60 document.querySelector("video").currentTime > 120 && !document.querySelector("video").seeking +shot yt-seeked +locate #movie_player video +wait 1 +click @ +wait 1 +pagetype l +wait 2 +save yt-keys JSON.stringify({ t: document.querySelector("video").currentTime, paused: document.querySelector("video").paused }) +assert document.querySelector("video").paused && document.querySelector("video").currentTime > 129 +pagetype f +waitfor 20 !!document.fullscreenElement +wait 3 +expect /fullscreen true +shot yt-fullscreen +pagetype {escape} +waitfor 20 !document.fullscreenElement +wait 2 +expect /fullscreen false +shot yt-fullscreen-back +open https://accounts.google.com/ +waitfor 60 !!document.querySelector("#identifierId") +wait 5 +locate #identifierId +wait 1 +click @ +wait 1 +pagetype nacre.smoke.test +wait 2 +assert document.querySelector("#identifierId").value === "nacre.smoke.test" +shot google-typed +open https://www.reddit.com/r/rust/ +waitfor 90 document.readyState === "complete" && document.querySelectorAll("shreddit-post").length > 0 +wait 15 +save reddit-before JSON.stringify({ posts: document.querySelectorAll("shreddit-post").length }) +pagescroll 640 400 4000 +wait 4 +pagescroll 640 400 4000 +wait 4 +pagescroll 640 400 4000 +wait 8 +save reddit-after JSON.stringify({ posts: document.querySelectorAll("shreddit-post").length, y: scrollY }) +shot reddit-scrolled +js (() => { window.scrollTo(0, 0); return "top"; })() +wait 3 +locate shreddit-post a[slot=full-post-link], shreddit-post a[href*="/comments/"] +wait 1 +rclick @ +wait 2 +shot reddit-ctxmenu +expect /active/dialog true +key escape +wait 1 +locate iframe[src*="gsi/button"] +wait 1 +click @ +wait 10 +# Pop-ups open as tabs (as in the original Nacre; Chromium gives them a window). +expect /tab_count 2 +shot reddit-popup +cmd close_tab +open https://discord.com/login +waitfor 90 document.readyState === "complete" +wait 40 +# The login form shows (it stayed blank with WebKit's own "Version/60.5" Safari agent). +assert !!document.querySelector("input[name=email]") +save discord JSON.stringify({ email: !!document.querySelector("input[name=email]"), text: document.body.innerText.slice(0, 200), scripts: document.scripts.length, root: (document.querySelector("#app-mount") || {}).childElementCount }) +shot discord +status done +quit