w3c / webdriver-bidi

Bidirectional WebDriver protocol for browser automation
https://w3c.github.io/webdriver-bidi/
336 stars 35 forks source link

Add event for detecting document unload #659

Closed jrandolf closed 4 months ago

jrandolf commented 4 months ago

In Puppeteer, we usually retain a set of current page frames visible to the user with the page.frames() method. In BiDi, it's not possible to track the set of current page frames as browsingContext.contextDestroyed is not deterministic with navigation. It's also not compatible with BFCache which may persist the browsingContext

Related: https://github.com/w3c/webdriver-bidi/issues/658

CC: @OrKoN @jgraham @whimboo

jrandolf commented 4 months ago

From investigating, a DOM event that satisfies the criteria required by Puppeteer would be pagehide. If we could add browsingContext.pagehide, this would solve our issue.

WDYT @OrKoN @jgraham

References:

jrandolf commented 4 months ago

Looks like we can get away with waiting for current frames to disappear on top of waiting for navigation in Puppeteer. See https://github.com/puppeteer/puppeteer/pull/11919