fix(firefox): race between markAsError and Page.ready (#6976)

When new page turns into download, we can have `_markAsError` followed
by the `Page.ready` signal and report the page twice (as an error and
as a real page). This is flaky and depends on whether `Page.ready` is
fast enough before the page closes or not.

Exposed by the "should report new window downloads" test.
This commit is contained in:
Dmitry Gozman 2021-06-08 17:28:24 -07:00 committed by GitHub
parent 6eeafc171b
commit ff3f951dc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -102,6 +102,8 @@ export class FFPage implements PageDelegate {
});
this._session.once('Page.ready', async () => {
await this._page.initOpener(this._opener);
if (this._initializationFailed)
return;
// Note: it is important to call |reportAsNew| before resolving pageOrError promise,
// so that anyone who awaits pageOrError got a ready and reported page.
this._initializedPage = this._page;