fix(browser): keep the Annotate pick armed when a page rewrites its URL fragment (#34423)

This commit is contained in:
Kelvin Amoaba
2026-10-27 13:36:38 +00:00
committed by GitHub
parent 89dea213df
commit b0ad924dc9
2 changed files with 18 additions and 3 deletions
@@ -133,14 +133,14 @@ export class BrowserGrabSessionController {
}
}
// Subframe navigations, such as ad loads, must not cancel the selection.
// Subframe loads and in-place URL updates (scroll spies) keep the overlay's document.
const handleNavigation = (
_event: unknown,
_url: unknown,
_isInPlace: unknown,
isInPlace: boolean,
isMainFrame: boolean
): void => {
if (isMainFrame) {
if (isMainFrame && !isInPlace) {
settleOnce({ opId, kind: 'cancelled', reason: 'navigation' })
}
}
@@ -546,6 +546,21 @@ describe('browserManager grab operations', () => {
expect(browserManager.hasActiveGrabOp('tab-1')).toBe(true)
})
it('does not cancel grab when the page rewrites its URL in place', async () => {
guestExecuteJavaScriptMock.mockImplementation(() => new Promise(() => {}))
void browserManager.awaitGrabSelection('tab-1', 'op-1', guest)
const navHandler = guestOnMock.mock.calls.findLast(
([event]) => event === 'did-start-navigation'
)?.[1] as ((...args: unknown[]) => void) | undefined
expect(navHandler).toBeTypeOf('function')
navHandler?.(null, 'https://example.com/#section-2', true, true)
expect(browserManager.hasActiveGrabOp('tab-1')).toBe(true)
})
})
describe('destruction auto-cancel', () => {