mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 20:06:10 +00:00
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 <neil@stably.ai>
This commit is contained in:
+8
-4
@@ -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<void> {
|
||||
@@ -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)
|
||||
})
|
||||
|
||||
@@ -36,6 +36,7 @@ export type PopupCompatibilityStatus = {
|
||||
title: string
|
||||
fullscreen: boolean
|
||||
focused: boolean
|
||||
size: number[]
|
||||
contentSize: number[]
|
||||
}[]
|
||||
}
|
||||
|
||||
+3
-4
@@ -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'))
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user