S051: profile folder nacre-browser, cookies sealed from WebKit's tmpfs store, site data, tab audio and mute on WebKit

- paths: one-time move from nacre-servo, Servo engine files deleted
- store::cookies: libsoup SQLite on tmpfs, sealed 60 s after a change and at quit
- clear data time range, site info cookie/data count, media-audio and site-data smokes
- D-047: details and MPRIS outcome (WebKit's own player, Nacre none)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-14 08:13:11 -06:00
commit 340c034be5
9 changed files with 58 additions and 16 deletions

View file

@ -75,6 +75,7 @@ Never modify: `~/Documents/Apps/Nacre` (the original Python Nacre, reference onl
| `tools/smoke.sh tests/smoke/privacy-mode.txt` (+ `SMOKE_ARGS=--incognito … privacy-incognito.txt`) | privacy mode: `pages/fingerprint.html` read off/on, `fp-off.json`/`fp-on.json` + shots (offline); `privacy-net.txt` (needs `tests/smoke/net/server.py`) frame cookies, per-site pause, Accept-Language; `SMOKE_TIMEOUT=700 … coveryourtracks.txt` EFF's test off/on (internet, direct). Selftest `save <name> <js>` writes a JS string result to `<name>.json`; `SMOKE_ARGS` passes browser arguments | now (S024) |
| `python tools/icons.py` | rebuilds the icon font subset and `src/ui/icons.rs` from `tools/icons.txt` (needs fontTools and Arch's ttf-material-symbols-variable) | now (S015) |
| `tools/engine-test/run.sh chromium\|webkit` + `analyze.py` | engine comparison: one browser visible on DP-1, throwaway profile, sites from `sites.txt`, per-second RAM (PSS), CPU, GPU of the whole process tree into `docs/engine/runs/<engine>/samples.csv`; `webkit_shell.py` is the WebKitGTK 6.0 shell (needs `webkitgtk-6.0`); report `docs/engine/engine-comparison.md`. Never run two at once or alongside cargo | now |
| `python3 tests/smoke/net/server.py &` + `tools/smoke.sh tests/smoke/site-data.txt`; `tools/smoke.sh tests/smoke/media-audio.txt` | site info cookie/data count, Clear data time range (stored data kept, cookies always whole); WebKit `is-playing-audio` → tab audible, tab mute via `set_is_muted` (`pages/sound.html`, `?element` plays `tone.ogg` with Media Session metadata; WebKit's MPRIS player shows on the run's bus: `busctl --address=unix:path=$(cat <out>/session/runtime)/bus list`). Offline, hidden | now (S051) |
| `tools/smoke.sh tests/smoke/pip.txt` (+ `tools/hidden.sh tests/smoke/pip.txt <out> -- tests/smoke/pip-driver.sh`: `<out>/windows.json` PiP floating), `bindings.txt` (side buttons, middle click; hidden only), `ctxmenu.txt` (site menu vs Nacre's; hidden only), `pip-return.txt` (page input after PiP and back; hidden only), selftest `pick x y` (GTK's pick at a page point + view state), `python3 tests/smoke/net/server.py &` + `SMOKE_SIZE=1280x900 tools/smoke.sh tests/smoke/auth.txt`, `tests/smoke/visible-ui.txt` (by hand, header) | PiP moves the live view and back (offline); HTTP sign-in cancel + saved login (offline); visible: portal file chooser, notification, page full screen, Web Inspector (`dialogs.txt` now also checks dialog answers, context menu, leave page, permission bars, notifications count) | now (S048, S056) |
| `tools/hidden.sh <script> [outdir] [-- driver.sh]` | WebKit build hidden with a driver script: Xvfb → nested niri (`tools/nested-session.sh`), throwaway home, software GL, `NACRE_SCRIPT`; the driver gets `click`/`scroll` (`tools/wl-input`), `grab` (grim), `key`/`type` (wtype). Scripts in `tests/hidden/` (`basic.txt` offline; `web.txt` + `web-driver.sh` needs internet). Read the PNGs | now (S045) |
| appimagetool, wine + Inno Setup, VM "Windows 10" | packaging and Windows checks | see the user's global CLAUDE.md "Building" |

View file

@ -18,8 +18,8 @@ one MPRIS player.
- [x] Clear data / clear on exit / site info flyout on `WebsiteDataManager` (types + since-time) and `CookieManager::get_cookies`; drop the "Servo keeps no dates" text.
- [x] Incognito: ephemeral session, nothing written; check the throwaway home after a run.
- [x] Media: probe events + `is-playing-audio` → media state; mute via `set_is_muted`; check whether WebKitGTK publishes its own MPRIS player (`busctl --user list | grep mpris` in the nested bus) and apply D-039 (one player).
- [ ] Smoke: `cookies.txt` → `cookies-restart.txt` → `cookies-cleared.txt` with `SMOKE_KEYRING=1`, `cookies-nokeyring.txt`, `restore.txt`, `privacy-incognito.txt` green hidden; `grep -c` of a test cookie value in the home dir = 0.
- [ ] PROGRESS entry, INDEX line, tracker, commit `S051: …`, push.
- [x] Smoke: `cookies.txt` → `cookies-restart.txt` → `cookies-cleared.txt` with `SMOKE_KEYRING=1`, `cookies-nokeyring.txt`, `restore.txt`, `privacy-incognito.txt` green hidden; `grep -c` of a test cookie value in the home dir = 0.
- [x] PROGRESS entry, INDEX line, tracker, commit `S051: …`, push.
## End criteria
- Listed smokes exit 0; no plain cookie value anywhere under the throwaway home (grep); migration unit test green.
@ -31,5 +31,3 @@ one MPRIS player.
## Handoff (→ PROGRESS.md)
Migration behaviour, seal timing, MPRIS outcome (which player).
## Resume note (WIP)
- Boxes 1–5 done (site-data.txt, media-audio.txt new, green; WebKit publishes its own MPRIS player, Nacre has none: one player). Next: box 6 smokes, then docs + commit.

View file

@ -11,7 +11,7 @@ Dropped with Servo (D-032): S011, S029, S030, S032, S033, S037, S038.
- [x] [S053 — Remove Servo: vendor crates, gst-mse, Servo-only tests/tools, docs and texts](08%20WebKit%20engine/S053-servo-removal.md) · Sonnet high
- [x] [S057 — Small UI bugs: Customize panel scroll, site colour from the favicon, colour picker glyphs, beforeunload on quit](08%20WebKit%20engine/S057-small-ui-bugs.md) · Sonnet high
- [x] [S058 — Ads vanish before your eyes: Pie-style cookie shield removal animation (port of the original)](08%20WebKit%20engine/S058-ad-removal-animation.md) · Opus medium
- [ ] [S051 — Profile folder, sealed cookies, site data, incognito, media source](08%20WebKit%20engine/S051-profile-cookies-media.md) · Opus medium
- [x] [S051 — Profile folder, sealed cookies, site data, incognito, media source](08%20WebKit%20engine/S051-profile-cookies-media.md) · Opus medium
- [ ] [S052 — WebKit tuning defaults, background tabs, memory check](08%20WebKit%20engine/S052-tuning-defaults.md) · Sonnet high
- [ ] [S054 — Site pass on WebKit vs Chromium reference](08%20WebKit%20engine/S054-site-pass.md) · Opus high

View file

@ -50,3 +50,4 @@
- D-044 — 2026-11-13 — Supersedes D-034 while the user allows it: visible test runs on the user's niri session (DP-1) are allowed ("you can run real tests on my niri session"), for what hidden runs can't prove (GPU/dmabuf path, 60 fps, video playback); everything else stays hidden. A visible run never switches the user's workspace, maximizes or steals focus; if the window can't open that way it stays hidden. `tools/smoke.sh` no longer focuses a monitor and starts `SMOKE_VISIBLE=1` only when the user's niri config has the window rule `match app-id="^dev\.nacre\.Nacre$"; open-on-output "DP-1"; open-focused false` (added by the user, not by a session). — user via orchestrator, 2026-11-13 — every plan with visible checks
- D-045 — 2026-11-13 — Visible test runs on DP-1 may take focus or switch the workspace; amends D-044 (no focus rule needed). Use them where they prove more than hidden runs (real GPU, video, real input); hidden stays fine for quick checks. — user, 2026-11-13 ("just run it, I never cared about running it with focus") — every plan with GUI tests
- D-046 — 2026-11-13 — Developer tools are WebKit's Web Inspector: F12 opens it attached for the active web tab, `nacre://devtools` only lists tabs to inspect and switches remote inspection (127.0.0.1:6080); Nacre has no console or network page of its own. Pop-ups open as tabs next to their opener (related views). — S048 (plan let the session pick the smaller option) — later devtools, net-log and pop-up work
- D-047 — 2026-11-14 — S051 details of D-037/D-038/D-039: the sealed cookies are a JSON list read from and written into libsoup's `moz_cookies` SQLite table with rusqlite (synchronous, so the quit seal needs no main-loop round trip); the tmpfs folder name carries a hash of the data folder so a test home never meets the user's running browser; a database left by a crashed run wins over `cookies.bin`. Clear data deletes cookies whole whatever the time range (WebKit's libsoup store has no cookie dates). WebKitGTK publishes its own MPRIS player per playing web process; Nacre publishes none, so D-039's "one player" holds and S013 shrinks to what WebKit's player lacks (DesktopEntry is empty; several players when several web processes play). — S051 — S013, later cookie or MPRIS work

View file

@ -29,7 +29,7 @@ src/inject.rs JavaScript injected into pages (bridge, autofill, find, media
src/adblock.rs adblock-rust: lists, updates, cosmetic engine, conversion to WebKit content filters
webext/ web process extension (cdylib): headers, stand-ins, blocked counts (D-036)
src/discord.rs Discord Rich Presence over the local IPC socket
src/media.rs media state gathered from pages; feeds the media button, Discord, MPRIS later
src/media.rs media state gathered from pages; feeds the media button and Discord (MPRIS is WebKit's own)
src/importer.rs import from Chromium- and Firefox-family browsers
src/spell.rs spell check (spellbook + hunspell dictionaries)
src/perf.rs memory use, low-memory mode, energy saver, tab freezing and unloading
@ -118,17 +118,31 @@ extensions replaced by user scripts and styles, the context menu, the download m
## Media
Playback is WebKit's own (GStreamer) including Media Source Extensions; `tests/smoke/mse*.txt` are plain MSE tests.
Page media state (title, position, playing) is read by a page probe and `is-playing-audio`; `media.rs` feeds the media
button, Discord and MPRIS. Picture in picture moves the live web view into its own floating window and back (no reload).
Page media state (title, position, playing) is read by a page probe; WebKit's `is-playing-audio` marks a tab audible
(also Web Audio and frames), and tab/site mute is WebKit's `set_is_muted` (D-039). `media.rs` feeds the media button and
Discord. MPRIS: each web process playing an audible media element publishes WebKit's own player
(`org.mpris.MediaPlayer2.dev.nacre.Nacre.Sandboxed.instance-<n>`, page Media Session metadata, Identity `nacre`); Nacre
publishes none, so there is one player per playing web process (S051). Picture in picture moves the live web view into its own floating window and back (no reload).
The patched gst_mse of the Servo era is gone; `docs/engine/gst-mse-patches.md` is its record.
## Cookies at rest
`store::cookies` seals the cookie jar into `<data>/cookies.bin` with XChaCha20-Poly1305 (`vault::seal`, AAD
`nacre-cookies-v1`, magic `NACRECK1`); the 256-bit key lives in the OS keyring (crate `keyring` 3, service `Nacre`,
account `cookies <data folder>`). Without a keyring cookies live for the run only and nothing is written (Settings →
Privacy → Site data says so). A file that doesn't decrypt is moved to `cookies-unreadable-<time>.bin`. Incognito
writes nothing. Reconnecting this to WebKit's cookie manager (cookie DB on tmpfs, sealed on exit) is plan S051 (D-037).
`store::cookies` (D-019, D-037): WebKit's libsoup SQLite cookie store lives on tmpfs at
`$XDG_RUNTIME_DIR/nacre-<profile>-<hash of the data folder>/cookies.sqlite` (0700). At start Nacre decrypts
`<data>/cookies.bin` and writes that database (rusqlite, libsoup's `moz_cookies` table) before WebKit opens it
(`Setup::cookie_db`, `CookieManager::set_persistent_storage`); a database a crashed run left there is newer and kept.
It reads the database back and seals it (XChaCha20-Poly1305 via `vault::seal`, AAD `nacre-cookies-v1`, magic
`NACRECK1`, JSON `{"version":2,"cookies":[…]}`) 60 s after WebKit's `changed` and at quit, then removes the tmpfs folder.
Only persistent cookies are kept (as WebKit and the original). The key lives in the OS keyring (crate `keyring` 3,
service `Nacre`, account `cookies <data folder>`; the `nacre-servo` account's key is taken over after the folder move).
A Servo-era `cookies.bin` (Servo's JSON jar) is converted; one that doesn't decrypt or parse is moved to
`cookies-unreadable-<time>.bin`. No keyring or no `$XDG_RUNTIME_DIR`: cookies live in WebKit's memory for the run and
nothing is written (Settings → Privacy → Site data says so). Incognito is an ephemeral `NetworkSession`.
Clear browsing data uses `WebsiteDataManager::clear` with "modified in the last <range>"; WebKit's libsoup cookie store
keeps no dates and ignores the range, so cookies are always deleted whole (the page says so). Site info asks
`CookieManager::cookies(<page url>)` and `WebsiteDataManager::fetch` (local storage, databases, service workers,
offline files under the host's name).
## Privacy mode

View file

@ -446,6 +446,16 @@ Later: S010 list: user checks the Discord icon with their own client (the Discor
- Verified: `cargo test` 81 + webext 1; hidden `zap.txt` (new, `tests/smoke/pages/ads.html`) exit 0: overlay + badge mid-animation dark and light, slots closed, player and video box intact, Motion off = no overlay; `net-adblock.txt`, `crash-adblock.txt` exit 0. Visible DP-1 (Independent, AccuWeather, Speedtest, Guardian): Guardian header slot squished then collapsed (content moves up once, no flicker seen); pages render as before.
- Later: `hidden_elements` counts matches in frames and ones the page later removes (Guardian 27 vs 3 left in the top document); an element whose `__nz_gone` class a page re-render strips shows again (as the original).
## S051 — Profile folder, sealed cookies, site data, incognito, media source (2026-11-14)
- Profile folder `nacre-browser` (D-038): first start renames `nacre-servo` config/data/cache when only the old exists, then deletes Servo's `engine/` and `http-cache*` in each profile (stderr lines `profile: …`); `~/.config/nacre` untouched; unit test.
- Cookies (D-037, D-047): libsoup SQLite store on tmpfs `$XDG_RUNTIME_DIR/nacre-<profile>-<hash>/cookies.sqlite`, written from `cookies.bin` with rusqlite before WebKit opens it, sealed 60 s after `changed` (first change counts) and at quit, tmpfs folder removed after; crashed run's DB wins; Servo-era jar converted, unreadable moved aside; keyring key of the `nacre-servo` account taken over. Session cookies not kept.
- Clear data: time range on `WebsiteDataManager` for stored data and cache; cookies always whole (libsoup store has no dates; page text says so). Site info flyout: "N cookies, local storage…" (`CookieManager::cookies` + `fetch`).
- Incognito: ephemeral session (already); run writes only profiles.json and the shared filter cache.
- Media (D-039): `is-playing-audio` → `Tab.playing_audio` (audible also for Web Audio); site mute via `set_is_muted`, page `media.act mute` removed. WebKitGTK publishes its own MPRIS player per playing web process (`org.mpris.MediaPlayer2.dev.nacre.Nacre.Sandboxed.instance-N`, metadata from Media Session, Playing); Nacre publishes none → one player.
- Verified: `cargo test` 85 + webext 1; hidden exit 0: cookies → cookies-restart → cookies-cleared (SMOKE_KEYRING), cookies-nokeyring, launch → restore, privacy-incognito (WebGL vendor now WebKit's), site-data (new), media-audio (new), basics, privacy-net; `grep -rl nacre-test-session` in homes = 0.
- Not done: no visible run; PiP mute button still mutes the video element (page script); Servo jar conversion tested on a synthetic jar only.
- Later: WebKit's MPRIS has empty DesktopEntry and one player per web process (S013 to judge); `log::` still prints nothing.
## 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).

View file

@ -3,6 +3,7 @@
- Engine: WebKitGTK 6.0 in a GTK 4 host with the egui chrome. Servo removed (S053 build check pending).
- Works: tabs, navigation, pages, find, dialogs, menus, permissions, full screen, Web Inspector, real PiP, ad
blocker, network bridge, HTTPS-only, certificates, downloads, privacy switches, disk cache.
- Not yet on WebKit: cookies persisted/sealed and profile move (S051), background-tab rest and final tuning (S052).
- Next plan: S053 box 7 (resume), then S057, S058, S051, S052, S054.
- Cookies sealed on WebKit, profile folder `nacre-browser`, site data and MPRIS checked (S051).
- Not yet on WebKit: background-tab rest and final tuning (S052).
- Next plan: S052, then S054.
- Tests: `cargo test` 80; hidden smokes green as of S056.

View file

@ -453,6 +453,23 @@ mod tests {
let _ = std::fs::remove_dir_all(data);
}
#[test]
fn seals_a_minute_after_a_change() {
let (data, tmp) = (temp_dir("tick"), temp_dir("tick-tmp").join("nacre-Default"));
let key = [5u8; 32];
let mut cookies = open(&data, &tmp, key).unwrap();
rusqlite::Connection::open(cookies.db()).unwrap().execute("INSERT INTO moz_cookies VALUES (NULL, 'a', 'v', 'x.org', '/', ?1, NULL, 0, 0, 0)", [util::now() as i64 + 3600]).unwrap();
let start = Instant::now();
cookies.changed(start);
cookies.changed(start + Duration::from_secs(30));
cookies.tick(start + Duration::from_secs(59));
assert!(!data.join(FILE).exists(), "not sealed before a minute");
cookies.tick(start + SEAL_AFTER);
assert_eq!(CookieStore::open(&data, key).1.map(|c| c.len()), Some(1), "first change counts");
cookies.finish(false);
let _ = std::fs::remove_dir_all(data);
}
#[test]
fn converts_servo_jar() {
let jar = br#"{"cookies_map":{"example.com":[

View file

@ -9,7 +9,7 @@ open @PAGES@/fingerprint.html
waitfor 30 document.title === "FP done"
save fp-incognito JSON.stringify(window.fp, null, 1)
shot fp-incognito
assert window.fp.hardwareConcurrency === 8 && window.fp.platform === "Linux x86_64" && window.fp.webgl.vendor === "Mozilla"
assert window.fp.hardwareConcurrency === 8 && window.fp.platform === "Linux x86_64" && window.fp.webgl.vendor === "WebKit"
flyout shield
wait 1
shot shield-incognito