@@ -512,7 +512,8 @@ interface ExpectedAgentInput {
512512 *
513513 * `about:blank` stays out: Chromium skips browser-side navigation for it, so the
514514 * child copies the guest's `contextIsolation: false` preferences and Electron
515- * gives no way to override them. Those popups keep loading in the preview tab.
515+ * gives no way to override them. Those popups are denied without navigating,
516+ * so the opener survives for the SDK fallback.
516517 *
517518 * Deliberately not `ElectronShell.parseSafeExternalUrl`: that also admits
518519 * `vscode://vscode-remote/...` deep links, which belong in `shell.openExternal`
@@ -553,14 +554,21 @@ const POPUP_WINDOW_OPTIONS = {
553554 * navigating the preview tab instead destroys the opener the popup has to
554555 * `postMessage` its result back to.
555556 *
557+ * `"deny"` blocks a scripted `new-window` without touching the opener. This is
558+ * for URLs that cannot be hardened in a popup, like `about:blank`: loading them
559+ * in the preview tab would replace the opener, while a plain deny lets SDKs
560+ * like MSAL fall back to redirect.
561+ *
556562 * `target="_blank"` links arrive as a tab disposition and keep loading in the
557563 * preview tab, which is what people expect from a link inside a preview.
558564 */
559565export const previewWindowOpenAction = ( details : {
560566 readonly url : string ;
561567 readonly disposition : Electron . HandlerDetails [ "disposition" ] ;
562- } ) : "popup" | "navigate" =>
563- details . disposition === "new-window" && isPopupUrl ( details . url ) ? "popup" : "navigate" ;
568+ } ) : "popup" | "navigate" | "deny" => {
569+ if ( details . disposition !== "new-window" ) return "navigate" ;
570+ return isPopupUrl ( details . url ) ? "popup" : "deny" ;
571+ } ;
564572
565573export const isPreviewRefreshShortcut = ( input : Electron . Input ) : boolean =>
566574 input . type === "keyDown" &&
@@ -2048,14 +2056,17 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
20482056 wc . ipc . on ( RECORDING_INPUT_CHANNEL , recordingInput ) ;
20492057 wc . ipc . on ( MOUSE_NAVIGATE_CHANNEL , mouseNavigate ) ;
20502058 wc . setWindowOpenHandler ( ( details ) => {
2051- if ( previewWindowOpenAction ( details ) === "popup" ) {
2059+ const openAction = previewWindowOpenAction ( details ) ;
2060+ if ( openAction === "popup" ) {
20522061 return { action : "allow" , overrideBrowserWindowOptions : POPUP_WINDOW_OPTIONS } ;
20532062 }
2054- runFork (
2055- attemptPromise ( { operation : "openPreviewWindow" , tabId, webContentsId : wc . id } , ( ) =>
2056- wc . loadURL ( details . url ) ,
2057- ) . pipe ( Effect . ignore ) ,
2058- ) ;
2063+ if ( openAction === "navigate" ) {
2064+ runFork (
2065+ attemptPromise ( { operation : "openPreviewWindow" , tabId, webContentsId : wc . id } , ( ) =>
2066+ wc . loadURL ( details . url ) ,
2067+ ) . pipe ( Effect . ignore ) ,
2068+ ) ;
2069+ }
20592070 return { action : "deny" } ;
20602071 } ) ;
20612072 wc . on ( "did-create-window" , windowCreated ) ;
0 commit comments