revert: lifecycle refactoring, it breaks setContent (#4420)
This commit is contained in:
parent
5d47214e2c
commit
b0d174fd9a
|
|
@ -397,8 +397,7 @@ class FrameSession {
|
||||||
const { windowId } = await this._client.send('Browser.getWindowForTarget');
|
const { windowId } = await this._client.send('Browser.getWindowForTarget');
|
||||||
this._windowId = windowId;
|
this._windowId = windowId;
|
||||||
}
|
}
|
||||||
|
let lifecycleEventsEnabled: Promise<any>;
|
||||||
let isInitialLifecycle = true;
|
|
||||||
if (!this._isMainFrame())
|
if (!this._isMainFrame())
|
||||||
this._addRendererListeners();
|
this._addRendererListeners();
|
||||||
this._addBrowserListeners();
|
this._addBrowserListeners();
|
||||||
|
|
@ -421,22 +420,20 @@ class FrameSession {
|
||||||
frame._evaluateExpression(binding.source, false, {}).catch(e => {});
|
frame._evaluateExpression(binding.source, false, {}).catch(e => {});
|
||||||
}
|
}
|
||||||
const isInitialEmptyPage = this._isMainFrame() && this._page.mainFrame().url() === ':';
|
const isInitialEmptyPage = this._isMainFrame() && this._page.mainFrame().url() === ':';
|
||||||
if (!isInitialEmptyPage)
|
if (isInitialEmptyPage) {
|
||||||
this._firstNonInitialNavigationCommittedFulfill();
|
|
||||||
this._eventListeners.push(helper.addEventListener(this._client, 'Page.lifecycleEvent', event => {
|
|
||||||
// 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).
|
||||||
// Note: isInitialLifecycle is reset after the Page.setLifecycleEventsEnabled response.
|
lifecycleEventsEnabled.then(() => {
|
||||||
const ignoreLifecycle = isInitialLifecycle && isInitialEmptyPage;
|
this._eventListeners.push(helper.addEventListener(this._client, 'Page.lifecycleEvent', event => this._onLifecycleEvent(event)));
|
||||||
if (!ignoreLifecycle)
|
});
|
||||||
this._onLifecycleEvent(event);
|
} else {
|
||||||
}));
|
this._firstNonInitialNavigationCommittedFulfill();
|
||||||
|
this._eventListeners.push(helper.addEventListener(this._client, 'Page.lifecycleEvent', event => this._onLifecycleEvent(event)));
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
this._client.send('Log.enable', {}),
|
this._client.send('Log.enable', {}),
|
||||||
this._client.send('Page.setLifecycleEventsEnabled', { enabled: true }).then(() => {
|
lifecycleEventsEnabled = this._client.send('Page.setLifecycleEventsEnabled', { enabled: true }),
|
||||||
isInitialLifecycle = true;
|
|
||||||
}),
|
|
||||||
this._client.send('Runtime.enable', {}),
|
this._client.send('Runtime.enable', {}),
|
||||||
this._client.send('Page.addScriptToEvaluateOnNewDocument', {
|
this._client.send('Page.addScriptToEvaluateOnNewDocument', {
|
||||||
source: sourceMap.generateSourceUrl(),
|
source: sourceMap.generateSourceUrl(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue