fix(chromium): fix a race when intialization does not finish before page close (#6975)
This is exposed by the flaky "should report new window downloads" test. In this test a new page is created, initialized and closed before initialization finishes. If `lifecycleEventsEnabled` fails with "Target closed error", we correctly ignore the initialization failure, but a single usage of the failed promise with `.then` fails anyway.
This commit is contained in:
parent
52e75cf13e
commit
6eeafc171b
|
|
@ -482,7 +482,7 @@ class FrameSession {
|
||||||
// Ignore lifecycle events for the initial empty page. It is never the final page
|
// Ignore lifecycle events for the initial empty page. It is never the final page
|
||||||
// hence we are going to get more lifecycle updates after the actual navigation has
|
// hence we are going to get more lifecycle updates after the actual navigation has
|
||||||
// started (even if the target url is about:blank).
|
// started (even if the target url is about:blank).
|
||||||
lifecycleEventsEnabled.then(() => {
|
lifecycleEventsEnabled.catch(e => {}).then(() => {
|
||||||
this._eventListeners.push(helper.addEventListener(this._client, 'Page.lifecycleEvent', event => this._onLifecycleEvent(event)));
|
this._eventListeners.push(helper.addEventListener(this._client, 'Page.lifecycleEvent', event => this._onLifecycleEvent(event)));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue