2020-08-03 13:41:48 -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-09-02 21:43:38 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-11 23:40:49 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import domain from 'domain';
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-25 15:05:50 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import { playwrightTest as it, expect } from '../config/browserTest';
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-25 23:30:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-05-17 14:56:39 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								// Use something worker-scoped (e.g. launch args) to force a new worker for this file.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// Otherwise, a browser launched for other tests in this worker will affect the expectations.
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-26 12:45:53 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								it.use({
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  launchOptions: async ({ launchOptions }, use) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await use({ ...launchOptions, args: [] });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							
								
									
										
										
										
											2021-05-17 14:56:39 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-13 14:03:47 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								it.skip(({ mode }) => mode === 'service');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-27 18:00:06 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								it('should scope context handles', async ({ browserType, server }) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const browser = await browserType.launch();
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const GOLDEN_PRECONDITION = {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    _guid: '',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    objects: [
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'android', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        { _guid: 'browser', objects: [] }
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      ] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'electron', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-09 17:21:17 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'localUtils', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'Playwright', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'selectors', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await expectScopeState(browser, GOLDEN_PRECONDITION);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const context = await browser.newContext();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const page = await context.newPage();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-15 17:33:09 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  // Firefox Beta 96 yields a console warning for the pages that
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // don't use `<!DOCTYPE HTML> tag.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await page.goto(server.PREFIX + '/empty-standard-mode.html');
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await expectScopeState(browser, {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    _guid: '',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    objects: [
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'android', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        { _guid: 'browser', objects: [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          { _guid: 'browser-context', objects: [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            { _guid: 'frame', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-09-27 18:58:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            { _guid: 'page', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-05-13 10:29:14 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            { _guid: 'request', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            { _guid: 'response', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-09-27 18:58:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          ] },
							 | 
						
					
						
							
								
									
										
										
										
											2022-01-22 11:25:13 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          { _guid: 'fetchRequest', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          { _guid: 'Tracing', objects: [] }
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        ] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      ] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'electron', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-09 17:21:17 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'localUtils', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'Playwright', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'selectors', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await context.close();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await expectScopeState(browser, GOLDEN_PRECONDITION);
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-02 21:07:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  await browser.close();
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-27 18:00:06 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								it('should scope CDPSession handles', async ({ browserType, browserName }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-02 21:07:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  it.skip(browserName !== 'chromium');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-27 18:00:06 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const browser = await browserType.launch();
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const GOLDEN_PRECONDITION = {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    _guid: '',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    objects: [
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'android', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        { _guid: 'browser', objects: [] }
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      ] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'electron', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-09 17:21:17 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'localUtils', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'Playwright', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'selectors', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await expectScopeState(browserType, GOLDEN_PRECONDITION);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-02 09:47:14 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const session = await browser.newBrowserCDPSession();
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await expectScopeState(browserType, {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    _guid: '',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    objects: [
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'android', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        { _guid: 'browser', objects: [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          { _guid: 'cdp-session', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        ] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      ] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'electron', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-09 17:21:17 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'localUtils', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'Playwright', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'selectors', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await session.detach();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await expectScopeState(browserType, GOLDEN_PRECONDITION);
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-02 21:07:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await browser.close();
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-27 18:00:06 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								it('should scope browser handles', async ({ browserType }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const GOLDEN_PRECONDITION = {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    _guid: '',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    objects: [
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'android', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'electron', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-09 17:21:17 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'localUtils', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'Playwright', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'selectors', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await expectScopeState(browserType, GOLDEN_PRECONDITION);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-27 18:00:06 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const browser = await browserType.launch();
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await browser.newContext();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await expectScopeState(browserType, {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    _guid: '',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    objects: [
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'android', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'browser-type', objects: [
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-02 23:22:23 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        {
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          _guid: 'browser', objects: [
							 | 
						
					
						
							
								
									
										
										
										
											2021-09-14 18:31:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            { _guid: 'browser-context', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2022-01-22 11:25:13 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            { _guid: 'fetchRequest', objects: [] },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            { _guid: 'Tracing', objects: [] }
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-02 23:22:23 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      },
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'electron', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-09 17:21:17 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'localUtils', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'Playwright', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-20 23:03:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      { _guid: 'selectors', objects: [] },
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await browser.close();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await expectScopeState(browserType, GOLDEN_PRECONDITION);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-27 18:00:06 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								it('should work with the domain module', async ({ browserType, server, browserName }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-01 13:18:04 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const local = domain.create();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  local.run(() => { });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  let err;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  local.on('error', e => err = e);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-27 18:00:06 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const browser = await browserType.launch();
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-11 23:40:49 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const page = await browser.newPage();
							 | 
						
					
						
							
								
									
										
										
										
											2020-11-19 12:09:42 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  expect(await page.evaluate(() => 1 + 1)).toBe(2);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // At the time of writing, we used to emit 'error' event for WebSockets,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // which failed with 'domain' module.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  let callback;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const result = new Promise(f => callback = f);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  page.on('websocket', ws => ws.on('socketerror', callback));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  page.evaluate(port => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    new WebSocket('ws://localhost:' + port + '/bogus-ws');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }, server.PORT);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const message = await result;
							 | 
						
					
						
							
								
									
										
										
										
											2021-05-13 10:22:23 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (browserName === 'firefox')
							 | 
						
					
						
							
								
									
										
										
										
											2020-11-19 12:09:42 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    expect(message).toBe('CLOSE_ABNORMAL');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(message).toContain(': 400');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-11 23:40:49 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  await browser.close();
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-01 13:18:04 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (err)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    throw err;
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-11 23:40:49 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-03 13:41:48 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								async function expectScopeState(object, golden) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  golden = trimGuids(golden);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const remoteState = trimGuids(await object._channel.debugScopeState());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const localState = trimGuids(object._connection._debugScopeState());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  expect(localState).toEqual(golden);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  expect(remoteState).toEqual(golden);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								function compareObjects(a, b) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (a._guid !== b._guid)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return a._guid.localeCompare(b._guid);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return a.objects.length - b.objects.length;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								function trimGuids(object) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (Array.isArray(object))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return object.map(trimGuids).sort(compareObjects);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (typeof object === 'object') {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const result = {};
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for (const key in object)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      result[key] = trimGuids(object[key]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return result;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (typeof object === 'string')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return object ? object.match(/[^@]+/)[0] : '';
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return object;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |