Files
paseo/packages/desktop/src/features/browser-webviews/window-open.test.ts
T
Mohamed Boudra 328361667f Keep browser sign-ins across tabs and restarts (#2089)
* feat(desktop): share persistent browser data across tabs

Keep browser sign-ins and site storage across tabs and app restarts, with a Settings action to clear the shared profile.

* fix(settings): prevent duplicate browser data clears

* fix(desktop): complete browser data cleanup

Clear legacy per-tab profiles after upgrades and localize the browser data settings in every supported language.

* fix(desktop): close browser profile cleanup races
2026-07-16 00:40:24 +08:00

55 lines
1.8 KiB
TypeScript

import { describe, expect, it, vi } from "vitest";
import { handleBrowserWindowOpenRequest, PendingBrowserWindowOpenRequests } from ".";
describe("browser webview window-open requests", () => {
it("denies Electron window creation and requests a Paseo browser tab", () => {
const requestNewTab = vi.fn();
const result = handleBrowserWindowOpenRequest({
url: "https://example.com/target",
sourceBrowserId: "browser-1",
requestNewTab,
});
expect(result).toEqual({ action: "deny" });
expect(requestNewTab).toHaveBeenCalledWith({
sourceBrowserId: "browser-1",
url: "https://example.com/target",
});
});
it("denies unsupported window-open requests before asking for a Paseo browser tab", () => {
const requestNewTab = vi.fn();
const result = handleBrowserWindowOpenRequest({
url: "file:///etc/passwd",
sourceBrowserId: "browser-1",
requestNewTab,
});
expect(result).toEqual({ action: "deny" });
expect(requestNewTab).not.toHaveBeenCalled();
});
});
describe("pending browser window-open requests", () => {
it("holds early allowed popups until browser identity registration", () => {
const pending = new PendingBrowserWindowOpenRequests();
pending.add(101, "https://example.com/first");
pending.add(101, "file:///etc/passwd");
pending.add(101, "https://example.com/second");
expect(pending.take(101)).toEqual(["https://example.com/first", "https://example.com/second"]);
expect(pending.take(101)).toEqual([]);
});
it("drops pending popups when an unregistered guest is destroyed", () => {
const pending = new PendingBrowserWindowOpenRequests();
pending.add(202, "https://example.com/target");
pending.delete(202);
expect(pending.take(202)).toEqual([]);
});
});