mirror of
				https://github.com/microsoft/playwright.git
				synced 2025-06-26 21:40:17 +00:00 
			
		
		
		
	fix: don't throw error on about:blank when blocking ServiceWorker (#32310)
Fixes https://github.com/microsoft/playwright/issues/32292
This commit is contained in:
		
							parent
							
								
									5acd2dbf48
								
							
						
					
					
						commit
						596f497633
					
				| @ -142,7 +142,7 @@ export abstract class BrowserContext extends SdkObject { | |||||||
|     if (debugMode() === 'console') |     if (debugMode() === 'console') | ||||||
|       await this.extendInjectedScript(consoleApiSource.source); |       await this.extendInjectedScript(consoleApiSource.source); | ||||||
|     if (this._options.serviceWorkers === 'block') |     if (this._options.serviceWorkers === 'block') | ||||||
|       await this.addInitScript(`\nnavigator.serviceWorker.register = async () => { console.warn('Service Worker registration blocked by Playwright'); };\n`); |       await this.addInitScript(`\nif (navigator.serviceWorker) navigator.serviceWorker.register = async () => { console.warn('Service Worker registration blocked by Playwright'); };\n`); | ||||||
| 
 | 
 | ||||||
|     if (this._options.permissions) |     if (this._options.permissions) | ||||||
|       await this.grantPermissions(this._options.permissions); |       await this.grantPermissions(this._options.permissions); | ||||||
|  | |||||||
| @ -29,4 +29,12 @@ it.describe('block', () => { | |||||||
|       page.goto(server.PREFIX + '/serviceworkers/empty/sw.html'), |       page.goto(server.PREFIX + '/serviceworkers/empty/sw.html'), | ||||||
|     ]); |     ]); | ||||||
|   }); |   }); | ||||||
|  | 
 | ||||||
|  |   it('should not throw error on about:blank', async ({ page }) => { | ||||||
|  |     it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/32292' }); | ||||||
|  |     const errors = []; | ||||||
|  |     page.on('pageerror', error => errors.push(error)); | ||||||
|  |     await page.goto('about:blank'); | ||||||
|  |     expect(errors).toEqual([]); | ||||||
|  |   }); | ||||||
| }); | }); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Max Schmitt
						Max Schmitt