Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): oauth popups open from the browser preview #8435

Mergedwalid-baharwal(GitHub profile, opens in a new tab)merged 5 commits intomain fromrefs/pull/8435/headmerged by juliusmarminge View on GitHub

Showing 3 changed files with 118 additions and 3 deletions.

x
0 of 3 viewed, 3 left
44 additions and 0 deletionsapps/desktop/src/preview/Manager.test.tsModified
View file
@@ -58,6 +58,50 @@
});
});
​
+describe("previewWindowOpenAction", () => {
+ const details = (overrides: {
+ readonly url?: string;
+ readonly disposition?: Electron.HandlerDetails["disposition"];
+ }) => ({
+ url: "https://accounts.google.com/o/oauth2/auth",
+ disposition: "new-window" as Electron.HandlerDetails["disposition"],
+ ...overrides,
+ });
+​
+ it("opens a real window for scripted popups so the opener survives", () => {
+ // OAuth SDKs read a null `window.open()` as a blocked popup, and they need
+ // the opener alive to receive the credential back.
+ expect(PreviewManager.previewWindowOpenAction(details({}))).toBe("popup");
+ expect(
+ PreviewManager.previewWindowOpenAction(details({ url: "http://localhost:5173/auth" })),
+ ).toBe("popup");
+ });
+​
+ it("keeps target=_blank links in the preview tab", () => {
+ expect(PreviewManager.previewWindowOpenAction(details({ disposition: "foreground-tab" }))).toBe(
+ "navigate",
+ );
+ expect(PreviewManager.previewWindowOpenAction(details({ disposition: "background-tab" }))).toBe(
+ "navigate",
+ );