The owner (11-03, again 11-04: "你到底彻底修复了没啊"): Magpie Browser
disturbs the user's browsing. v0.1.2864 moved agents into tabs of their
own, behind the user's, in a Magpie tab group, but two paths still took
the user's tab from under them:
- A screenshot that took over 8s brought the agent's tab forward for
~300ms and gave the user's back. With a recording on (v0.1.2865) every
action takes one. Measured on mote, headful Chrome for Testing 1234:
Chrome draws a background tab for Page.captureScreenshot (first ~5s,
then 50-250ms), so the tab is never brought forward now; after 20s
the call fails SCREENSHOT_FAILED instead.
- A link with target=_blank, clicked in the agent's background tab,
opened its new tab in front, and the user's tab came back only after
the new page settled (up to ~2.5s). Now such a link is clicked with
Cmd (Ctrl off macOS) held, as a person opens one in the background,
and a tab that still comes up in front (window.open, Enter on a link)
is given back the moment it is created.
Extension 0.1.5.
Test: TestBrowserLeavesTheUsersTabAlone starts Chrome on a user page the
extension never attaches to (attaching turns on focus emulation, which
keeps a page "visible"); its title counts every visibilitychange to
hidden. Headless Chrome keeps every tab visible, so the moment-long case
is caught only with MAGPIE_BROWSER_HEADFUL=1 (a window on the screen);
the test says so in its log when headless.
Run on mote at this tree:
- gofmt clean; GOOS=darwin/linux/windows go vet ./internal/gateway clean
- go test ./internal/gateway -count=1 -timeout 45m: ok (1114s)
- MAGPIE_BROWSER_HEADFUL=1 go test ./internal/gateway -run TestBrowser:
all 20 pass; TestBrowserLeavesTheUsersTabAlone -count=3 headful ok
Broken by hand, headful: the old screenshot dance fails "after a
screenshot ... Watch 1"; the click without Cmd fails "after a link
opened a tab ... Watch 1"; the fix before the Cmd click (restore on
create only) still failed at the link, which is why the Cmd click is in.
Headless, both breaks pass: that is the limit named above.
Not tried: Edge, Arc, Windows and Linux Chrome; a real site's
window.open popup (it is given back at once, a flash remains).