2021-07-06 21:16:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								/ * *  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Copyright  2018  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 . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-25 15:05:50 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  {  browserTest  as  it ,  expect  }  from  '../config/browserTest' ;  
						 
					
						
							
								
									
										
										
										
											2021-07-06 21:16:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 19:42:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								it ( 'should construct a new URL when a baseURL in browser.newContext is passed to page.goto @smoke' ,  async  function ( {  browser ,  server  } )  {  
						 
					
						
							
								
									
										
										
										
											2021-07-06 21:16:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  const  context  =  await  browser . newContext ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    baseURL : server.PREFIX , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  page  =  await  context . newPage ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-23 09:31:30 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( ( await  page . goto ( '/empty.html' ) ) ! . url ( ) ) . toBe ( server . EMPTY_PAGE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-06 21:16:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  await  context . close ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-27 18:58:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								it ( 'should construct a new URL when a baseURL in browser.newPage is passed to page.goto' ,  async  function ( {  browser ,  server  } )  {  
						 
					
						
							
								
									
										
										
										
											2021-07-06 21:16:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  const  page  =  await  browser . newPage ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    baseURL : server.PREFIX , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-23 09:31:30 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( ( await  page . goto ( '/empty.html' ) ) ! . url ( ) ) . toBe ( server . EMPTY_PAGE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-06 21:16:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  await  page . close ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-27 18:00:06 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								it ( 'should construct a new URL when a baseURL in browserType.launchPersistentContext is passed to page.goto' ,  async  function ( {  browserType ,  server ,  createUserDataDir  } )  {  
						 
					
						
							
								
									
										
										
										
											2021-07-13 21:11:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  const  userDataDir  =  await  createUserDataDir ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  context  =  await  browserType . launchPersistentContext ( userDataDir ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    baseURL : server.PREFIX , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  page  =  await  context . newPage ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-23 09:31:30 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( ( await  page . goto ( '/empty.html' ) ) ! . url ( ) ) . toBe ( server . EMPTY_PAGE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-13 21:11:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  await  context . close ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-27 18:58:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								it ( 'should construct the URLs correctly when a baseURL without a trailing slash in browser.newPage is passed to page.goto' ,  async  function ( {  browser ,  server  } )  {  
						 
					
						
							
								
									
										
										
										
											2021-07-06 21:16:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  const  page  =  await  browser . newPage ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    baseURL : server.PREFIX  +  '/url-construction' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-23 09:31:30 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( ( await  page . goto ( 'mypage.html' ) ) ! . url ( ) ) . toBe ( server . PREFIX  +  '/mypage.html' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( ( await  page . goto ( './mypage.html' ) ) ! . url ( ) ) . toBe ( server . PREFIX  +  '/mypage.html' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( ( await  page . goto ( '/mypage.html' ) ) ! . url ( ) ) . toBe ( server . PREFIX  +  '/mypage.html' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-06 21:16:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  await  page . close ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-27 18:58:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								it ( 'should construct the URLs correctly when a baseURL with a trailing slash in browser.newPage is passed to page.goto' ,  async  function ( {  browser ,  server  } )  {  
						 
					
						
							
								
									
										
										
										
											2021-07-06 21:16:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  const  page  =  await  browser . newPage ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    baseURL : server.PREFIX  +  '/url-construction/' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-23 09:31:30 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( ( await  page . goto ( 'mypage.html' ) ) ! . url ( ) ) . toBe ( server . PREFIX  +  '/url-construction/mypage.html' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( ( await  page . goto ( './mypage.html' ) ) ! . url ( ) ) . toBe ( server . PREFIX  +  '/url-construction/mypage.html' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( ( await  page . goto ( '/mypage.html' ) ) ! . url ( ) ) . toBe ( server . PREFIX  +  '/mypage.html' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( ( await  page . goto ( '.' ) ) ! . url ( ) ) . toBe ( server . PREFIX  +  '/url-construction/' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( ( await  page . goto ( '/' ) ) ! . url ( ) ) . toBe ( server . PREFIX  +  '/' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-06 21:16:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  await  page . close ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-27 18:58:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								it ( 'should not construct a new URL when valid URLs are passed' ,  async  function ( {  browser ,  server  } )  {  
						 
					
						
							
								
									
										
										
										
											2021-07-06 21:16:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  const  page  =  await  browser . newPage ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    baseURL :  'http://microsoft.com' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-23 09:31:30 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  expect ( ( await  page . goto ( server . EMPTY_PAGE ) ) ! . url ( ) ) . toBe ( server . EMPTY_PAGE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-06 21:16:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  page . goto ( 'data:text/html,Hello world' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( await  page . evaluate ( ( )  = >  window . location . href ) ) . toBe ( 'data:text/html,Hello world' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  page . goto ( 'about:blank' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( await  page . evaluate ( ( )  = >  window . location . href ) ) . toBe ( 'about:blank' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  page . close ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-27 18:58:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								it ( 'should be able to match a URL relative to its given URL with urlMatcher' ,  async  function ( {  browser ,  server  } )  {  
						 
					
						
							
								
									
										
										
										
											2021-07-06 21:16:37 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  const  page  =  await  browser . newPage ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    baseURL : server.PREFIX  +  '/foobar/' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  page . goto ( '/kek/index.html' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  page . waitForURL ( '/kek/index.html' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( page . url ( ) ) . toBe ( server . PREFIX  +  '/kek/index.html' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  page . route ( './kek/index.html' ,  route  = >  route . fulfill ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    body :  'base-url-matched-route' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  const  [ request ,  response ]  =  await  Promise . all ( [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    page . waitForRequest ( './kek/index.html' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    page . waitForResponse ( './kek/index.html' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    page . goto ( './kek/index.html' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( request . url ( ) ) . toBe ( server . PREFIX  +  '/foobar/kek/index.html' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( response . url ( ) ) . toBe ( server . PREFIX  +  '/foobar/kek/index.html' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  expect ( ( await  response . body ( ) ) . toString ( ) ) . toBe ( 'base-url-matched-route' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  page . close ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2021-07-13 21:11:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-27 18:58:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								it ( 'should not construct a new URL with baseURL when a glob was used' ,  async  function ( {  browser ,  server  } )  {  
						 
					
						
							
								
									
										
										
										
											2021-07-13 21:11:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  const  page  =  await  browser . newPage ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    baseURL : server.PREFIX  +  '/foobar/' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  page . goto ( './kek/index.html' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  page . waitForURL ( '**/foobar/kek/index.html' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  await  page . close ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;