mirror of
				https://github.com/microsoft/playwright.git
				synced 2025-06-26 21:40:17 +00:00 
			
		
		
		
	fix(firefox): fix launching firefox without dependencies (#2900)
We always have to reject promises with some error. Otherwise, our error-rewriting logic in try-catch miserably fails. With this patch, attempt to launch Firefox when it's missing dependencies will actually result in a thrown exception with pretty logs. Without this patch, Playwright throws internal error.
This commit is contained in:
		
							parent
							
								
									1cebf8757c
								
							
						
					
					
						commit
						a403d4beff
					
				| @ -166,11 +166,12 @@ export async function launchProcess(options: LaunchProcessOptions): Promise<Laun | |||||||
| export function waitForLine(progress: Progress, process: childProcess.ChildProcess, inputStream: stream.Readable, regex: RegExp): Promise<RegExpMatchArray> { | export function waitForLine(progress: Progress, process: childProcess.ChildProcess, inputStream: stream.Readable, regex: RegExp): Promise<RegExpMatchArray> { | ||||||
|   return new Promise((resolve, reject) => { |   return new Promise((resolve, reject) => { | ||||||
|     const rl = readline.createInterface({ input: inputStream }); |     const rl = readline.createInterface({ input: inputStream }); | ||||||
|  |     const failError = new Error('Process failed to launch!'); | ||||||
|     const listeners = [ |     const listeners = [ | ||||||
|       helper.addEventListener(rl, 'line', onLine), |       helper.addEventListener(rl, 'line', onLine), | ||||||
|       helper.addEventListener(rl, 'close', reject), |       helper.addEventListener(rl, 'close', reject.bind(null, failError)), | ||||||
|       helper.addEventListener(process, 'exit', reject), |       helper.addEventListener(process, 'exit', reject.bind(null, failError)), | ||||||
|       helper.addEventListener(process, 'error', reject) |       helper.addEventListener(process, 'error', reject.bind(null, failError)) | ||||||
|     ]; |     ]; | ||||||
| 
 | 
 | ||||||
|     progress.cleanupWhenAborted(cleanup); |     progress.cleanupWhenAborted(cleanup); | ||||||
|  | |||||||
							
								
								
									
										3
									
								
								test/assets/dummy_bad_browser_executable.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										3
									
								
								test/assets/dummy_bad_browser_executable.js
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,3 @@ | |||||||
|  | #!/usr/bin/env node
 | ||||||
|  | 
 | ||||||
|  | process.exit(1); | ||||||
| @ -44,6 +44,12 @@ describe('Playwright', function() { | |||||||
|       await browserType.launch(options).catch(e => waitError = e); |       await browserType.launch(options).catch(e => waitError = e); | ||||||
|       expect(waitError.message).toContain('can not specify page'); |       expect(waitError.message).toContain('can not specify page'); | ||||||
|     }); |     }); | ||||||
|  |     it('should reject if launched browser fails immediately', async({browserType, defaultBrowserOptions}) => { | ||||||
|  |       const options = Object.assign({}, defaultBrowserOptions, {executablePath: path.join(__dirname, 'assets', 'dummy_bad_browser_executable.js')}); | ||||||
|  |       let waitError = null; | ||||||
|  |       await browserType.launch(options).catch(e => waitError = e); | ||||||
|  |       expect(waitError.message).toContain('browserType.launch logs'); | ||||||
|  |     }); | ||||||
|     it('should reject if executable path is invalid', async({browserType, defaultBrowserOptions}) => { |     it('should reject if executable path is invalid', async({browserType, defaultBrowserOptions}) => { | ||||||
|       let waitError = null; |       let waitError = null; | ||||||
|       const options = Object.assign({}, defaultBrowserOptions, {executablePath: 'random-invalid-path'}); |       const options = Object.assign({}, defaultBrowserOptions, {executablePath: 'random-invalid-path'}); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Andrey Lushnikov
						Andrey Lushnikov