From ba04481e42e6c389003400f97e32f6272ca4b413 Mon Sep 17 00:00:00 2001 From: RoastFried Date: Sun, 8 Nov 2026 21:01:25 +0900 Subject: [PATCH] fix(browser): keep native popup minimum content size and first Windows fixture error (#39319) Native popups now hide the app menu bar like origin-bar popups, so the Windows menu no longer eats into the 200px minimum content height. The popup compatibility fixture keeps the first reported error across later status writes, stops serializing the destroyed Event as an error, and replaces its status file with the Windows retry helper. The native resize check now compares against the native outer window size. Fixes #39299 Co-authored-by: Neil --- .../browser-popup-compatibility-electron-fixture.ts | 12 ++++++++---- .../popups/browser-popup-compatibility-status.ts | 1 + ...owser-popup-native-compatibility.electron.test.ts | 7 +++---- .../popups/browser-popup-native-electron-fixture.ts | 1 + .../popups/browser-popup-native-window.ts | 2 ++ 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/browser/guest-lifecycle/popups/browser-popup-compatibility-electron-fixture.ts b/src/main/browser/guest-lifecycle/popups/browser-popup-compatibility-electron-fixture.ts index 6dc3ab320d8..b9d9e12b33f 100644 --- a/src/main/browser/guest-lifecycle/popups/browser-popup-compatibility-electron-fixture.ts +++ b/src/main/browser/guest-lifecycle/popups/browser-popup-compatibility-electron-fixture.ts @@ -7,7 +7,8 @@ import { type Session, type WebContents } from 'electron' -import { renameSync, writeFileSync } from 'node:fs' +import { writeFileSync } from 'node:fs' +import { renameFileWithWindowsRetry } from '../../../../shared/windows-retry-file-operations' import { applyBackgroundActivationPolicy } from '../../../window/foreground-activation-policy' import { BrowserPopupCompatibilityManager } from './browser-popup-compatibility-manager-fixture' import { BrowserRouteWebContentsRegistry } from '../../routing/guest-authority/browser-route-webcontents-registry' @@ -48,6 +49,7 @@ const authority = Symbol('fixture-route-authority') let fixtureAuthority: symbol | null = authority let fixtureAuthorityThrows = false let revision = 0 +let failure: string | undefined const adapterProbe = process.env.ORCA_POPUP_FIXTURE_ADAPTER_PROBE === '1' ? new BrowserPopupAdapterProbeFixture(() => writeStatus()) @@ -65,14 +67,16 @@ const native = new BrowserPopupNativeFixture({ writeStatus }) +// Later teardown snapshots must not hide the initiating failure. function writeStatus(error?: string): void { + failure ??= error writeFileSync( `${fixtureStatusPath}.next`, JSON.stringify({ revision: ++revision, ready, phase, - error, + error: failure, tabOpens: manager.tabOpens, childRequests: manager.childRequests, native: native.snapshot(), @@ -92,7 +96,7 @@ function writeStatus(error?: string): void { guestIds: Object.fromEntries([...guests].map(([name, guest]) => [name, guest.id])) }) ) - renameSync(`${fixtureStatusPath}.next`, fixtureStatusPath) + renameFileWithWindowsRetry(`${fixtureStatusPath}.next`, fixtureStatusPath) } async function createHost(name: string, partition: string, nativeControl = false): Promise { @@ -178,7 +182,7 @@ async function createHost(name: string, partition: string, nativeControl = false }) } await guest.loadURL(`${fixtureOrigin}/${name}`) - guest.once('destroyed', writeStatus) + guest.once('destroyed', () => writeStatus()) resolve() })().catch(reject) }) diff --git a/src/main/browser/guest-lifecycle/popups/browser-popup-compatibility-status.ts b/src/main/browser/guest-lifecycle/popups/browser-popup-compatibility-status.ts index ba8704ce854..446732becea 100644 --- a/src/main/browser/guest-lifecycle/popups/browser-popup-compatibility-status.ts +++ b/src/main/browser/guest-lifecycle/popups/browser-popup-compatibility-status.ts @@ -36,6 +36,7 @@ export type PopupCompatibilityStatus = { title: string fullscreen: boolean focused: boolean + size: number[] contentSize: number[] }[] } diff --git a/src/main/browser/guest-lifecycle/popups/browser-popup-native-compatibility.electron.test.ts b/src/main/browser/guest-lifecycle/popups/browser-popup-native-compatibility.electron.test.ts index 2c86126b39e..fdbd1bf3974 100644 --- a/src/main/browser/guest-lifecycle/popups/browser-popup-native-compatibility.electron.test.ts +++ b/src/main/browser/guest-lifecycle/popups/browser-popup-native-compatibility.electron.test.ts @@ -15,7 +15,6 @@ import { setPopupFixtureEvidenceName } from './browser-popup-compatibility-cdp-fixture' import { waitForHiddenFrameInput } from '../../electron-fixtures/hidden-frame-input-readiness-fixture' -import { MIN_POPUP_CONTENT_HEIGHT, MIN_POPUP_CONTENT_WIDTH } from './popup-window-minimum-size' setPopupFixtureEvidenceName('native-electron-evidence.json') @@ -502,12 +501,12 @@ describe('hidden Chromium native popup request compatibility', () => { await page.locator('#scripted-native').click({ modifiers: ['Shift'] }) } const child = await childPage(`${origin}${path}`) - // Native size conversion can round by one pixel; the resize must still take effect. + // resizeTo sizes the native outer window; window.outerWidth echoes the pending request. await child.evaluate('window.resizeTo(640, 480)') await expect .poll(async () => { await refreshStatus() - const width = status().native.windows.at(-1)?.contentSize[0] + const width = status().native.windows.at(-1)?.size[0] return Math.abs((width ?? Infinity) - 640) }) .toBeLessThanOrEqual(1) @@ -517,7 +516,7 @@ describe('hidden Chromium native popup request compatibility', () => { await refreshStatus() return status().native.windows.at(-1)?.contentSize }) - .toEqual([MIN_POPUP_CONTENT_WIDTH, MIN_POPUP_CONTENT_HEIGHT]) + .toEqual([360, 200]) await closeChildren(page) await page.locator('#shift').evaluate((link) => link.setAttribute('href', '/shift')) } diff --git a/src/main/browser/guest-lifecycle/popups/browser-popup-native-electron-fixture.ts b/src/main/browser/guest-lifecycle/popups/browser-popup-native-electron-fixture.ts index 8e9da714c62..e5ce1690dc8 100644 --- a/src/main/browser/guest-lifecycle/popups/browser-popup-native-electron-fixture.ts +++ b/src/main/browser/guest-lifecycle/popups/browser-popup-native-electron-fixture.ts @@ -136,6 +136,7 @@ export class BrowserPopupNativeFixture { title: window.isDestroyed() ? '' : window.getTitle(), fullscreen: !window.isDestroyed() && window.isFullScreen(), focused: !window.isDestroyed() && window.isFocused(), + size: window.isDestroyed() ? [] : window.getSize(), contentSize: window.isDestroyed() ? [] : window.getContentSize() })) } diff --git a/src/main/browser/guest-lifecycle/popups/browser-popup-native-window.ts b/src/main/browser/guest-lifecycle/popups/browser-popup-native-window.ts index c4d6e1fd265..742c4cec958 100644 --- a/src/main/browser/guest-lifecycle/popups/browser-popup-native-window.ts +++ b/src/main/browser/guest-lifecycle/popups/browser-popup-native-window.ts @@ -97,6 +97,8 @@ export function allowNativeBrowserPopup(input: { ...input.options, title: 'about:blank', fullscreenable: false, + // Like origin-bar popups; a visible Windows app menu eats the minimum content height. + autoHideMenuBar: true, show: mayPresent && !input.background, // Content-sized like origin-bar popups, so resizeTo cannot hide the origin title. useContentSize: true,