| 
									
										
										
										
											2020-08-04 15:57:25 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Copyright 2017 Google Inc. All rights reserved. | 
					
						
							|  |  |  |  * Modifications copyright (c) Microsoft Corporation. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
					
						
							|  |  |  |  * you may not use this file except in compliance with the License. | 
					
						
							|  |  |  |  * You may obtain a copy of the License at | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *     http://www.apache.org/licenses/LICENSE-2.0
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  |  * distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  |  * See the License for the specific language governing permissions and | 
					
						
							|  |  |  |  * limitations under the License. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:12:14 -07:00
										 |  |  | import fs from 'fs'; | 
					
						
							| 
									
										
										
										
											2022-03-25 15:05:50 -08:00
										 |  |  | import { playwrightTest as test, expect } from '../config/browserTest'; | 
					
						
							| 
									
										
										
										
											2021-04-01 16:35:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-25 16:47:04 -07:00
										 |  |  | test('browserType.executablePath should work', async ({ browserType, channel, mode }) => { | 
					
						
							| 
									
										
										
										
											2021-05-13 10:22:23 -07:00
										 |  |  |   test.skip(!!channel, 'We skip browser download when testing a channel'); | 
					
						
							| 
									
										
										
										
											2023-07-25 16:47:04 -07:00
										 |  |  |   test.skip(mode.startsWith('service')); | 
					
						
							| 
									
										
										
										
											2021-10-27 18:00:06 -08:00
										 |  |  |   test.skip(!!(browserType as any)._defaultLaunchOptions.executablePath, 'Skip with custom executable path'); | 
					
						
							| 
									
										
										
										
											2020-08-04 15:57:25 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   const executablePath = browserType.executablePath(); | 
					
						
							|  |  |  |   expect(fs.existsSync(executablePath)).toBe(true); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-27 18:58:08 +02:00
										 |  |  | test('browserType.name should work', async ({ browserType, browserName }) => { | 
					
						
							| 
									
										
										
										
											2021-04-01 16:35:26 -07:00
										 |  |  |   expect(browserType.name()).toBe(browserName); | 
					
						
							| 
									
										
										
										
											2020-08-04 15:57:25 -07:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2021-04-01 16:35:26 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | test('should throw when trying to connect with not-chromium', async ({ browserType, browserName }) => { | 
					
						
							| 
									
										
										
										
											2021-02-10 16:22:18 -08:00
										 |  |  |   test.skip(browserName === 'chromium'); | 
					
						
							| 
									
										
										
										
											2021-04-01 16:35:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-27 18:58:08 +02:00
										 |  |  |   const error = await browserType.connectOverCDP({ endpointURL: 'ws://foo' }).catch(e => e); | 
					
						
							| 
									
										
										
										
											2021-02-10 16:22:18 -08:00
										 |  |  |   expect(error.message).toBe('Connecting over CDP is only supported in Chromium.'); | 
					
						
							|  |  |  | }); |