mirror of
				https://github.com/microsoft/playwright.git
				synced 2025-06-26 21:40:17 +00: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); |     this._workers.setSession(session); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   async initialize(session: WKSession, pagePausedOnStart: boolean) { |   async initialize(session: WKSession) { | ||||||
|     this._setSession(session); |     this._setSession(session); | ||||||
|     await Promise.all([ |     await Promise.all([ | ||||||
|       this._initializePageProxySession(), |       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); |     this._page._frameManager.frameLifecycleEvent(frameId, event); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   private _handleFrameTree(frameTree: Protocol.Page.FrameResourceTree, pagePausedOnStart: boolean) { |   private _handleFrameTree(frameTree: Protocol.Page.FrameResourceTree) { | ||||||
|     const frame = this._onFrameAttached(frameTree.frame.id, frameTree.frame.parentId || null); |     this._onFrameAttached(frameTree.frame.id, frameTree.frame.parentId || null); | ||||||
|     this._onFrameNavigated(frameTree.frame, true); |     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) |     if (!frameTree.childFrames) | ||||||
|       return; |       return; | ||||||
|     for (const child of frameTree.childFrames) |     for (const child of frameTree.childFrames) | ||||||
|       this._handleFrameTree(child, pagePausedOnStart); |       this._handleFrameTree(child); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   _onFrameAttached(frameId: string, parentFrameId: string | null): frames.Frame { |   _onFrameAttached(frameId: string, parentFrameId: string | null): frames.Frame { | ||||||
|  | |||||||
| @ -97,10 +97,8 @@ export class WKPageProxy { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   onPopupCreated(popupPageProxy: WKPageProxy) { |   onPopupCreated(popupPageProxy: WKPageProxy) { | ||||||
|     const wkPage = this._wkPage; |     if (this._wkPage) | ||||||
|     if (!wkPage || !wkPage._page.listenerCount(Events.Page.Popup)) |       popupPageProxy.page().then(page => this._wkPage!._page.emit(Events.Page.Popup, page)); | ||||||
|       return; |  | ||||||
|     popupPageProxy.page().then(page => wkPage._page.emit(Events.Page.Popup, page)); |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   private async _initializeWKPage(): Promise<Page> { |   private async _initializeWKPage(): Promise<Page> { | ||||||
| @ -114,7 +112,7 @@ export class WKPageProxy { | |||||||
|     } |     } | ||||||
|     assert(session, 'One non-provisional target session must exist'); |     assert(session, 'One non-provisional target session must exist'); | ||||||
|     this._wkPage = new WKPage(this._browserContext, this._pageProxySession); |     this._wkPage = new WKPage(this._browserContext, this._pageProxySession); | ||||||
|     await this._wkPage.initialize(session!, this._pagePausedOnStart); |     await this._wkPage.initialize(session!); | ||||||
|     if (this._pagePausedOnStart) { |     if (this._pagePausedOnStart) { | ||||||
|       this._resumeTarget(session!.sessionId); |       this._resumeTarget(session!.sessionId); | ||||||
|       this._pagePausedOnStart = false; |       this._pagePausedOnStart = false; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Yury Semikhatsky
						Yury Semikhatsky