S050 (WIP): Google UA quirk past WebKit's site quirks, navigation policy only for the tab's own loads, DocumentBrowser cache model (D-040), privacy-mode on WebKit
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
parent
070227847a
commit
e12d9ee9af
6 changed files with 84 additions and 19 deletions
|
|
@ -19,13 +19,14 @@ download manager stubs, HTTP cache on disk.
|
|||
- [x] `download-started` → Nacre's downloads store/UI or the custom manager hand-off; progress, cancel, destination, finished state.
|
||||
- [x] TLS errors → Nacre's certificate warning page; "continue" allows the cert for the host for the run.
|
||||
- [x] Error pages from Nacre's look (port `assets/servo/neterror.html`/`badcert.html` style into `nacre://` pages).
|
||||
- [ ] `CookieManager` accept policy (third-party), `set_preferred_languages`, privacy mode Accept-Language, per-view UA quirk.
|
||||
- [x] `CookieManager` accept policy (third-party), `set_preferred_languages`, privacy mode Accept-Language, per-view UA quirk.
|
||||
- [x] Loopback/127.0.0.1 and localhost bypass the bridge (today a loopback page ends in "Message was restarted too many times" with the URL rewritten to the bridge port; found in S046); regression smoke.
|
||||
- [x] `net::policy::decide` wired on WebKit (main frames + images), including the images permission (handed over by S049).
|
||||
- [ ] `privacy-net.txt` exits 0: `*.nacre.test` through the bridge's DoH, third-party cookies (handed over by S049).
|
||||
- [x] `privacy-net.txt` exits 0: `*.nacre.test` through the bridge's DoH, third-party cookies (handed over by S049).
|
||||
- [x] Remove the stale PROGRESS "Later" line about the niri window rule (fixed by D-045, e434bd2).
|
||||
- [ ] Navigation policy only for the tab's own (main frame) loads: WebKit's GTK API can't tell iframe navigations apart (`frame_name()` is empty for unnamed iframes), so HTTPS-only, the strip and the UA reload can take over a tab with a frame's URL today. Likely fix: the web process extension tells main-frame loads (found in S050).
|
||||
- [ ] Smoke (start `python3 tests/smoke/net/server.py &` / `cache/server.py &`): `net-privacy.txt`, `net-downloads.txt`, `privacy-net.txt`, `privacy-mode.txt`, `cache.txt` + `cache-restart.txt` green hidden.
|
||||
- [x] Navigation policy only for the tab's own (main frame) loads: WebKit's GTK API can't tell iframe navigations apart (`frame_name()` is empty for unnamed iframes), so HTTPS-only, the strip and the UA reload can take over a tab with a frame's URL today. Likely fix: the web process extension tells main-frame loads (found in S050).
|
||||
- [x] Smoke (start `python3 tests/smoke/net/server.py &` / `cache/server.py &`): `net-privacy.txt`, `net-downloads.txt`, `privacy-net.txt`, `privacy-mode.txt`, `cache.txt` + `cache-restart.txt` green hidden.
|
||||
- [ ] Rerun the S046–S049 smokes hidden (the old selftest could pass with asserts unanswered): launch, basics, input, keys, chrome, dialogs, pip, auth, stores-*, integ-spell, net-adblock, crash-adblock; fix or log failures.
|
||||
- [ ] PROGRESS entry, INDEX line, tracker, commit `S050: …`, push.
|
||||
|
||||
## End criteria
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
- D-037 — 2026-11-13 — Cookies at rest on WebKit (keeps D-019's rule "never plain on disk"): WebKit's SQLite cookie store lives in the per-run `$XDG_RUNTIME_DIR` (tmpfs, 0700) via `CookieManager::set_persistent_storage`; Nacre fills it from the sealed `cookies.bin` at start and seals it back (D-019 key, XChaCha20-Poly1305) at quit and every 60 s after a cookie change. No keyring → cookies for the run only, as before. Servo-era `cookies.bin` is converted when it parses, else moved aside. — keeps encryption without patching WebKit; tmpfs never touches the disk — S051
|
||||
- D-038 — 2026-11-13 — Profile folder `nacre-servo` → `nacre-browser` (config, data, cache): on first start, if `nacre-browser` is missing and `nacre-servo` exists, it is renamed (one move, logged); Servo-only engine files inside are deleted after the move. `~/.config/nacre` belongs to the Python Nacre and is never touched (the importer reads it). — engine name out of the path; `nacre` is taken by the original — S051
|
||||
- D-039 — 2026-11-13 — Media on WebKit: Nacre's page-script media probe (`inject.rs` `media.*`, mediaSession hook) stays the one source for the new tab card, Discord and MPRIS; WebKit's `is-playing-audio` and `set_is_muted` replace the mute script. If WebKitGTK publishes its own MPRIS player it is not left as a second player (turned off or Nacre's skipped, whichever the plan finds possible; one player only). — one engine-neutral source already feeds three features — S051, S013
|
||||
- D-040 — 2026-11-13 — WebKit tuning defaults (D-032 data, `docs/engine/tune/`): page cache off, memory pressure limit 500 MB per web process, cache model `DocumentViewer`, hardware acceleration policy default (on demand; `never` broke JS checks), related views only for pop-ups. Env overrides for tests (`NACRE_WK_PAGE_CACHE`, `NACRE_WK_MEM_LIMIT`, `NACRE_WK_CACHE_MODEL`, `NACRE_WK_HW`). — lowest PSS/VRAM in the tune runs without failed sites — S052
|
||||
- D-040 — 2026-11-13 — WebKit tuning defaults (D-032 data, `docs/engine/tune/`): page cache off, memory pressure limit 500 MB per web process, cache model `DocumentBrowser` (amended in S050: `DocumentViewer` has no HTTP disk cache; hidden 4-tab check, nacre tree PSS median: viewer 1147 MB, browser 1128 MB; env `viewer` for the old one), hardware acceleration policy default (on demand; `never` broke JS checks), related views only for pop-ups. Env overrides for tests (`NACRE_WK_PAGE_CACHE`, `NACRE_WK_MEM_LIMIT`, `NACRE_WK_CACHE_MODEL`, `NACRE_WK_HW`). — lowest PSS/VRAM in the tune runs without failed sites — S052
|
||||
- D-041 — 2026-11-13 — S044 boxes 3–5 (Nacre `ViewId`, engine-neutral `Event` payload types, selftest on them) move to S045 and are defined directly on WebKit; S044 closes with the privacy/policy move. — converting 56 Servo payload uses and 14 `WebViewId` sites now would only add Servo adapters that S045/S048 delete — orchestrator, 2026-11-13 — S044, S045
|
||||
- D-042 — 2026-11-13 — S045 GTK host: the WebKit build ports page controls instead of stubbing them (script dialogs, `<select>`, colour, file, HTTP auth, permissions, context menu from WebKit's hit test, notifications); Bluetooth chooser and protocol-handler prompts are removed (WebKit has neither); picture in picture shows "isn't available yet" until S047; one `UserContentManager` per view so page messages carry their `ViewId` (bridge posts to `window.webkit.messageHandlers.nacre`); cookies stay in WebKit's memory until S051 (`Keeping::RunOnly`); downloads come from the response policy (non-displayable main-frame MIME) plus `looks_like_download`, the Servo download probe is gone; WebKit data/cache under `<profile data>/webkit` and `<cache>/webkit`; views sit in a `Gtk.Overlay` placed by margins (a `Gtk.Fixed` size request grew the window); prefers-color-scheme follows GTK's dark preference set by Nacre (its own changes ignored by the system-scheme watcher); with no desktop font DPI (`gtk-xft-dpi` -1) Nacre sets 96 dpi, else WebKit gives every view after the first a NaN zoom (blank page).
|
||||
- D-043 — 2026-11-13 — Local media and WebKit's sandbox: the web process sandbox (bwrap) has no /home, so GStreamer can't read file:// media. Nacre adds the XDG user folders that exist (Downloads, Videos, Music, Pictures, Desktop, Documents; never the home folder itself) read-only with `WebContext::add_path_to_sandbox` before the first web process, plus `tests/smoke/pages` read-only only when `NACRE_SCRIPT` is set (`engine::host::media_dirs`). file:// media elsewhere doesn't play. — Chromium plays local files; all of $HOME would let a web process read ~/.ssh — orchestrator (option A), 2026-11-13 — S050/S051 media and downloads, any sandbox change
|
||||
|
|
|
|||
|
|
@ -69,6 +69,27 @@ fn webext_dir() -> Option<std::path::PathBuf> {
|
|||
}
|
||||
|
||||
/// Attach or detach the ad blocker filter for a view about to show a page of `host`; the Images filter always.
|
||||
/// A navigation found to be the tab's own, for the browser to decide.
|
||||
struct Navigation {
|
||||
web: webkit::WebView,
|
||||
hub: Rc<Hub>,
|
||||
filters: Rc<RefCell<Vec<webkit::UserContentFilter>>>,
|
||||
images: Rc<RefCell<Option<webkit::UserContentFilter>>>,
|
||||
id: ViewId,
|
||||
url: Url,
|
||||
redirect: bool,
|
||||
reloadable: bool,
|
||||
decision: webkit::PolicyDecision,
|
||||
}
|
||||
|
||||
impl Navigation {
|
||||
fn decide(self) {
|
||||
// The filter is set for the page's site before it loads (paused sites go without).
|
||||
attach_filters(&self.web, &self.hub, &self.filters, &self.images, self.url.host_str().unwrap_or(""));
|
||||
self.hub.push(Event::Navigation(self.id, NavigationRequest::new(self.url, self.redirect, self.reloadable, self.decision)));
|
||||
}
|
||||
}
|
||||
|
||||
fn attach_filters(web: &webkit::WebView, hub: &Hub, filters: &RefCell<Vec<webkit::UserContentFilter>>, images: &RefCell<Option<webkit::UserContentFilter>>, host: &str) {
|
||||
let Some(ucm) = web.user_content_manager() else { return };
|
||||
ucm.remove_all_filters();
|
||||
|
|
@ -130,8 +151,9 @@ impl Engine {
|
|||
}
|
||||
context.set_cache_model(match env("NACRE_WK_CACHE_MODEL").as_deref() {
|
||||
Some("browser") => webkit::CacheModel::WebBrowser,
|
||||
Some("docbrowser") => webkit::CacheModel::DocumentBrowser,
|
||||
_ => webkit::CacheModel::DocumentViewer,
|
||||
Some("viewer") => webkit::CacheModel::DocumentViewer,
|
||||
// DocumentViewer has no HTTP disk cache (D-040).
|
||||
_ => webkit::CacheModel::DocumentBrowser,
|
||||
});
|
||||
let settings = webkit::Settings::new();
|
||||
settings.set_enable_developer_extras(setup.developer_extras || env("NACRE_WK_INSPECTOR").is_some());
|
||||
|
|
@ -377,7 +399,7 @@ impl Engine {
|
|||
settings.set_user_agent(Some(ua));
|
||||
return changed;
|
||||
}
|
||||
// A copy of the shared settings with only the user agent changed.
|
||||
// A copy of the shared settings with only the user agent (and its quirks) changed.
|
||||
let copy = webkit::Settings::new();
|
||||
for spec in self.settings.list_properties().iter() {
|
||||
let flags = spec.flags();
|
||||
|
|
@ -385,6 +407,8 @@ impl Engine {
|
|||
copy.set_property_from_value(spec.name(), &self.settings.property_value(spec.name()));
|
||||
}
|
||||
}
|
||||
// WebKit's own site quirks put a Safari user agent on Google's requests over any set one.
|
||||
copy.set_enable_site_specific_quirks(false);
|
||||
copy.set_user_agent(Some(ua));
|
||||
view.web.set_settings(©);
|
||||
},
|
||||
|
|
@ -510,7 +534,10 @@ impl Engine {
|
|||
let hub = self.hub.clone();
|
||||
web.connect_favicon_notify(move |_| hub.push(Event::Favicon(id)));
|
||||
let hub = self.hub.clone();
|
||||
let provisional = Rc::new(std::cell::Cell::new(false));
|
||||
let tab_loading = provisional.clone();
|
||||
web.connect_load_changed(move |w, event| {
|
||||
tab_loading.set(matches!(event, webkit::LoadEvent::Started | webkit::LoadEvent::Redirected));
|
||||
let state = match event {
|
||||
webkit::LoadEvent::Started => LoadState::Started,
|
||||
webkit::LoadEvent::Committed => LoadState::Committed,
|
||||
|
|
@ -591,12 +618,37 @@ impl Engine {
|
|||
if action.frame_name().is_some() {
|
||||
return false;
|
||||
}
|
||||
let Some(url) = action.request().and_then(|r| r.uri()).and_then(|u| Url::parse(&u).ok()) else { return false };
|
||||
// The filter is set for the page's site before it loads (paused sites go without).
|
||||
attach_filters(web, &hub, &filters, &images, url.host_str().unwrap_or(""));
|
||||
let get = action.request().and_then(|r| r.http_method()).is_none_or(|m| m.eq_ignore_ascii_case("GET"));
|
||||
let Some(request) = action.request() else { return false };
|
||||
let Some(uri) = request.uri() else { return false };
|
||||
let Ok(url) = Url::parse(&uri) else { return false };
|
||||
let get = request.http_method().is_none_or(|m| m.eq_ignore_ascii_case("GET"));
|
||||
let reloadable = get && action.navigation_type() != webkit::NavigationType::BackForward;
|
||||
hub.push(Event::Navigation(id, NavigationRequest::new(url, action.is_redirect(), reloadable, decision.clone())));
|
||||
let redirect = action.is_redirect();
|
||||
let tab = Navigation { web: web.clone(), hub: hub.clone(), filters: filters.clone(), images: images.clone(), id, url, redirect, reloadable, decision: decision.clone() };
|
||||
// WebKit's GTK API doesn't say which frame a navigation is for, and the browser's decisions (HTTPS-only,
|
||||
// the strip, the user agent reload) load the new URL in the tab: only the tab's own loads go to it.
|
||||
// The browser's own loads come without headers; a redirect is the tab's while its load is provisional
|
||||
// (frames load after the page commits); anything else is a frame's when a frame element has that
|
||||
// URL. Not caught: a link followed inside a frame.
|
||||
let from_browser = request.http_headers().is_none_or(|h| {
|
||||
let mut any = false;
|
||||
h.foreach(|_, _| any = true);
|
||||
!any
|
||||
});
|
||||
if from_browser {
|
||||
tab.decide();
|
||||
} else if redirect {
|
||||
if !provisional.get() {
|
||||
return false;
|
||||
}
|
||||
tab.decide();
|
||||
} else {
|
||||
let script = format!("(() => {{ const u = {}; const has = d => [...d.querySelectorAll('iframe, frame')].some(f => {{ if (f.src === u) return true; try {{ return !!f.contentDocument && has(f.contentDocument); }} catch (e) {{ return false; }} }}); return has(document); }})()", serde_json::to_string(uri.as_str()).unwrap_or_default());
|
||||
View::new(id, web.clone()).evaluate_javascript(script, move |frame| match frame {
|
||||
Ok(serde_json::Value::Bool(true)) => tab.decision.use_(),
|
||||
_ => tab.decide(),
|
||||
});
|
||||
}
|
||||
true
|
||||
},
|
||||
webkit::PolicyDecisionType::Response => {
|
||||
|
|
|
|||
|
|
@ -53,6 +53,14 @@ assert location.href === "http://localhost:8767/echo?local"
|
|||
open http://127.0.0.1:8766/echo?utm_source=news&id=3&fbclid=abc&utm_medium=mail
|
||||
waitfor 20 document.title === "Echo id=3"
|
||||
assert location.search === "?id=3"
|
||||
# The page's own script navigation is stripped too (the browser asks the page whether a frame has that URL first).
|
||||
js location.href = "http://127.0.0.1:8766/echo?utm_source=a&id=5"
|
||||
waitfor 20 document.title === "Echo id=5"
|
||||
# A frame's load stays in its frame (S050: it used to take over the tab with the frame's URL).
|
||||
open @PAGES@/frames.html
|
||||
waitfor 20 document.title === "Frames"
|
||||
wait 3
|
||||
assert location.href.endsWith("/frames.html")
|
||||
set /privacy/strip_params false
|
||||
open http://127.0.0.1:8766/echo?id=4&gclid=x
|
||||
waitfor 20 document.title === "Echo id=4&gclid=x"
|
||||
|
|
|
|||
3
tests/smoke/pages/frames.html
Normal file
3
tests/smoke/pages/frames.html
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<!doctype html><title>Frames</title>
|
||||
<p>A page with an unnamed iframe (S050: frame navigations must not take over the tab).</p>
|
||||
<iframe id="f" src="http://127.0.0.1:8767/echo?frame&utm_source=x"></iframe>
|
||||
|
|
@ -10,21 +10,22 @@ open @PAGES@/fingerprint.html
|
|||
waitfor 30 document.title === "FP done"
|
||||
save fp-off JSON.stringify(window.fp, null, 1)
|
||||
shot fp-off
|
||||
# The engine's own values: Servo's platform and appVersion, the real core count, the real screen.
|
||||
assert window.fp.platform === "Linux" && window.fp.appVersion === "4.0" && window.fp.webgl.vendor === "Mozilla/Servo" && window.fp.languages.length === 1
|
||||
# The engine's own values (WebKit since S050): its platform and vendor, the real core count, the real screen.
|
||||
assert window.fp.platform === "Linux x86_64" && window.fp.vendor === "Apple Computer, Inc." && window.fp.webgl.vendor === "WebKit" && window.fp.languages.length === 1
|
||||
assert window.fp.screen !== "0 0 0 0 24 24"
|
||||
set /privacy/mode true
|
||||
wait 1
|
||||
# The real values go to the next load in the URL's hash (Servo doesn't keep window.name).
|
||||
# The real values go to the next load in the URL's hash (kept from the Servo era: window.name isn't relied on).
|
||||
js location.href = "?on#" + encodeURIComponent(JSON.stringify({ canvas: window.fp.canvas, audio: window.fp.audio }))
|
||||
wait 1
|
||||
waitfor 30 document.title === "FP done"
|
||||
save fp-on JSON.stringify(window.fp, null, 1)
|
||||
shot fp-on
|
||||
js window.off = JSON.parse(decodeURIComponent(location.hash.slice(1))); JSON.stringify(window.off)
|
||||
# Common values, consistent with the Firefox user agent.
|
||||
assert window.fp.hardwareConcurrency === 8 && window.fp.platform === "Linux x86_64" && window.fp.appVersion === "5.0 (X11)"
|
||||
assert window.fp.webgl.vendor === "Mozilla" && window.fp.webgl.renderer === "Mozilla" && window.fp.webgl.unmaskedVendor === "Mozilla" && window.fp.webgl.unmaskedRenderer === "Mozilla"
|
||||
# Common values, consistent with the user agent (WebKit's own since S050: appVersion is the user agent after "Mozilla/").
|
||||
assert window.fp.hardwareConcurrency === 8 && window.fp.platform === "Linux x86_64" && window.fp.appVersion === window.fp.userAgent.slice(8)
|
||||
# WebGL: the real GPU is hidden behind the masked names (S047).
|
||||
assert window.fp.webgl.vendor === "WebKit" && window.fp.webgl.renderer === "WebKit WebGL" && window.fp.webgl.unmaskedVendor === "WebKit" && window.fp.webgl.unmaskedRenderer === "WebKit WebGL"
|
||||
# Desktop Firefox: no touch points, touch events can't be created; the language list as Firefox sends it.
|
||||
assert window.fp.touchEvents === "function NotSupportedError" && window.fp.maxTouchPoints === 0
|
||||
assert window.fp.languages.length === 2 && window.fp.languages[0] === window.fp.language && window.fp.language.startsWith(window.fp.languages[1] + "-")
|
||||
|
|
|
|||
Loading…
Reference in a new issue