mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-14 21:53:35 +03:00
fix(webkit): unflake Page.setContent (#786)
This commit is contained in:
parent
2bf88fd178
commit
c57fd22382
@ -84,11 +84,11 @@ export class WKPage implements PageDelegate {
|
||||
this._workers.setSession(session);
|
||||
}
|
||||
|
||||
async initialize(session: WKSession, pagePausedOnStart: boolean) {
|
||||
async initialize(session: WKSession) {
|
||||
this._setSession(session);
|
||||
await Promise.all([
|
||||
this._initializePageProxySession(),
|
||||
this._initializeSession(this._session, ({frameTree}) => this._handleFrameTree(frameTree, pagePausedOnStart)),
|
||||
this._initializeSession(this._session, ({frameTree}) => this._handleFrameTree(frameTree)),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -240,26 +240,14 @@ export class WKPage implements PageDelegate {
|
||||
this._page._frameManager.frameLifecycleEvent(frameId, event);
|
||||
}
|
||||
|
||||
private _handleFrameTree(frameTree: Protocol.Page.FrameResourceTree, pagePausedOnStart: boolean) {
|
||||
const frame = this._onFrameAttached(frameTree.frame.id, frameTree.frame.parentId || null);
|
||||
private _handleFrameTree(frameTree: Protocol.Page.FrameResourceTree) {
|
||||
this._onFrameAttached(frameTree.frame.id, frameTree.frame.parentId || null);
|
||||
this._onFrameNavigated(frameTree.frame, true);
|
||||
|
||||
if (!pagePausedOnStart) {
|
||||
frame._utilityContext().then(async context => {
|
||||
const readyState = await context.evaluate(() => document.readyState).catch(e => 'loading');
|
||||
if (frame.isDetached())
|
||||
return;
|
||||
if (readyState === 'interactive' || readyState === 'complete')
|
||||
this._page._frameManager.frameLifecycleEvent(frame._id, 'domcontentloaded');
|
||||
if (readyState === 'complete')
|
||||
this._page._frameManager.frameLifecycleEvent(frame._id, 'load');
|
||||
});
|
||||
}
|
||||
|
||||
if (!frameTree.childFrames)
|
||||
return;
|
||||
for (const child of frameTree.childFrames)
|
||||
this._handleFrameTree(child, pagePausedOnStart);
|
||||
this._handleFrameTree(child);
|
||||
}
|
||||
|
||||
_onFrameAttached(frameId: string, parentFrameId: string | null): frames.Frame {
|
||||
|
@ -97,10 +97,8 @@ export class WKPageProxy {
|
||||
}
|
||||
|
||||
onPopupCreated(popupPageProxy: WKPageProxy) {
|
||||
const wkPage = this._wkPage;
|
||||
if (!wkPage || !wkPage._page.listenerCount(Events.Page.Popup))
|
||||
return;
|
||||
popupPageProxy.page().then(page => wkPage._page.emit(Events.Page.Popup, page));
|
||||
if (this._wkPage)
|
||||
popupPageProxy.page().then(page => this._wkPage!._page.emit(Events.Page.Popup, page));
|
||||
}
|
||||
|
||||
private async _initializeWKPage(): Promise<Page> {
|
||||
@ -114,7 +112,7 @@ export class WKPageProxy {
|
||||
}
|
||||
assert(session, 'One non-provisional target session must exist');
|
||||
this._wkPage = new WKPage(this._browserContext, this._pageProxySession);
|
||||
await this._wkPage.initialize(session!, this._pagePausedOnStart);
|
||||
await this._wkPage.initialize(session!);
|
||||
if (this._pagePausedOnStart) {
|
||||
this._resumeTarget(session!.sessionId);
|
||||
this._pagePausedOnStart = false;
|
||||
|
Loading…
Reference in New Issue
Block a user