Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

test(hud): pin that click-through is asked for, never born with

Etienne Lescot7e14d17d67c2
diff --git a/tests/e2e/windows-native-checklist.spec.ts b/tests/e2e/windows-native-checklist.spec.ts
index 9c9c5710e..959b15f1d 100644
--- a/tests/e2e/windows-native-checklist.spec.ts
+++ b/tests/e2e/windows-native-checklist.spec.ts
@@ -319,4 +319,80 @@ test.describe("Windows native checklist smoke tests", () => {
}
}
});
+
+ // The HUD must reach click-through by *asking* for it from the renderer, never
+ // by being born that way. On Windows the `forward` option is a global
+ // WH_MOUSE_LL hook, and it is the only route back out: a HUD that is already
+ // input-transparent when the hook fails to install can never be clicked again,
+ // which is what bricked the app in issue #266. Both halves matter — that nothing
+ // asks during construction, and that the renderer still does after mount.
+ test("the HUD asks for click-through instead of being born with it", async () => {
+ const app = await launchApp();
+
+ try {
+ const hudWindow = await app.firstWindow({ timeout: 60_000 });
+ await hudWindow.waitForLoadState("domcontentloaded");
+ await dismissLanguagePrompt(hudWindow);
+
+ // A second window keeps the window list non-empty while the HUD is torn
+ // down below — emptying it fires window-all-closed, which quits the app.
+ await hudWindow.getByTestId("launch-source-selector-button").click();
+ await app.waitForEvent("window", {
+ predicate: (w) => w.url().includes("windowType=source-selector"),
+ timeout: 15_000,
+ });
+
+ // Recreate the HUD through the app's own path (second-instance →
+ // showMainWindow → createHudOverlayWindow) with the native call taped.
+ // Nothing awaits between the tape going on and the snapshot coming off,
+ // so no IPC from the renderer can slip into it: what comes back is
+ // construction, and construction only.
+ const duringConstruction = await app.evaluate(({ app: electronApp, BrowserWindow }) => {
+ const tape: unknown[][] = [];
+ const original = BrowserWindow.prototype.setIgnoreMouseEvents;
+ globalThis.__hudTape = tape;
+ globalThis.__hudSetIgnoreMouseEvents = original;
+ BrowserWindow.prototype.setIgnoreMouseEvents = function patched(
+ this: InstanceType<typeof BrowserWindow>,
+ ...args: Parameters<typeof original>
+ ) {
+ tape.push(args);
+ return original.apply(this, args);
+ };
+
+ BrowserWindow.getAllWindows()
+ .find((w) => w.webContents.getURL().includes("windowType=hud-overlay"))
+ ?.destroy();
+ electronApp.emit("second-instance");
+
+ return tape.slice();
+ });
+
+ expect(duringConstruction).toEqual([]);
+
+ // And the renderer does ask, once it has mounted.
+ await expect
+ .poll(() => app.evaluate(() => globalThis.__hudTape ?? []), { timeout: 20_000 })
+ .toContainEqual([true, { forward: true }]);
+ } finally {
+ await app.evaluate(({ BrowserWindow }) => {
+ const original = globalThis.__hudSetIgnoreMouseEvents;
+ if (original) {
+ BrowserWindow.prototype.setIgnoreMouseEvents = original;
+ }
+ globalThis.__hudTape = undefined;
+ globalThis.__hudSetIgnoreMouseEvents = undefined;
+ });
+ await closeApp(app);
+ }
+ });
});
+
+declare global {
+ // Set inside the main process by the click-through test above, read back by a
+ // second evaluate — the only way to observe calls that land between two of them.
+ var __hudTape: unknown[][] | undefined;
+ var __hudSetIgnoreMouseEvents:
+ | ((ignore: boolean, options?: { forward?: boolean }) => void)
+ | undefined;
+}