S061: site menus win on every right click, menu keys, pop-ups need a click, ad frames can't take the tab

WebKit asks for a menu on cancelled right clicks once it has shown one; the bridge
script's answer decides now. Script navigations that may be a frame's are no longer
rewritten into loads in the tab (an ad frame took the tab over on the user's site).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-18 04:55:53 -06:00
commit 09233cdaf3

View file

@ -481,6 +481,15 @@ Later: S010 list: user checks the Discord icon with their own client (the Discor
- Also tried (orchestrator's suspects): a visible DP-1 run (real GPU, user's niri, 3 rounds, `cmd pip`; round 2 a real Escape, round 3 niri close-window by id; niri windows sampled 1/3/5 s into each round): the PiP window was floating and focused for the whole 5 s every round, each round a new window id, the old PiP window gone from niri's list after exit. Code read: the only `present()` calls are `open_window` (the new window itself), opening a link in a new tab and a second launch; nothing presents or focuses the parent on PiP enter/exit; the closed PiP window's handlers hold only a weak app ref and its id. The user's niri config has no Nacre rule and no focus-follows-mouse.
- Not done: 🧑 the user trying PiP 3× on YouTube on their screen (deferred overnight, box left unticked); the user's exact steps for "focus goes back" weren't known, so a focus loss specific to the real screen may remain.
## S061 — A site's own context menu wins; video clicks don't open ads (2026-11-18)
- Priority, root cause (reproduced hidden): once WebKit has shown one menu on a page it emits `context-menu` even for right clicks the page cancels (it reuses its last hit test), so after one Nacre menu every site menu got Nacre's on top (the user's YouTube case). Fix: the bridge script reports after dispatch whether the page cancelled (`context_end`); Nacre shows its menu only when not (`tabs::MenuWait`; 300 ms fallback for pages without the script). Stale right-click details are dropped on each new click.
- Nacre's menu: Up/Down/Enter/Escape (S035). WebKit keeps the keyboard after a right click, so the window's key handler sends those keys to the open menu.
- Ad on click: one hidden load of the user's site (no account): the tab's own page ended up on an ad frame's address (`cdn-fc.com/creatives/…`). Cause: Nacre's rewrites of a script navigation (HTTPS-only upgrade, tracking-param strip, user-agent reload) load in the tab, and a frame inside a cross-site frame can't be found by the page check. Fix: such navigations (`maybe_frame`) load where they were going; only if the tab itself starts loading that URL does the browser load it again with its rules (`Tab::redo`). Also pop-ups need a click or key press unless the site is allowed (Chromium's rule, the "pop-up blocked" bar otherwise); listed pop-up addresses were already stopped by WebKit's content filters; a zapped ad no longer catches clicks while it fades.
- Tests: `ctxmenu.txt` extended (`pages/site-menu.html`: YouTube-like toggle, Discord-like always-own, plain, each 3×, keys), new `player-ad.txt` (`pages/player-ad.html` click catcher + pop-unders, `frame-hijack.html` + `frame-ad.html`; server.py serves them and `/popup-list.txt`); selftest `realkey`. The frame case fails without the fix (tab went to the frame's URL).
- Verified: hidden `ctxmenu.txt`, `player-ad.txt`, `basics.txt` exit 0; `cargo test` 88 + webext 1.
- Not done: 🧑 the real site after the fix was not reloaded (plan allows one hidden load; it was used to find the cause): the user should open a video there and click the player once to confirm. No visible run; YouTube/Discord menus not rechecked live.
- Later: a link clicked inside a frame still goes through the tab's policy (S050 note); WebKit treats `evaluate_javascript` window.open as a user gesture.
## 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).