test(browser): freeze recovery clock during artificial attach gate

This commit is contained in:
Jinwoo-H
2026-09-04 21:43:35 -04:00
parent f73a2f68b4
commit db04a32451
2 changed files with 5 additions and 1 deletions
@@ -56,7 +56,7 @@ describe('BrowserPane webview preferences', () => {
'persist:orca-browser-session-profile-1'
)
expect(ensuredWebview?.webview.getAttribute('webpreferences')).toBe(
ORCA_BROWSER_GUEST_WEB_PREFERENCES_ATTRIBUTE
`${ORCA_BROWSER_GUEST_WEB_PREFERENCES_ATTRIBUTE},transparent=false`
)
expect(registryMocks.registerPersistentWebview).toHaveBeenCalledWith(
'browser-page-1',
@@ -44,6 +44,8 @@ export async function observeBrowserLoadingSurface(
await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve))
const url = `http://127.0.0.1:${(server.address() as AddressInfo).port}/held`
const observations: Record<string, unknown>[] = []
// Freezing attachment for a screenshot must also freeze the missing-guest watchdog.
await page.clock.pauseAt(new Date())
const attachGate = await page.evaluateHandle((heldUrl) => {
const original = Element.prototype.setAttribute
const pending: (() => void)[] = []
@@ -138,6 +140,7 @@ export async function observeBrowserLoadingSurface(
await page.mouse.move(0, 0)
await capture('pre-attach', 'theme')
await attachGate.evaluate((release) => release())
await page.clock.resume()
await expect.poll(() => requestCount).toBe(1)
await capture('dark-held', 'theme', true)
await page.evaluate(async () => {
@@ -280,6 +283,7 @@ export async function observeBrowserLoadingSurface(
return observations
} finally {
await attachGate.evaluate((release) => release()).catch(() => {})
await page.clock.resume().catch(() => {})
await attachGate.dispose()
release?.()
server.closeAllConnections()