WebPanel: fix round 2 (unresponsive reset, foreground gate, clipboard, Open rollback)

- Reset the unresponsive counter on teardown, on each new open and on
  navigation completed; harness check UnresponsiveCountResetsPerOpen.
- Show only calls SetForegroundWindow when our process holds the foreground.
- ClipboardRead permission is denied for about:blank.
- Open rolls back live handle and status fields if the STA thread fails to start.
- State struct minimum size is 28 on both platforms; test asserts it unguarded.
- Harness Escape message reports game key count as informational.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daniel Wallace 2026-11-07 15:38:19 -08:00
commit ba7d96c7d9
5 changed files with 54 additions and 5 deletions

View file

@ -105,6 +105,7 @@ internal static unsafe class Program
Guard("NoBrowserFallbackAfterNavigation", () => CheckNoFallbackAfterNavigation(s, handle));
Guard("GpuProcessCrashKeepsPanel", () => handle = CheckGpuCrash(s));
Guard("LateFailureForSupersededHandle", () => handle = CheckLateFailure(s));
Guard("UnresponsiveCountResetsPerOpen", () => handle = CheckUnresponsiveReset(s));
Guard("CreateFailureFallsBack", () => CheckCreateFailure(s));
Guard("VisibilitySameProcess", () => handle = CheckVisibilitySameProcess(s));
Unverified("VisibilityOtherProcess", "needs another process to take the foreground (alt-tab); the harness never forces it. Owner in-game check.");
@ -249,7 +250,7 @@ internal static unsafe class Program
return;
}
if (!closed) { Fail("EscapeClosesAndRefocusesGame", $"AcceleratorKeyPressed fired but the panel is {st[2]}, not Closed"); return; }
if (!panelFg) { Unverified("EscapeClosesAndRefocusesGame", "closed, game saw 0 keys; the foreground hand-back could not be checked (the panel did not hold the foreground)"); return; }
if (!panelFg) { Unverified("EscapeClosesAndRefocusesGame", $"closed (game key messages {g}, informational only); the foreground hand-back could not be checked (the panel did not hold the foreground)"); return; }
if (fg != _game) { Fail("EscapeClosesAndRefocusesGame", "closed, but the foreground is not the game"); return; }
Ok("EscapeClosesAndRefocusesGame");
}
@ -447,6 +448,28 @@ internal static unsafe class Program
return b;
}
// Two unresponsive reports, a new Open, one more report: the count starts again per panel, so the new one
// stays Ready (the limit is 3 within 30 s). Reports are injected through the host's own handler.
private static int CheckUnresponsiveReset(Session s)
{
var (a, _) = Open(s, "https://panel.test/index.html", Allow, title: "Hung A");
bool ra = WaitStatus(s, a, StatusReady, 30000, out _);
s.Call("ReportUnresponsive"); s.Call("ReportUnresponsive");
Thread.Sleep(300);
int[] sa = State(s, a);
var (b, _) = Open(s, "https://panel.test/b.html", Allow, title: "Hung B");
bool rb = WaitStatus(s, b, StatusReady, 30000, out _);
s.Call("ReportUnresponsive");
Thread.Sleep(500);
int[] sb = State(s, b);
W($"two reports on {a}: state [{string.Join(",", sa)}]; then Open {b} Ready {rb}, one more report: state [{string.Join(",", sb)}]");
if (!ra || !rb) Fail("UnresponsiveCountResetsPerOpen", "setup: not Ready");
else if (sa[2] != StatusReady) Fail("UnresponsiveCountResetsPerOpen", "two reports already failed the panel (limit is 3)");
else if (sb[2] != StatusReady) Fail("UnresponsiveCountResetsPerOpen", $"the third report overall failed the new panel: status {sb[2]} error {sb[4]}");
else Ok("UnresponsiveCountResetsPerOpen");
return b;
}
private static uint ParentPid(int pid)
{
IntPtr h = OpenProcess(0x1000 /* PROCESS_QUERY_LIMITED_INFORMATION */, false, pid);