Google sign-in loads again: the Firefox user agent swap is removed (D-053); packaging docs (D-054), S054 interaction checks

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-25 00:09:02 -06:00
commit beb2036450
15 changed files with 24 additions and 110 deletions

View file

@ -29,6 +29,7 @@ src/ui/ egui chrome, menus, dialogs, widgets, pages/* (every nacre:// pa
assets/ bundled resources
docs/ DESIGN, FEATURES, REVIEW, HANDOFF, UI-BRIEF, ui-reference/, PROGRESS, DECISIONS
Plans/ INDEX.md, _TEMPLATE.md, one folder per category
install.sh builds and installs the Arch package (packaging/arch/PKGBUILD, D-054); removes target/ afterwards
releases/ release files (git-ignored; hub-release-sync uploads them)
```
Never modify: `~/Documents/Apps/Nacre` (the original Python Nacre, reference only) and `~/Projects/Nacre-rust` (older repo, not a source). `target/` is build output.

View file

@ -14,8 +14,8 @@ Supersedes the Servo-era site work of S041 for the engine part.
## Steps
- [x] Site list: YouTube (home, watch, search, Shorts), Reddit, Discord web, GitHub, Wikipedia, DuckDuckGo, Google search + sign-in page, a news site, Twitch, a maps site; size 1280x800.
- [x] Hidden Nacre shots (`heavy-web.txt`, `site-doctor.txt` extended) + Chromium pane shots at the same width; Read each pair; list differences in `docs/engine/site-pass-webkit.md`.
- [ ] Fix Nacre-side causes (UA, scripts, chrome overlap, input); WebKit engine differences listed, not patched.
- [ ] Interaction checks per site: video plays/seeks/full screen, sign-in form typing, infinite scroll, context menu, pop-up sign-in windows.
- [x] Fix Nacre-side causes (UA, scripts, chrome overlap, input); WebKit engine differences listed, not patched.
- [x] Interaction checks per site: video plays/seeks/full screen, sign-in form typing, infinite scroll, context menu, pop-up sign-in windows.
- [ ] GPU path (D-035 unproven): if the user is awake and asks, a `SMOKE_VISIBLE=1` run of the watch page with stats (60 fps video under the overlay, dmabuf path); else write it as open in PROGRESS.
- [ ] PROGRESS entry, INDEX line, tracker, commit `S054: …`, push.

View file

@ -56,3 +56,5 @@
- D-050 — 2026-11-18 — Amends D-022: a custom download manager is a user-given name + loopback port (several allowed), listed with the built-in managers; the endpoint is `http://127.0.0.1:<port>/` with D-022's body, ping and fallback. S036 superseded by S065. — User's choice. — S065
- D-051 — 2026-11-18 — Pop-ups and frames: a site not asked about gets pop-ups only from a click or key press (Chromium's rule); Allow/Block per site as before. Nacre's menu shows only when the page didn't cancel `contextmenu` (the bridge script's answer decides, not WebKit's signal). A script navigation not proven to be a frame's is never rewritten into a load in the tab; the browser reloads it only once the tab itself starts loading it. — WebKit asks for menus on cancelled right clicks after its first menu; ad frames took tabs over through Nacre's rewrites. — S061 — later pop-up, menu or navigation-policy work
- D-052 — 2026-11-18 — Saved passwords without a master password are guarded by the Linux account password of the user running Nacre (checked by the system, so a changed login password works at once), never by a click; with a master password, the master password guards them. Mechanism (S067): PAM's `login` service in-process for the `getuid` user (as swaylock does: unprivileged, pam_unix's setuid helper, no root, no new /etc file), libpam loaded at run time (`src/auth.rs`), off the main thread; no polkit. pam_faillock counts these tries with every login (deny 3 in 15 min → 10 min lock), so Nacre allows at most 2 wrong tries per faillock window (read from faillock.conf, at least a minute) and says how long to wait. Without libpam the gate says why and offers a master password. Tests use `NACRE_TEST_ACCOUNT_PASSWORD` (only with `NACRE_SCRIPT`). — User: "it should ask for a password from the user like other browsers". — S067
- D-053 — 2026-11-25 — Google sign-in uses Nacre's normal user agent; the Firefox swap for accounts.google.com (setting `privacy.google_signin`, per-view settings copy, page script) is removed. — With WebKitGTK 2.54.3 a view given the copied settings never commits the page (blank tab); WebKit's own site quirks cover Google and the page loads with the Safari agent. Signing in past the email step is not verified. — packaging session
- D-054 — 2026-11-25 — Installing is an Arch package: `./install.sh` builds the last commit with `packaging/arch/PKGBUILD` in a temporary folder and installs it with pacman and all dependencies, then deletes the build and `target/`. `./install.sh --uninstall` = `pacman -Rs nacre`. Supersedes "packaging later" (D-001) for this PC; AppImage/tar.gz releases are still open. — User's request, 2026-11-24

View file

@ -87,7 +87,7 @@ written.
| Send Do Not Track and GPC | verified on Servo S023, re-verify on WebKit (privacy-net.txt): `DNT: 1` + `Sec-GPC: 1` on every request (web process extension since S049), plus the JS properties |
| Remove tracking parameters | verified on Servo S007, re-verify on WebKit (net-privacy.txt: utm_*/fbclid removed, other parameters kept, off keeps all) |
| Block third-party cookies | verified on Servo S023, re-verify on WebKit (privacy-net.txt): cross-site requests send and store no cookies (web process extension since S049), same-site subdomains keep theirs, on in privacy mode. `document.cookie` in a cross-site frame: empty (S024, script layer) |
| Google sign-in quirk | written (UA switch + JS) |
| Google sign-in quirk | removed (D-053): WebKit's own site quirks cover Google; the Firefox user agent swap stopped the page from loading |
| Sites where ad blocking is paused | verified on Servo S007, re-verify on WebKit (net-adblock.txt), persisted S008 (site-memory*.txt) |
| Remote debugging, user agent | written |

View file

@ -559,6 +559,14 @@ Later: S010 list: user checks the Discord icon with their own client (the Discor
- Later: on "ask again" after a tab switch the field isn't focused (the address bar keeps the keyboard).
- Note: without libpam, setting a master password from the gate is offered as the plan says; whoever sits at the machine can do that (no PAM = nothing to check against).
## Packaging: installs like a package; Google sign-in (2026-11-25)
- The repo never had an installer. New: `install.sh`, `packaging/arch/PKGBUILD` (D-054), `assets/dev.nacre.Nacre.{desktop,svg}`. Runtime dependencies include gst-plugins-bad/good/libav (video parsers).
- Found by `site-interact.txt` on the package: accounts.google.com never loaded (blank tab) with WebKitGTK 2.54.3. Cause: the Firefox user agent swap; removed (D-053).
- S054's old UI crash in the Discord step did not happen in three runs (one had Google failing, one a script race; the last was green); no core dumps.
- Verified: PKGBUILD built in a clean folder, `launch`, `basics`, `input` exit 0 with the packaged layout (before the Google fix); `site-interact.txt` exit 0 after it; `privacy-net.txt` exit 0 twice (first run: the "Open anyway" click missed once, not explained); `cargo test` 97 + webext 1.
- `site-interact.txt`: waits for the closed pop-up tab before opening Discord (race).
- Not done: Google sign-in past the email step (real account); GPU path of S054 (visible run); `heavy-web.txt` not rerun; import of the Python Nacre's passwords, history and bookmarks.
## Later
- A link followed inside a frame still goes through the tab's navigation policy (WebKit's GTK API has no frame info; S050).
- file:// media outside the XDG user folders doesn't play (WebKit sandbox, D-043).
@ -569,7 +577,7 @@ Later: S010 list: user checks the Discord icon with their own client (the Discor
- YouTube's result list lays out at zero size; CSS mask-image icons paint as squares (Servo layout, S006).
- System accent: watch caelestia scheme.json / the portal `accent-color` and restyle live (R1-11).
- Reader mode, split view, translate, real gamepad rumble (D-002: not planned for now).
- Packaging and first release (D-001: plan when the user asks).
- AppImage / tar.gz release (D-001, D-054).
- Shortcut icons: a favicon cache by host (today only open tabs' favicons show).
- Interface size above ~110 % on a narrow (772 px) window clips wide segmented rows at the right (R1-21 visible run).
- A test run (fresh profile, internet) moves ~200 KB before the first page and looks up the update host

View file

@ -1403,9 +1403,7 @@ impl App {
// Maybe a frame's: let it load where it was going; if it turns out to be the tab's own load, it is
// loaded again from the browser then (`redo`). An ad frame never takes the tab over this way.
if request.maybe_frame {
let quirk = self.hub.config.borrow().wants_ua_quirk(&url);
let ua_change = self.engine.as_ref().is_some_and(|e| e.own_user_agent(&view) != quirk);
if !matches!(outcome, crate::net::policy::Outcome::Allow) || ua_change && request.reloadable {
if !matches!(outcome, crate::net::policy::Outcome::Allow) {
tab.redo = Some(url);
}
return request.allow();
@ -1420,17 +1418,7 @@ impl App {
request.deny();
view.load(&clean);
},
crate::net::policy::Outcome::Allow => {
let quirk = self.hub.config.borrow().wants_ua_quirk(&url);
let changed = self.engine.as_ref().is_some_and(|e| e.set_view_user_agent(&view, quirk.then_some(crate::inject::FIREFOX_UA)));
// The request was made with the old user agent: load it again with the new one.
if changed && request.reloadable {
request.deny();
view.load(&url);
} else {
request.allow();
}
},
crate::net::policy::Outcome::Allow => request.allow(),
}
},
"about" | "data" | "blob" | "file" | "javascript" => request.allow(),
@ -2560,7 +2548,6 @@ impl App {
|| old.privacy.block_third_party != new.privacy.block_third_party
|| old.privacy.dnt != new.privacy.dnt
|| old.privacy.save_data != new.privacy.save_data
|| old.privacy.google_signin != new.privacy.google_signin
|| old.web.force_dark != new.web.force_dark
|| old.web.smooth_scroll != new.web.smooth_scroll
|| old.web.preload != new.web.preload

View file

@ -495,7 +495,6 @@ impl App {
youtube_ads: s.adblock.enabled && s.adblock.youtube,
autofill: s.vault.enabled,
spell: s.spell.enabled,
google_signin: s.privacy.google_signin,
};
let mut sources = inject::page_scripts(&options);
let scripts = self.shared.scripts.borrow();

View file

@ -86,7 +86,6 @@ struct Navigation {
id: ViewId,
url: Url,
redirect: bool,
reloadable: bool,
decision: webkit::PolicyDecision,
}
@ -94,7 +93,7 @@ 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.maybe_frame, self.decision)));
self.hub.push(Event::Navigation(self.id, NavigationRequest::new(self.url, self.redirect, self.maybe_frame, self.decision)));
}
}
@ -427,43 +426,6 @@ impl Engine {
self.context.set_preferred_languages(&refs);
}
/// A user agent for one view only (`None`: back to the shared settings). Google's sign-in refuses browsers it
/// doesn't know, so its pages get Firefox's (`HubConfig::wants_ua_quirk`). Whether the view's agent changed: a
/// navigation already on its way still carries the old one.
/// The view has a user agent of its own (a site quirk), not the shared one.
pub fn own_user_agent(&self, view: &View) -> bool {
webkit::prelude::WebViewExt::settings(&view.web).as_ref() != Some(&self.settings)
}
pub fn set_view_user_agent(&self, view: &View, ua: Option<&str>) -> bool {
let current = webkit::prelude::WebViewExt::settings(&view.web);
let own = current.as_ref() != Some(&self.settings);
match ua {
None if own => view.web.set_settings(&self.settings),
None => return false,
Some(ua) => {
if own && let Some(settings) = &current {
let changed = settings.user_agent().as_deref() != Some(ua);
settings.set_user_agent(Some(ua));
return 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();
if flags.contains(glib::ParamFlags::READWRITE) && !flags.intersects(glib::ParamFlags::CONSTRUCT_ONLY) {
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(&copy);
},
}
true
}
/// The colour a page shows before it paints (no white flash in dark mode).
pub fn set_dark_background(&self, dark: bool) {
let shade = if dark { 0.1 } else { 1.0 };
@ -752,13 +714,11 @@ impl Engine {
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;
let redirect = action.is_redirect();
let scripted = !matches!(action.navigation_type(), webkit::NavigationType::LinkClicked | webkit::NavigationType::FormSubmitted | webkit::NavigationType::FormResubmitted | webkit::NavigationType::BackForward | webkit::NavigationType::Reload);
let mut tab = Navigation { web: web.clone(), hub: hub.clone(), filters: filters.clone(), images: images.clone(), id, url, redirect, reloadable, maybe_frame: false, decision: decision.clone() };
let mut tab = Navigation { web: web.clone(), hub: hub.clone(), filters: filters.clone(), images: images.clone(), id, url, redirect, maybe_frame: false, 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 strip) 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.

View file

@ -181,8 +181,6 @@ pub struct NavigationRequest {
pub url: Url,
/// The server sent the page here (an HTTP redirect), rather than a link or the address bar.
pub redirect: bool,
/// A plain GET that isn't a back/forward step: denying it and loading the URL again gives the same page.
pub reloadable: bool,
/// Started by a script and not found as a frame of the page: it may still be a frame's (one inside a
/// cross-site frame, an ad's), so Nacre doesn't load another URL in the tab for it (S061).
pub maybe_frame: bool,
@ -190,8 +188,8 @@ pub struct NavigationRequest {
}
impl NavigationRequest {
pub(crate) fn new(url: Url, redirect: bool, reloadable: bool, maybe_frame: bool, decision: webkit::PolicyDecision) -> Self {
NavigationRequest { url, redirect, reloadable, maybe_frame, decision }
pub(crate) fn new(url: Url, redirect: bool, maybe_frame: bool, decision: webkit::PolicyDecision) -> Self {
NavigationRequest { url, redirect, maybe_frame, decision }
}
pub fn allow(self) {
self.decision.use_();

View file

@ -51,7 +51,6 @@ pub struct Options<'a> {
pub youtube_ads: bool,
pub autofill: bool,
pub spell: bool,
pub google_signin: bool,
}
/// All scripts, in the order they are added to the user content manager.
@ -90,9 +89,6 @@ pub fn page_scripts(o: &Options) -> Vec<String> {
if o.spell {
modules.push(SPELL_JS.to_owned());
}
if o.google_signin {
modules.push(GOOGLE_SIGNIN_JS.to_owned());
}
let mut combined = String::from("(() => {\n");
combined.push_str(&BRIDGE_JS.replace("__TOKEN__", &util::js_string(o.token)));
for module in modules {
@ -677,17 +673,6 @@ const SPELL_JS: &str = r#"(() => { if (!window.__nacre || window.__nacre.spell)
};
})();"#;
/// Google refuses sign-in from browsers it doesn't know; on its sign-in pages Nacre looks like
/// Firefox (the user agent pref is switched by the browser; this covers the JavaScript side).
const GOOGLE_SIGNIN_JS: &str = r#"(() => { if (!/(^|\.)accounts\.google\.com$/.test(location.hostname)) return;
const ua = 'Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0';
try { Object.defineProperty(Navigator.prototype, 'userAgent', { get: () => ua, configurable: true });
Object.defineProperty(Navigator.prototype, 'appVersion', { get: () => '5.0 (X11)', configurable: true });
Object.defineProperty(Navigator.prototype, 'vendor', { get: () => '', configurable: true }); } catch (e) {} })();"#;
/// The Firefox user agent used on Google's sign-in pages.
pub const FIREFOX_UA: &str = "Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0";
/// Small helpers for browser -> page calls.
pub fn call(path: &str, args: &[Value]) -> String {
let args: Vec<String> = args.iter().map(Value::to_string).collect();
@ -734,7 +719,7 @@ mod tests {
assert!(js.contains(r#"const SEED = "se\"ed", NAV = {"platform":"Linux x86_64","oscpu":"Linux x86_64","appVersion":"5.0 (X11)"}, LANGS = ["en-US","en"], PAUSED = ["example.com","a\"b"];"#));
assert!(privacy_script("s", "Custom agent", &[], &[]).contains("NAV = null, LANGS = [], PAUSED = [];"));
// Off by default; cookie-blocking module only with blocking on.
let mut o = Options { token: "t", privacy_mode: false, seed: "s", user_agent: "", privacy_paused: &[], languages: &[], block_third_party: false, dnt: false, force_dark: false, smooth_scroll: false, preload: false, save_data: false, cosmetic: false, youtube_ads: false, autofill: false, spell: false, google_signin: false };
let mut o = Options { token: "t", privacy_mode: false, seed: "s", user_agent: "", privacy_paused: &[], languages: &[], block_third_party: false, dnt: false, force_dark: false, smooth_scroll: false, preload: false, save_data: false, cosmetic: false, youtube_ads: false, autofill: false, spell: false };
assert!(!page_scripts(&o)[0].contains("__nacrePriv") && !page_scripts(&o)[0].contains("'cookie'"));
o.privacy_mode = true;
o.block_third_party = true;

View file

@ -17,7 +17,6 @@ pub struct HubConfig {
pub https_only: bool,
pub https_exceptions: Vec<String>,
pub strip_params: bool,
pub google_signin: bool,
/// Images permission: blocked unless a site says otherwise, and the sites that differ (host, blocked).
pub images_block_default: bool,
pub images_sites: Vec<(String, bool)>,
@ -40,18 +39,12 @@ impl HubConfig {
https_only: settings.privacy.https_only,
https_exceptions: settings.privacy.https_exceptions.clone(),
strip_params: settings.privacy.strip_params,
google_signin: settings.privacy.google_signin,
images_block_default: permissions.answer(settings, "", Kind::Images) == Answer::Block,
images_sites: permissions.all().into_iter().filter(|(_, kind, _)| *kind == Kind::Images).map(|(host, _, decision)| (host, decision == Decision::Block)).collect(),
user_agent: user_agent.to_owned(),
http_allowed,
}
}
/// Whether this URL is Google's sign-in page and the Firefox user agent should be used for it.
pub fn wants_ua_quirk(&self, url: &Url) -> bool {
self.google_signin && url.host_str().is_some_and(|h| h == "accounts.google.com")
}
}
/// What to do with a page the tab is about to open.
@ -169,11 +162,4 @@ mod tests {
assert_eq!(rules[1]["trigger"]["if-domain"], serde_json::json!(["b.example"]));
assert_eq!(rules[1]["action"]["type"], "ignore-previous-rules");
}
#[test]
fn google_quirk_only_on_sign_in() {
let config = HubConfig { google_signin: true, ..Default::default() };
assert!(config.wants_ua_quirk(&Url::parse("https://accounts.google.com/x").unwrap()));
assert!(!config.wants_ua_quirk(&Url::parse("https://www.google.com/").unwrap()));
}
}

View file

@ -241,8 +241,6 @@ pub struct Privacy {
pub doh: DohProvider,
pub doh_custom: String,
pub save_data: bool,
/// Look like Firefox on accounts.google.com so Google lets you sign in.
pub google_signin: bool,
/// Default answer per permission (missing = ask). Keys are `store::permissions::Kind` names.
pub permission_defaults: BTreeMap<String, PermissionDefault>,
/// Clear these when the browser closes: history, cookies, cache, downloads.
@ -263,7 +261,6 @@ impl Default for Privacy {
doh: DohProvider::Off,
doh_custom: String::new(),
save_data: false,
google_signin: true,
permission_defaults: BTreeMap::new(),
clear_on_exit: Vec::new(),
}

View file

@ -783,7 +783,6 @@ fn privacy(ui: &mut Ui, f: &mut Frame, s: &mut Settings) {
switch_row(ui, "Send Do Not Track and Global Privacy Control", "Asks every site not to sell or share your data (DNT and Sec-GPC headers)", &mut s.privacy.dnt);
switch_row(ui, "Remove tracking parameters", "Strips utm_, fbclid, gclid and similar from links before they load", &mut s.privacy.strip_params);
switch_row(ui, "Block third-party cookies", "Sites inside a page (ads, trackers) can't send or store cookies; always on in privacy mode", &mut s.privacy.block_third_party);
switch_row(ui, "Google sign-in", "Looks like Firefox on accounts.google.com so Google lets you sign in", &mut s.privacy.google_signin);
});
section(ui, "Site data");
card(ui, |ui| {

View file

@ -93,13 +93,6 @@ waitfor 20 document.title === "Echo pm"
assert navigator.hardwareConcurrency === 8 && navigator.platform === "Linux x86_64" && navigator.appVersion === navigator.userAgent.slice(8)
set /privacy/mode_off []
set /privacy/mode false
# Google sign-in (S050): Firefox's user agent for accounts.google.com's view only (the stub resolves it here).
set /privacy/google_signin true
wait 1
open http://accounts.google.com:8767/echo?ua
waitfor 20 document.title === "Echo ua"
open http://127.0.0.1:8767/echo?ua2
waitfor 20 document.title === "Echo ua2"
# Do Not Track off: the headers stop.
set /privacy/dnt false
set /privacy/save_data false
@ -121,8 +114,6 @@ assert window.pick("off", "cdn.other.test").length === 2 && window.pick("off", "
assert window.reqs.some(r => r.path === "/note?tag=jon&seen=") && window.reqs.some(r => r.path.startsWith("/note?tag=joff&seen=") && r.path.includes("fp%3D1"))
# Accept-Language: Firefox's list in privacy mode (S024), WebKit's weights for the same list otherwise (S050).
assert window.reqs.filter(r => r.path === "/echo?pm").every(r => r.lang === navigator.language + "," + navigator.language.split("-")[0] + ";q=0.5") && window.reqs.filter(r => r.path === "/echo?nodnt").every(r => r.lang === navigator.language + "," + navigator.language.split("-")[0] + ";q=0.90")
# The user agent quirk: on the sign-in page's requests, not after leaving it.
assert window.reqs.some(r => r.path === "/echo?ua") && window.reqs.filter(r => r.path === "/echo?ua").every(r => r.ua.includes("Firefox/")) && window.reqs.filter(r => r.path === "/echo?ua2").every(r => !r.ua.includes("Firefox/"))
# Privacy mode: blocked again.
assert window.pick("mode", "cdn.other.test").length === 2 && window.pick("mode", "cdn.other.test").every(r => r.cookie === null)
status done

View file

@ -70,6 +70,7 @@ wait 10
expect /tab_count 2
shot reddit-popup
cmd close_tab
waitstatus 10 /tab_count 1
open https://discord.com/login
waitfor 90 document.readyState === "complete"
wait 40