The test page read document.hidden from WebKit, which app.js never does:
app.js makes hidden and visibilityState follow magpie's signal (#4293).
WebKit turns an ordered-out window's document.hidden on in its own time
and fires no visibilitychange of its own, so the page recorded the hiding
only if WebKit's value was already true when magpie's signal (an async
ExecJS after orderOut) arrived. When it wasn't, nothing was recorded, the
window was shown again after a fixed 500ms, and the host waited 8s for a
report that could never come: "timed out waiting for the page's hidden
report", as on macOS CI at 4a9cfb52e and in a full run on mote.
A probe on mote showed WebKit reporting hidden=true for this page from the
start, before the window was ever ordered out, so there the old test
passed on WebKit's value, not on magpie's signal.
The page now overrides hidden and visibilityState the way app.js does,
and says when it has seen itself hidden; the window is shown again only
after that (a wait on state, 15s bound), not after a fixed pause. The
runAppKit bound is 2 minutes to cover its waits. app.js is unchanged.
Run on mote (macOS) at this tree:
- Injected WebKit reporting visible when the signal arrives (hidden and
visibilityState pinned to visible in the page): old test red on both
tests with "timed out waiting for the page's hidden report"; new test
green.
- hideWebview's signal broken by hand (pageHiddenJSOn returns ""): new
test red on both, "timed out waiting for the page to see itself hidden".
- No injection: green, -count=3.
- go vet ./internal/gui: ok; gofmt -l: clean.
- go test -count=1 ./internal/gui: only TestMainWindowCorners red, the
separate #3949, which #4924's body names as well.
Not tried: a 1.5s busy page or a 300ms-late orderOut as the injection;
neither turned the old test red on mote, since WebKit says hidden there
throughout. A CI macOS runner itself.