2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/*
  
						 
					
						
							
								
									
										
										
										
											2024-10-04 13:19:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								 *  Copyright  ( c )  2022 - 2024 ,  Andreas  Kling  < andreas @ ladybird . org > 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-26 22:33:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								 *  Copyright  ( c )  2023 - 2025 ,  Aliaksandr  Kalenik  < kalenik . aliaksandr @ gmail . com > 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 14:30:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								 *  Copyright  ( c )  2025 ,  Luke  Wilde  < luke @ ladybird . org > 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								 *  SPDX - License - Identifier :  BSD - 2 - Clause 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-08 14:17:54 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/SystemColor.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:50:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/ContentSecurityPolicy/BlockingAlgorithms.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/ContentSecurityPolicy/Directives/DirectiveOperations.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:01:26 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/ContentSecurityPolicy/PolicyList.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:50:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/ContentSecurityPolicy/Violation.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Crypto/Crypto.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/DOM/Document.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/DOM/DocumentLoading.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-01-18 12:52:13 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/DOM/Event.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-04-26 16:59:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/DOM/Range.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-10-14 16:07:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/DOM/Text.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Fetch/Fetching/Fetching.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Fetch/Infrastructure/FetchAlgorithms.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Fetch/Infrastructure/FetchController.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Fetch/Infrastructure/HTTP/Requests.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Fetch/Infrastructure/URL.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/BrowsingContext.h> 
  
						 
					
						
							
								
									
										
										
										
											2025-01-05 17:21:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/BrowsingContextGroup.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/DocumentState.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/HTMLIFrameElement.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/HistoryHandlingBehavior.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/Navigable.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/Navigation.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-10-25 10:26:01 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/NavigationObserver.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/NavigationParams.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/POSTResource.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-12-19 16:16:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/Parser/HTMLParser.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/SandboxingFlagSet.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/Scripting/ClassicScript.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/SessionHistoryEntry.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/StructuredSerialize.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-12-12 12:07:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/TraversableNavigable.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-10-08 11:59:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/Window.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-02-04 03:44:19 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/WindowProxy.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-04-11 10:20:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Infra/Strings.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-08-22 16:00:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Layout/Node.h> 
  
						 
					
						
							
								
									
										
										
										
											2025-04-18 20:40:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Layout/Viewport.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-09-21 17:55:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Loader/GeneratedPagesLoader.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-09-19 19:16:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Page/Page.h> 
  
						 
					
						
							
								
									
										
										
										
											2025-07-10 19:24:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Painting/DisplayListPlayerSkia.h> 
  
						 
					
						
							
								
									
										
										
										
											2025-07-25 01:39:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Painting/NavigableContainerViewportPaintable.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-01-14 11:14:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Painting/Paintable.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-01-15 11:28:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Painting/ViewportPaintable.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Platform/EventLoopPlugin.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-04-26 16:59:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Selection/Selection.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/XHR/FormData.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								namespace  Web : : HTML  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC_DEFINE_ALLOCATOR ( Navigable ) ;  
						 
					
						
							
								
									
										
										
										
											2023-11-19 19:47:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-23 01:03:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								class  ResponseHolder  :  public  JS : : Cell  {  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC_CELL ( ResponseHolder ,  JS : : Cell ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    GC_DECLARE_ALLOCATOR ( ResponseHolder ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-23 01:03:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								public :  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    [[nodiscard]]  static  GC : : Ref < ResponseHolder >  create ( JS : : VM &  vm ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-23 01:03:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-14 06:13:46 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  vm . heap ( ) . allocate < ResponseHolder > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-23 01:03:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    [[nodiscard]]  GC : : Ptr < Fetch : : Infrastructure : : Response >  response ( )  const  {  return  m_response ;  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    void  set_response ( GC : : Ptr < Fetch : : Infrastructure : : Response >  response )  {  m_response  =  response ;  } 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-23 01:03:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    virtual  void  visit_edges ( Cell : : Visitor &  visitor )  override 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-03 15:48:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        Base : : visit_edges ( visitor ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-23 01:03:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        visitor . visit ( m_response ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								private :  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ptr < Fetch : : Infrastructure : : Response >  m_response ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-23 01:03:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC_DEFINE_ALLOCATOR ( ResponseHolder ) ;  
						 
					
						
							
								
									
										
										
										
											2023-11-19 19:47:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-17 14:18:36 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								HashTable < GC : : RawRef < Navigable > > &  all_navigables ( )  
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:43:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-01-17 14:18:36 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    static  HashTable < GC : : RawRef < Navigable > >  set ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:43:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  set ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 23:16:38 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/document-sequences.html#child-navigable
  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Vector < GC : : Root < Navigable > >  Navigable : : child_navigables ( )  const  
						 
					
						
							
								
									
										
										
										
											2023-04-06 23:16:38 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < GC : : Root < Navigable > >  results ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 23:16:38 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto &  entry  :  all_navigables ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( entry - > current_session_history_entry ( ) - > step ( )  = =  SessionHistoryEntry : : Pending : : Tag ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-01 22:13:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 23:16:38 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( entry - > parent ( )  = =  this ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            results . append ( entry ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  results ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  Navigable : : is_ancestor_of ( GC : : Ref < Navigable >  other )  const  
						 
					
						
							
								
									
										
										
										
											2024-04-19 15:38:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  ancestor  =  other - > parent ( ) ;  ancestor ;  ancestor  =  ancestor - > parent ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ancestor  = =  this ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-06-26 22:33:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								static  RefPtr < Gfx : : SkiaBackendContext >  g_cached_skia_backend_context ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								static  RefPtr < Gfx : : SkiaBackendContext >  get_skia_backend_context ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! g_cached_skia_backend_context )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# ifdef AK_OS_MACOS 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  metal_context  =  Gfx : : get_metal_context ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        g_cached_skia_backend_context  =  Gfx : : SkiaBackendContext : : create_metal_context ( * metal_context ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# elif USE_VULKAN 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  maybe_vulkan_context  =  Gfx : : create_vulkan_context ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( maybe_vulkan_context . is_error ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln ( " Vulkan context creation failed: {} " ,  maybe_vulkan_context . error ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  vulkan_context  =  maybe_vulkan_context . release_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        g_cached_skia_backend_context  =  Gfx : : SkiaBackendContext : : create_vulkan_context ( vulkan_context ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# endif 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  g_cached_skia_backend_context ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Navigable : : Navigable ( GC : : Ref < Page >  page ,  bool  is_svg_page )  
						 
					
						
							
								
									
										
										
										
											2024-04-26 14:55:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    :  m_page ( page ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-26 16:59:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    ,  m_event_handler ( { } ,  * this ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-26 22:33:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    ,  m_is_svg_page ( is_svg_page ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    ,  m_backing_store_manager ( heap ( ) . allocate < Painting : : BackingStoreManager > ( * this ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:43:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-01-17 14:18:36 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    all_navigables ( ) . set ( * this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-26 22:33:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! m_is_svg_page )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  display_list_player_type  =  page - > client ( ) . display_list_player_type ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        OwnPtr < Painting : : DisplayListPlayerSkia >  skia_player ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( display_list_player_type  = =  DisplayListPlayerType : : SkiaGPUIfAvailable )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            m_skia_backend_context  =  get_skia_backend_context ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            skia_player  =  make < Painting : : DisplayListPlayerSkia > ( m_skia_backend_context ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            skia_player  =  make < Painting : : DisplayListPlayerSkia > ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        m_rendering_thread . set_skia_player ( move ( skia_player ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        m_rendering_thread . start ( display_list_player_type ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:43:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-17 14:18:36 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Navigable : : ~ Navigable ( )  =  default ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : finalize ( )  
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:43:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-01-17 14:18:36 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    all_navigables ( ) . remove ( * this ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Base : : finalize ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:43:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : visit_edges ( Cell : : Visitor &  visitor )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Base : : visit_edges ( visitor ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-26 14:55:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    visitor . visit ( m_page ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    visitor . visit ( m_parent ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    visitor . visit ( m_current_session_history_entry ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    visitor . visit ( m_active_session_history_entry ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    visitor . visit ( m_container ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 10:26:01 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    visitor . visit ( m_navigation_observers ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-26 22:33:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    visitor . visit ( m_backing_store_manager ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-26 16:59:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    m_event_handler . visit_edges ( visitor ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto &  navigation_params  :  m_pending_navigations )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        navigation_params . visit_edges ( visitor ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : NavigateParams : : visit_edges ( Cell : : Visitor &  visitor )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    visitor . visit ( response ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    visitor . visit ( source_document ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    visitor . visit ( source_element ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:56:35 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/nav-history-apis.html#script-closable
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								bool  Navigable : : is_script_closable ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-05-03 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // A navigable is script-closable if it is a top-level traversable, and any of the following are true:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // - its is created by web content is true; or
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // - its session history entries's size is 1.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! is_top_level_traversable ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:56:35 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  as < TraversableNavigable > ( this ) - > is_created_by_web_content ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        | |  get_session_history_entries ( ) . size ( )  = =  1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:56:35 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-14 01:22:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : set_delaying_load_events ( bool  value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( value )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  document  =  container_document ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        VERIFY ( document ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        m_delaying_the_load_event . emplace ( * document ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        m_delaying_the_load_event . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC : : Ptr < Navigable >  Navigable : : navigable_with_active_document ( GC : : Ref < DOM : : Document >  document )  
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:43:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-01-17 14:18:36 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  navigable  :  all_navigables ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:43:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( navigable - > active_document ( )  = =  document ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  navigable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-25 20:46:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/document-sequences.html#initialize-the-navigable
  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								ErrorOr < void >  Navigable : : initialize_navigable ( GC : : Ref < DocumentState >  document_state ,  GC : : Ptr < Navigable >  parent )  
						 
					
						
							
								
									
										
										
										
											2023-04-25 20:46:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    static  int  next_id  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-14 10:05:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    m_id  =  String : : number ( next_id + + ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-25 20:46:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-28 13:20:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Assert: documentState's document is non-null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( document_state - > document ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-25 20:46:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-28 13:20:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Let entry be a new session history entry, with
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ref < SessionHistoryEntry >  entry  =  * heap ( ) . allocate < SessionHistoryEntry > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-25 20:46:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // URL: document's URL
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    entry - > set_url ( document_state - > document ( ) - > url ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-25 20:46:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // document state: documentState
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    entry - > set_document_state ( document_state ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-25 20:46:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-28 13:20:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Set navigable's current session history entry to entry.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-25 20:46:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    m_current_session_history_entry  =  entry ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-28 13:20:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. Set navigable's active session history entry to entry.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-25 20:46:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    m_active_session_history_entry  =  entry ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-28 13:20:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. Set navigable's parent to parent.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-25 20:46:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    m_parent  =  parent ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 23:30:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#getting-the-target-history-entry
  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC : : Ptr < SessionHistoryEntry >  Navigable : : get_the_target_history_entry ( int  target_step )  const  
						 
					
						
							
								
									
										
										
										
											2023-04-06 23:30:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Let entries be the result of getting session history entries for navigable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  entries  =  get_session_history_entries ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Return the item in entries that has the greatest step less than or equal to step.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ptr < SessionHistoryEntry >  result  =  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 23:30:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto &  entry  :  entries )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  entry_step  =  entry - > step ( ) . get < int > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 23:30:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( entry_step  < =  target_step )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! result  | |  result - > step ( ) . get < int > ( )  <  entry_step )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 23:30:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                result  =  entry ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  result ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 23:33:21 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#activate-history-entry
  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : activate_history_entry ( GC : : Ptr < SessionHistoryEntry >  entry )  
						 
					
						
							
								
									
										
										
										
											2023-04-06 23:33:21 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: 1. Save persisted state to the navigable's active session history entry.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Let newDocument be entry's document.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ptr < DOM : : Document >  new_document  =  entry - > document ( ) . ptr ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 23:33:21 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Assert: newDocument's is initial about:blank is false, i.e., we never traverse
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    back to the initial about:blank Document because it always gets replaced when we
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    navigate away from it.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( ! new_document - > is_initial_about_blank ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. Set navigable's active session history entry to entry.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_active_session_history_entry  =  entry ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. Make active newDocument.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    new_document - > make_active ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 10:26:01 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( m_ongoing_navigation . has < Empty > ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto  navigation_observer  :  m_navigation_observers )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( navigation_observer - > navigation_complete ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                navigation_observer - > navigation_complete ( ) - > function ( ) ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 23:33:21 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-document
  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC : : Ptr < DOM : : Document >  Navigable : : active_document ( )  
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // A navigable's active document is its active session history entry's document.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 16:14:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  m_active_session_history_entry - > document ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-bc
  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC : : Ptr < BrowsingContext >  Navigable : : active_browsing_context ( )  
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // A navigable's active browsing context is its active document's browsing context.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // If this navigable is a traversable navigable, then its active browsing context will be a top-level browsing context.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  document  =  active_document ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  document - > browsing_context ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-wp
  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC : : Ptr < HTML : : WindowProxy >  Navigable : : active_window_proxy ( )  
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // A navigable's active WindowProxy is its active browsing context's associated WindowProxy.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  browsing_context  =  active_browsing_context ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  browsing_context - > window_proxy ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-window
  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC : : Ptr < HTML : : Window >  Navigable : : active_window ( )  
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // A navigable's active window is its active WindowProxy's [[Window]].
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  window_proxy  =  active_window_proxy ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  window_proxy - > window ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-target
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								String  Navigable : : target_name ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-08-31 20:51:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // A navigable's target name is its active session history entry's document state's navigable target name.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  active_session_history_entry ( ) - > document_state ( ) - > navigable_target_name ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-container
  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC : : Ptr < NavigableContainer >  Navigable : : container ( )  const  
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // The container of a navigable navigable is the navigable container whose nested navigable is navigable, or null if there is no such element.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-23 17:50:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  NavigableContainer : : navigable_container_with_content_navigable ( const_cast < Navigable & > ( * this ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-16 12:05:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-container-document
  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC : : Ptr < DOM : : Document >  Navigable : : container_document ( )  const  
						 
					
						
							
								
									
										
										
										
											2022-12-16 12:05:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  container  =  this - > container ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. If navigable's container is null, then return null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! container ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Return navigable's container's node document.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  container - > document ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-12 12:07:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-traversable
  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC : : Ptr < TraversableNavigable >  Navigable : : traversable_navigable ( )  const  
						 
					
						
							
								
									
										
										
										
											2022-12-12 12:07:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Let navigable be inputNavigable.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 12:06:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  navigable  =  const_cast < Navigable * > ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-12 12:07:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. While navigable is not a traversable navigable, set navigable to navigable's parent.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( navigable  & &  ! is < TraversableNavigable > ( * navigable ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        navigable  =  navigable - > parent ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Return navigable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  static_cast < TraversableNavigable * > ( navigable ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-12 12:17:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-top
  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC : : Ptr < TraversableNavigable >  Navigable : : top_level_traversable ( )  
						 
					
						
							
								
									
										
										
										
											2022-12-12 12:17:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Let navigable be inputNavigable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  navigable  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. While navigable's parent is not null, set navigable to navigable's parent.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( navigable - > parent ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        navigable  =  navigable - > parent ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Return navigable.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-21 09:12:05 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  as < TraversableNavigable > ( navigable ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-12 12:17:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 15:22:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#set-the-ongoing-navigation
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : set_ongoing_navigation ( Variant < Empty ,  Traversal ,  String >  ongoing_navigation )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. If navigable's ongoing navigation is equal to newValue, then return.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( m_ongoing_navigation  = =  ongoing_navigation ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 23:21:16 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Inform the navigation API about aborting navigation given navigable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    inform_the_navigation_api_about_aborting_navigation ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 15:22:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Set navigable's ongoing navigation to newValue.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_ongoing_navigation  =  ongoing_navigation ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/document-sequences.html#the-rules-for-choosing-a-navigable
  
						 
					
						
							
								
									
										
										
										
											2024-05-28 09:12:18 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Navigable : : ChosenNavigable  Navigable : : choose_a_navigable ( StringView  name ,  TokenizedFeature : : NoOpener  no_opener ,  ActivateTab  activate_tab ,  Optional < TokenizedFeature : : Map  const & >  window_features )  
						 
					
						
							
								
									
										
										
										
											2023-04-11 10:20:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Let chosen be null.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ptr < Navigable >  chosen  =  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 10:20:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Let windowType be "existing or none".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  window_type  =  WindowType : : ExistingOrNone ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Let sandboxingFlagSet be currentNavigable's active document's active sandboxing flag set.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  sandboxing_flag_set  =  active_document ( ) - > active_sandboxing_flag_set ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 10:20:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. If name is the empty string or an ASCII case-insensitive match for "_self", then set chosen to currentNavigable.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-18 15:04:56 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( name . is_empty ( )  | |  name . equals_ignoring_ascii_case ( " _self " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 10:20:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        chosen  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 10:20:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. Otherwise, if name is an ASCII case-insensitive match for "_parent",
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    set chosen to currentNavigable's parent, if any, and currentNavigable otherwise.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-18 15:04:56 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    else  if  ( name . equals_ignoring_ascii_case ( " _parent " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 10:20:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parent  =  this - > parent ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            chosen  =  parent ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            chosen  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 10:20:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 6. Otherwise, if name is an ASCII case-insensitive match for "_top",
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    set chosen to currentNavigable's traversable navigable.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-18 15:04:56 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    else  if  ( name . equals_ignoring_ascii_case ( " _top " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 10:20:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        chosen  =  traversable_navigable ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-15 12:57:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 7. Otherwise, if name is not an ASCII case-insensitive match for "_blank" and noopener is false, then set chosen
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    to the result of finding a navigable by target name given name and currentNavigable.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-18 15:04:56 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    else  if  ( ! name . equals_ignoring_ascii_case ( " _blank " sv )  & &  no_opener  = =  TokenizedFeature : : NoOpener : : No )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-15 12:57:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        chosen  =  find_a_navigable_by_target_name ( name ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-28 08:36:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-15 12:57:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 8. If chosen is null, then a new top-level traversable is being requested, and what happens depends on the user
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    agent's configuration and abilities — it is determined by the rules given for the first applicable option
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    from the following list:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! chosen )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-05 17:21:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // --> If currentNavigable's active window does not have transient activation and the user agent has been configured to
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        //     not show popups (i.e., the user agent has a "popup blocker" enabled)
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( active_window ( )  & &  ! active_window ( ) - > has_transient_activation ( )  & &  traversable_navigable ( ) - > page ( ) . should_block_pop_ups ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: The user agent may inform the user that a popup has been blocked.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln ( " Pop-up blocked! " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // --> If sandboxingFlagSet has the sandboxed auxiliary navigation browsing context flag set
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        else  if  ( has_flag ( sandboxing_flag_set ,  SandboxingFlagSet : : SandboxedAuxiliaryNavigation ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: The user agent may report to a developer console that a popup has been blocked.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln ( " Pop-up blocked! " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // --> If the user agent has been configured such that in this instance it will create a new top-level traversable
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        else  if  ( true )  {  // FIXME: When is this the case?
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 12:37:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 1. Consume user activation of currentNavigable's active window.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            active_window ( ) - > consume_user_activation ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 2. Set windowType to "new and unrestricted".
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            window_type  =  WindowType : : NewAndUnrestricted ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 12:37:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 3. Let currentDocument be currentNavigable's active document.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  current_document  =  active_document ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 12:37:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 4. If currentDocument's opener policy's value is "same-origin" or "same-origin-plus-COEP",
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            //    and currentDocument's origin is not same origin with currentDocument's relevant settings object's top-level origin, then:
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ( current_document - > opener_policy ( ) . value  = =  OpenerPolicyValue : : SameOrigin  | |  current_document - > opener_policy ( ) . value  = =  OpenerPolicyValue : : SameOriginPlusCOEP ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-25 16:47:37 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                & &  ! current_document - > origin ( ) . is_same_origin ( relevant_settings_object ( * current_document ) . top_level_origin . value ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // 1. Set noopener to true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                no_opener  =  TokenizedFeature : : NoOpener : : Yes ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // 2. Set name to "_blank".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                name  =  " _blank " sv ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // 3. Set windowType to "new with no opener".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                window_type  =  WindowType : : NewWithNoOpener ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // NOTE: In the presence of an opener policy,
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            //       nested documents that are cross-origin with their top-level browsing context's active document always set noopener to true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 5. Let targetName be the empty string.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            String  target_name ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 6. If name is not an ASCII case-insensitive match for "_blank", then set targetName to name.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-18 15:04:56 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! name . equals_ignoring_ascii_case ( " _blank " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                target_name  =  MUST ( String : : from_utf8 ( name ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  create_new_traversable_closure  =  [ this ,  no_opener ,  target_name ,  activate_tab ,  window_features ] ( GC : : Ptr < BrowsingContext >  opener )  - >  GC : : Ref < Navigable >  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-28 09:12:18 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  hints  =  WebViewHints : : from_tokenised_features ( window_features . value_or ( { } ) ,  traversable_navigable ( ) - > page ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-03 09:09:33 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  [ page ,  window_handle ]  =  traversable_navigable ( ) - > page ( ) . client ( ) . page_did_request_new_web_view ( activate_tab ,  hints ,  no_opener ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-30 20:55:24 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  traversable  =  TraversableNavigable : : create_a_new_top_level_traversable ( * page ,  opener ,  target_name ) . release_value_but_fixme_should_propagate_errors ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                page - > set_top_level_traversable ( traversable ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                traversable - > set_window_handle ( window_handle ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  traversable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  create_new_traversable  =  GC : : create_function ( heap ( ) ,  move ( create_new_traversable_closure ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-30 20:55:24 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 7. If noopener is true, then set chosen to the result of creating a new top-level traversable given null and targetName.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( no_opener  = =  TokenizedFeature : : NoOpener : : Yes )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-30 20:55:24 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                chosen  =  create_new_traversable - > function ( ) ( nullptr ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 8. Otherwise:
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            else  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-05 17:21:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                // 1. Set chosen to the result of creating a new top-level traversable given currentNavigable's active browsing context, targetName, and currentNavigable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // FIXME: "and currentNavigable", which is the openerNavigableForWebDriver parameter.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-30 20:55:24 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                chosen  =  create_new_traversable - > function ( ) ( active_browsing_context ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:06:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                // 2. If sandboxingFlagSet's sandboxed navigation browsing context flag is set,
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                //    then set chosen's active browsing context's one permitted sandboxed navigator to currentNavigable's active browsing context.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:06:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( has_flag ( sandboxing_flag_set ,  SandboxingFlagSet : : SandboxedNavigation ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    chosen - > active_browsing_context ( ) - > set_the_one_permitted_sandboxed_navigator ( active_browsing_context ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 9. If sandboxingFlagSet's sandbox propagates to auxiliary browsing contexts flag is set,
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:06:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            //     then all the flags that are set in sandboxingFlagSet must be set in chosen's active browsing context's popup sandboxing flag set.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( has_flag ( sandboxing_flag_set ,  SandboxingFlagSet : : SandboxPropagatesToAuxiliaryBrowsingContexts ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                chosen - > active_browsing_context ( ) - > set_popup_sandboxing_flag_set ( chosen - > active_browsing_context ( ) - > popup_sandboxing_flag_set ( )  |  sandboxing_flag_set ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 10. Set chosen's is created by web content to true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            as < TraversableNavigable > ( * chosen ) . set_is_created_by_web_content ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-05 17:21:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // --> If the user agent has been configured such that in this instance it will choose currentNavigable
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        else  if  ( false )  {  // FIXME: When is this the case?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Set chosen to current.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            chosen  =  * this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-05 17:21:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // --> If the user agent has been configured such that in this instance it will not find a navigable
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-23 08:09:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        else  if  ( false )  {  // FIXME: When is this the case?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Do nothing.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 10:20:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-05 17:21:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 9. Return chosen and windowType
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 10:20:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  {  chosen . ptr ( ) ,  window_type  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-05 17:21:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/document-sequences.html#find-a-navigable-by-target-name
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								GC : : Ptr < Navigable >  Navigable : : find_a_navigable_by_target_name ( StringView  name )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Let currentDocument be currentNavigable's active document.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  current_document  =  * active_document ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Let sourceSnapshotParams be the result of snapshotting source snapshot params given currentDocument.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  source_snapshot_params  =  current_document . snapshot_source_snapshot_params ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Let subtreesToSearch be an implementation-defined choice of one of the following:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    - « currentNavigable's traversable navigable, currentNavigable »
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    - the inclusive ancestor navigables of currentDocument
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: Decide which to use, or wait until the spec picks one.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  subtrees_to_search  =  current_document . inclusive_ancestor_navigables ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. For each subtreeToSearch of subtreesToSearch, in reverse order:
 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-14 18:34:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const &  subtree_to_search  :  subtrees_to_search . in_reverse ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-05 17:21:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Let documentToSearch be subtreeToSearch's active document.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  document_to_search  =  * subtree_to_search - > active_document ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. For each navigable of the inclusive descendant navigables of documentToSearch:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto  const &  navigable  :  document_to_search . inclusive_descendant_navigables ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 1. If currentNavigable is not allowed by sandboxing to navigate navigable given sourceSnapshotParams, then optionally continue.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! allowed_by_sandboxing_to_navigate ( * navigable ,  source_snapshot_params ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 2. If navigable's target name is name, then return navigable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( navigable - > target_name ( )  = =  name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  * navigable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. Let currentTopLevelBrowsingContext be currentNavigable's active browsing context's top-level browsing context.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  current_top_level_browsing_context  =  * active_browsing_context ( ) - > top_level_browsing_context ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 6. Let group be currentTopLevelBrowsingContext's group.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto *  group  =  current_top_level_browsing_context . group ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 7. For each topLevelBrowsingContext of group's browsing context set, in an implementation-defined order (the user agent should pick a consistent ordering, such as the most recently opened, most recently focused, or more closely related):
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const &  top_level_browsing_context  :  group - > browsing_context_set ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. If currentTopLevelBrowsingContext is topLevelBrowsingContext, then continue.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( & current_top_level_browsing_context  = =  top_level_browsing_context ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Let documentToSearch be topLevelBrowsingContext's active document.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto *  document_to_search  =  top_level_browsing_context - > active_document ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. For each navigable of the inclusive descendant navigables of documentToSearch:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto  const &  navigable  :  document_to_search - > inclusive_descendant_navigables ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 1. If currentNavigable's active browsing context is not familiar with navigable's active browsing context, then continue.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! active_browsing_context ( ) - > is_familiar_with ( * navigable - > active_browsing_context ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 2. If currentNavigable is not allowed by sandboxing to navigate navigable given sourceSnapshotParams, then optionally continue.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! allowed_by_sandboxing_to_navigate ( * navigable ,  source_snapshot_params ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 3. If navigable's target name is name, then return navigable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( navigable - > target_name ( )  = =  name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  * navigable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 8. Return null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:08:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#getting-session-history-entries
  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Vector < GC : : Ref < SessionHistoryEntry > > &  Navigable : : get_session_history_entries ( )  const  
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:08:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Let traversable be navigable's traversable navigable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  traversable  =  traversable_navigable ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME 2. Assert: this is running within traversable's session history traversal queue.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. If navigable is traversable, return traversable's session history entries.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( this  = =  traversable ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  traversable - > session_history_entries ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. Let docStates be an empty ordered set of document states.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < GC : : Ptr < DocumentState > >  doc_states ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:08:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. For each entry of traversable's session history entries, append entry's document state to docStates.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto &  entry  :  traversable - > session_history_entries ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        doc_states . append ( entry - > document_state ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:08:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 6. For each docState of docStates:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( ! doc_states . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  doc_state  =  doc_states . take_first ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. For each nestedHistory of docState's nested histories:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto &  nested_history  :  doc_state - > nested_histories ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 1. If nestedHistory's id equals navigable's id, return nestedHistory's entries.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( nested_history . id  = =  id ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  nested_history . entries ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 2. For each entry of nestedHistory's entries, append entry's document state to docStates.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            for  ( auto &  entry  :  nested_history . entries ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                doc_states . append ( entry - > document_state ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:08:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsers.html#determining-navigation-params-policy-container
  
						 
					
						
							
								
									
										
										
										
											2024-11-25 14:30:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								static  GC : : Ref < PolicyContainer >  determine_navigation_params_policy_container ( URL : : URL  const &  response_url ,  
						 
					
						
							
								
									
										
										
										
											2025-04-26 11:35:51 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Heap &  heap , 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 14:30:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ptr < PolicyContainer >  history_policy_container , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ptr < PolicyContainer >  initiator_policy_container , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ptr < PolicyContainer >  parent_policy_container , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ptr < PolicyContainer >  response_policy_container ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. If historyPolicyContainer is not null, then:
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 14:30:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( history_policy_container )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: 1. Assert: responseURL requires storing the policy container in history.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Return a clone of historyPolicyContainer.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-26 11:35:51 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  history_policy_container - > clone ( heap ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. If responseURL is about:srcdoc, then:
 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-15 23:51:45 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( response_url  = =  URL : : about_srcdoc ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Assert: parentPolicyContainer is not null.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 14:30:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        VERIFY ( parent_policy_container ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Return a clone of parentPolicyContainer.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-26 11:35:51 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  parent_policy_container - > clone ( heap ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. If responseURL is local and initiatorPolicyContainer is not null, then return a clone of initiatorPolicyContainer.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 14:30:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( Fetch : : Infrastructure : : is_local_url ( response_url )  & &  initiator_policy_container ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-26 11:35:51 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  initiator_policy_container - > clone ( heap ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. If responsePolicyContainer is not null, then return responsePolicyContainer.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: File a spec issue to say "a clone of" here for consistency
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 14:30:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( response_policy_container ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-26 11:35:51 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  response_policy_container - > clone ( heap ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. Return a new policy container.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-26 11:35:51 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  heap . allocate < PolicyContainer > ( heap ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsers.html#obtain-coop
  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								static  OpenerPolicy  obtain_an_opener_policy ( GC : : Ref < Fetch : : Infrastructure : : Response > ,  Fetch : : Infrastructure : : Request : : ReservedClientType  const &  reserved_client )  
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Let policy be a new opener policy.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    OpenerPolicy  policy  =  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // AD-HOC: We don't yet setup environments in all cases
 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-24 11:09:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! reserved_client ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  policy ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-24 11:09:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  reserved_environment  =  * reserved_client ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. If reservedEnvironment is a non-secure context, then return policy.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is_non_secure_context ( reserved_environment ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  policy ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: We don't yet have the technology to extract structured data from Fetch headers
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: 3. Let parsedItem be the result of getting a structured field value given `Cross-Origin-Opener-Policy` and "item" from response's header list.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: 4. If parsedItem is not null, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     FIXME: nested steps...
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: 5. Set parsedItem to the result of getting a structured field value given `Cross-Origin-Opener-Policy-Report-Only` and "item" from response's header list.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: 6. If parsedItem is not null, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     FIXME: nested steps...
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 7. Return policy.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  policy ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#attempt-to-create-a-non-fetch-scheme-document
  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								static  GC : : Ptr < DOM : : Document >  attempt_to_create_a_non_fetch_scheme_document ( NonFetchSchemeNavigationParams  const &  params )  
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-07-08 11:56:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Let url be navigationParams's URL.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  url  =  params . url ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Let navigable be navigationParams's navigable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    [[maybe_unused]]  auto  navigable  =  params . navigable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. FIXME: If url is to be handled using a mechanism that does not affect navigable, e.g., because url's scheme is
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    handled externally, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( false )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. FIXME: Hand-off to external software given url, navigable, navigationParams's target snapshot sandboxing flags,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    navigationParams's source snapshot has transient activation, and navigationParams's initiator origin.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Return null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. FIXME: Handle url by displaying some sort of inline content, e.g., an error message because the specified scheme is
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    not one of the supported protocols, or an inline prompt to allow the user to select a registered handler for
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    the given scheme. Return the result of displaying the inline content given navigable, navigationParams's id,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    navigationParams's navigation timing type, and navigationParams's user involvement.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    dbgln ( " FIXME: Don't know how to navigate to {} " ,  url ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-05 09:57:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#create-navigation-params-from-a-srcdoc-resource
  
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								static  GC : : Ref < NavigationParams >  create_navigation_params_from_a_srcdoc_resource ( GC : : Ptr < SessionHistoryEntry >  entry ,  GC : : Ptr < Navigable >  navigable ,  TargetSnapshotParams  const &  target_snapshot_params ,  UserNavigationInvolvement  user_involvement ,  Optional < String >  navigation_id )  
						 
					
						
							
								
									
										
										
										
											2023-04-05 09:57:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  vm  =  navigable - > vm ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( navigable - > active_window ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-05 09:57:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  realm  =  navigable - > active_window ( ) - > realm ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Let documentResource be entry's document state's resource.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  document_resource  =  entry - > document_state ( ) - > resource ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-05 09:57:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( document_resource . has < String > ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Let response be a new response with
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    URL: about:srcdoc
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    header list: (`Content-Type`, `text/html`)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    body: the UTF-8 encoding of documentResource, as a body
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  response  =  Fetch : : Infrastructure : : Response : : create ( vm ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-15 23:51:45 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    response - > url_list ( ) . append ( URL : : about_srcdoc ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-26 13:24:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  header  =  Fetch : : Infrastructure : : Header : : from_string_pair ( " Content-Type " sv ,  " text/html " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    response - > header_list ( ) - > append ( move ( header ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-04 16:06:01 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    response - > set_body ( Fetch : : Infrastructure : : byte_sequence_as_body ( realm ,  document_resource . get < String > ( ) . bytes ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-05 09:57:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Let responseOrigin be the result of determining the origin given response's URL, targetSnapshotParams's sandboxing flags, and entry's document state's origin.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-26 07:44:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  response_origin  =  determine_the_origin ( response - > url ( ) ,  target_snapshot_params . sandboxing_flags ,  entry - > document_state ( ) - > origin ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-05 09:57:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. Let coop be a new opener policy.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    OpenerPolicy  coop  =  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-05 09:57:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. Let coopEnforcementResult be a new opener policy enforcement result with
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-05 09:57:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //    url: response's URL
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 22:38:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //    origin: responseOrigin
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //    opener policy: coop
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    OpenerPolicyEnforcementResult  coop_enforcement_result  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-05 09:57:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        . url  =  * response - > url ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 22:38:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        . origin  =  response_origin , 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        . opener_policy  =  coop 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-05 09:57:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 6. Let policyContainer be the result of determining navigation params policy container given response's URL,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    entry's document state's history policy container, null, navigable's container document's policy container, and null.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 14:30:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ptr < PolicyContainer >  history_policy_container  =  entry - > document_state ( ) - > history_policy_container ( ) . visit ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        [ ] ( GC : : Ref < PolicyContainer >  const &  c )  - >  GC : : Ptr < PolicyContainer >  {  return  c ;  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        [ ] ( DocumentState : : Client )  - >  GC : : Ptr < PolicyContainer >  {  return  { } ;  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ptr < PolicyContainer >  policy_container ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 02:12:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( navigable - > container ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // NOTE: Specification assumes that only navigables corresponding to iframes can be navigated to about:srcdoc.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //       We also use srcdoc to implement load_html() for top level navigables so we need to null check container
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //       because it might be null.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-26 11:35:51 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        policy_container  =  determine_navigation_params_policy_container ( * response - > url ( ) ,  realm . heap ( ) ,  history_policy_container ,  { } ,  navigable - > container_document ( ) - > policy_container ( ) ,  { } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 14:30:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-26 11:35:51 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        policy_container  =  realm . heap ( ) . allocate < PolicyContainer > ( realm . heap ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 02:12:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-05 09:57:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 7. Return a new navigation params, with
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    id: navigationId
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //    navigable: navigable
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-05 09:57:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //    request: null
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    response: response
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //    fetch controller: null
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    commit early hints: null
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-05 09:57:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //    COOP enforcement result: coopEnforcementResult
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    reserved environment: null
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //    origin: responseOrigin
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    policy container: policyContainer
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    final sandboxing flag set: targetSnapshotParams's sandboxing flags
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //    opener policy: coop
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-05 09:57:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //    FIXME: navigation timing type: navTimingType
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //    about base URL: entry's document state's about base URL
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //    user involvement: userInvolvement
 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-15 14:33:29 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  vm . heap ( ) . allocate < NavigationParams > ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        move ( navigation_id ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        navigable , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        nullptr , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        response , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        nullptr , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        nullptr , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        move ( coop_enforcement_result ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        nullptr , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        move ( response_origin ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        * policy_container , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        target_snapshot_params . sandboxing_flags , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        move ( coop ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        entry - > document_state ( ) - > about_base_url ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        user_involvement ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-05 09:57:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#create-navigation-params-by-fetching
  
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:10:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								static  WebIDL : : ExceptionOr < Navigable : : NavigationParamsVariant >  create_navigation_params_by_fetching ( GC : : Ptr < SessionHistoryEntry >  entry ,  GC : : Ptr < Navigable >  navigable ,  SourceSnapshotParams  const &  source_snapshot_params ,  TargetSnapshotParams  const &  target_snapshot_params ,  ContentSecurityPolicy : : Directives : : Directive : : NavigationType  csp_navigation_type ,  UserNavigationInvolvement  user_involvement ,  Optional < String >  navigation_id )  
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  vm  =  navigable - > vm ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( navigable - > active_window ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  realm  =  navigable - > active_window ( ) - > realm ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  active_document  =  * navigable - > active_document ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: 1. Assert: this is running in parallel.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Let documentResource be entry's document state's resource.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  document_resource  =  entry - > document_state ( ) - > resource ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Let request be a new request, with
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    url: entry's URL
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    client: sourceSnapshotParams's fetch client
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    destination: "document"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    credentials mode: "include"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    use-URL-credentials flag: set
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    redirect mode: "manual"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    replaces client id: navigable's active document's relevant settings object's id
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    mode: "navigate"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    referrer: entry's document state's request referrer
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //    referrer policy: entry's document state's request referrer policy
 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-10 17:29:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //    policy container: sourceSnapshotParams's source policy container
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  request  =  Fetch : : Infrastructure : : Request : : create ( vm ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    request - > set_url ( entry - > url ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    request - > set_client ( source_snapshot_params . fetch_client ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    request - > set_destination ( Fetch : : Infrastructure : : Request : : Destination : : Document ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    request - > set_credentials_mode ( Fetch : : Infrastructure : : Request : : CredentialsMode : : Include ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    request - > set_use_url_credentials ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    request - > set_redirect_mode ( Fetch : : Infrastructure : : Request : : RedirectMode : : Manual ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-24 15:44:50 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    request - > set_replaces_client_id ( active_document . relevant_settings_object ( ) . id ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    request - > set_mode ( Fetch : : Infrastructure : : Request : : Mode : : Navigate ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    request - > set_referrer ( entry - > document_state ( ) - > request_referrer ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-10 17:29:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    request - > set_policy_container ( source_snapshot_params . source_policy_container ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-11 21:12:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. If navigable is a top-level traversable, then set request's top-level navigation initiator origin to entry's
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    document state's initiator origin.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( navigable - > top_level_traversable ( ) - > parent ( )  = =  nullptr ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        request - > set_top_level_navigation_initiator_origin ( entry - > document_state ( ) - > origin ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. If request's client is null:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( request - > client ( )  = =  nullptr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // Note: This only occurs in the case of a browser UI-initiated navigation.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Set request's origin to a new opaque origin.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        request - > set_origin ( URL : : Origin : : create_opaque ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Set request's service-workers mode to "all".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        request - > set_service_workers_mode ( Fetch : : Infrastructure : : Request : : ServiceWorkersMode : : All ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. Set request's referrer to "no-referrer".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        request - > set_referrer ( Fetch : : Infrastructure : : Request : : Referrer : : NoReferrer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 6. If documentResource is a POST resource:
 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-21 15:18:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto *  post_resource  =  document_resource . get_pointer < POSTResource > ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Set request's method to `POST`.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-14 18:55:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        request - > set_method ( TRY_OR_THROW_OOM ( vm ,  ByteBuffer : : copy ( " POST " sv . bytes ( ) ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Set request's body to documentResource's request body.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        request - > set_body ( document_resource . get < POSTResource > ( ) . request_body . value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. Set `Content-Type` to documentResource's request content-type in request's header list.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-21 15:18:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  request_content_type  =  [ & ] ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            switch  ( post_resource - > request_content_type )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            case  POSTResource : : RequestContentType : : ApplicationXWWWFormUrlencoded : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  " application/x-www-form-urlencoded " sv ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  POSTResource : : RequestContentType : : MultipartFormData : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  " multipart/form-data " sv ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  POSTResource : : RequestContentType : : TextPlain : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  " text/plain " sv ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-21 15:18:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        StringBuilder  request_content_type_buffer ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! post_resource - > request_content_type_directives . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            request_content_type_buffer . append ( request_content_type ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            for  ( auto  const &  directive  :  post_resource - > request_content_type_directives ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                request_content_type_buffer . appendff ( " ; {}={} " ,  directive . type ,  directive . value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            request_content_type  =  request_content_type_buffer . string_view ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  header  =  Fetch : : Infrastructure : : Header : : from_string_pair ( " Content-Type " sv ,  request_content_type ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-26 13:24:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        request - > header_list ( ) - > append ( move ( header ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 7. If entry's document state's reload pending is true, then set request's reload-navigation flag.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( entry - > document_state ( ) - > reload_pending ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        request - > set_reload_navigation ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 8. Otherwise, if entry's document state's ever populated is true, then set request's history-navigation flag.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:05:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    else  if  ( entry - > document_state ( ) - > ever_populated ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        request - > set_history_navigation ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 9. If sourceSnapshotParams's has transient activation is true, then set request's user-activation to true.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( source_snapshot_params . has_transient_activation ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        request - > set_user_activation ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 10. If navigable's container is non-null:
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( navigable - > container ( )  ! =  nullptr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. If the navigable's container has a browsing context scope origin, then set request's origin to that browsing context scope origin.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: From "browsing context scope origin": This definition is broken and needs investigation to see what it was intended to express: see issue #4703.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //        The referenced issue suggests that it is a no-op to retrieve the browsing context scope origin.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Set request's destination to navigable's container's local name.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: Are there other container types? If so, we need a helper here
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Web : : Fetch : : Infrastructure : : Request : : Destination  destination  =  is < HTMLIFrameElement > ( * navigable - > container ( ) )  ?  Web : : Fetch : : Infrastructure : : Request : : Destination : : IFrame 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                                                                                                                      :  Web : : Fetch : : Infrastructure : : Request : : Destination : : Object ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        request - > set_destination ( destination ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. If sourceSnapshotParams's fetch client is navigable's container document's relevant settings object,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    then set request's initiator type to navigable's container's local name.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // NOTE: This ensure that only container-initiated navigations are reported to resource timing.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( source_snapshot_params . fetch_client  = =  & navigable - > container_document ( ) - > relevant_settings_object ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: Are there other container types? If so, we need a helper here
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            Web : : Fetch : : Infrastructure : : Request : : InitiatorType  initiator_type  =  is < HTMLIFrameElement > ( * navigable - > container ( ) )  ?  Web : : Fetch : : Infrastructure : : Request : : InitiatorType : : IFrame 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                                                                                                                               :  Web : : Fetch : : Infrastructure : : Request : : InitiatorType : : Object ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            request - > set_initiator_type ( initiator_type ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 11. Let response be null.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-23 01:03:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: We use a heap-allocated cell to hold the response pointer because the processResponse callback below
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //       might use it after this stack is freed.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  response_holder  =  ResponseHolder : : create ( vm ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 12. Let responseOrigin be null.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:33:34 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < URL : : Origin >  response_origin ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 13. Let fetchController be null.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ptr < Fetch : : Infrastructure : : FetchController >  fetch_controller  =  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 14. Let coopEnforcementResult be a new opener policy enforcement result, with
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // - url: navigable's active document's URL
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // - origin: navigable's active document's origin
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // - opener policy: navigable's active document's opener policy
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // - current context is navigation source: true if navigable's active document's origin is same origin with
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //                                         entry's document state's initiator origin otherwise false
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    OpenerPolicyEnforcementResult  coop_enforcement_result  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        . url  =  active_document . url ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        . origin  =  active_document . origin ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        . opener_policy  =  active_document . opener_policy ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        . current_context_is_navigation_source  =  entry - > document_state ( ) - > initiator_origin ( ) . has_value ( )  & &  active_document . origin ( ) . is_same_origin ( * entry - > document_state ( ) - > initiator_origin ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 15. Let finalSandboxFlags be an empty sandboxing flag set.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 11:57:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    SandboxingFlagSet  final_sandbox_flags  =  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 16. Let responsePolicyContainer be null.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 14:30:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ptr < PolicyContainer >  response_policy_container  =  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 17. Let responseCOOP be a new opener policy.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    OpenerPolicy  response_coop  =  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 18. Let locationURL be null.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-18 16:22:27 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    ErrorOr < Optional < URL : : URL > >  location_url  {  OptionalNone  { }  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 19. Let currentURL be request's current URL.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-18 16:22:27 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    URL : : URL  current_url  =  request - > current_url ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 20. Let commitEarlyHints be null.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Function < void ( DOM : : Document & ) >  commit_early_hints  =  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 21. While true:
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( true )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-12 12:10:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. If request's reserved client is not null and currentURL's origin is not the same as request's reserved client's creation URL's origin, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( request - > reserved_client ( )  & &  ! current_url . origin ( ) . is_same_origin ( request - > reserved_client ( ) - > creation_url . origin ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 1. Run the environment discarding steps for request's reserved client.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            request - > reserved_client ( ) - > discard_environment ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 2. Set request's reserved client to null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            request - > set_reserved_client ( nullptr ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 3. Set commitEarlyHints to null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            commit_early_hints  =  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. If request's reserved client is null, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! request - > reserved_client ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 1. Let topLevelCreationURL be currentURL.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 16:57:31 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            Optional < URL : : URL >  top_level_creation_url  =  current_url ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-12 12:10:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 2. Let topLevelOrigin be null.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-25 16:47:37 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            Optional < URL : : Origin >  top_level_origin ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-12 12:10:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 3. If navigable is not a top-level traversable, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! navigable - > is_top_level_traversable ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // 1. Let parentEnvironment be navigable's parent's active document's relevant settings object.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto &  parent_environment  =  navigable - > parent ( ) - > active_document ( ) - > relevant_settings_object ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // 2. Set topLevelCreationURL to parentEnvironment's top-level creation URL.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                top_level_creation_url  =  parent_environment . top_level_creation_url ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // 3. Set topLevelOrigin to parentEnvironment's top-level origin.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                top_level_origin  =  parent_environment . top_level_origin ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 4. Set request's reserved client to a new environment whose id is a unique opaque string,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            //    target browsing context is navigable's active browsing context,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            //    creation URL is currentURL,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            //    top-level creation URL is topLevelCreationURL,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            //    and top-level origin is topLevelOrigin.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: Make this a proper unique opaque string.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            static  int  next_id  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  id_string  =  MUST ( String : : formatted ( " create-by-fetching-{} " ,  next_id + + ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            request - > set_reserved_client ( realm . create < Environment > ( id_string ,  current_url ,  top_level_creation_url ,  top_level_origin ,  navigable - > active_browsing_context ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:50:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. If the result of should navigation request of type be blocked by Content Security Policy? given request and cspNavigationType is "Blocked", then set response to a network error and break. [CSP]
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ContentSecurityPolicy : : should_navigation_request_of_type_be_blocked_by_content_security_policy ( request ,  csp_navigation_type )  = =  ContentSecurityPolicy : : Directives : : Directive : : Result : : Blocked )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-02 20:51:45 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            response_holder - > set_response ( Fetch : : Infrastructure : : Response : : network_error ( vm ,  " Blocked by Content Security Policy " _string ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:50:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 4. Set response to null.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-23 01:03:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        response_holder - > set_response ( nullptr ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 5. If fetchController is null, then set fetchController to the result of fetching request,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    with processEarlyHintsResponse set to processEarlyHintsResponseas defined below, processResponse
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    set to processResponse as defined below, and useParallelQueue set to true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! fetch_controller )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: Let processEarlyHintsResponse be the following algorithm given a response earlyResponse:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Let processResponse be the following algorithm given a response fetchedResponse:
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  process_response  =  [ response_holder ] ( GC : : Ref < Fetch : : Infrastructure : : Response >  fetch_response )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                // 1. Set response to fetchedResponse.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-23 01:03:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                response_holder - > set_response ( fetch_response ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            fetch_controller  =  TRY ( Fetch : : Fetching : : fetch ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                realm , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                request , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                Fetch : : Infrastructure : : FetchAlgorithms : : create ( vm , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        . process_request_body_chunk_length  =  { } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        . process_request_end_of_body  =  { } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        . process_early_hints_response  =  { } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        . process_response  =  move ( process_response ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        . process_response_end_of_body  =  { } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        . process_response_consume_body  =  { } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    } ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                Fetch : : Fetching : : UseParallelQueue : : Yes ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 6. Otherwise, process the next manual redirect for fetchController.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            fetch_controller - > process_next_manual_redirect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 7. Wait until either response is non-null, or navigable's ongoing navigation changes to no longer equal navigationId.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 19:48:50 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        HTML : : main_thread_event_loop ( ) . spin_until ( GC : : create_function ( vm . heap ( ) ,  [ navigation_id ,  navigable ,  response_holder ] ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-23 01:03:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( response_holder - > response ( )  ! =  nullptr ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( navigation_id . has_value ( )  & &  ( ! navigable - > ongoing_navigation ( ) . has < String > ( )  | |  navigable - > ongoing_navigation ( ) . get < String > ( )  ! =  * navigation_id ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-31 05:23:43 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // If the latter condition occurs, then abort fetchController, and return. Otherwise, proceed onward.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( navigation_id . has_value ( )  & &  ( ! navigable - > ongoing_navigation ( ) . has < String > ( )  | |  navigable - > ongoing_navigation ( ) . get < String > ( )  ! =  * navigation_id ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            fetch_controller - > abort ( realm ,  { } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-13 19:08:01 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Navigable : : NullOrError  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 8. If request's body is null, then set entry's document state's resource to null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! request - > body ( ) . has < Empty > ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            entry - > document_state ( ) - > set_resource ( Empty  { } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:01:26 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 9. Set responsePolicyContainer to the result of creating a policy container from a fetch response given response and request's reserved client.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-26 11:35:51 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        response_policy_container  =  create_a_policy_container_from_a_fetch_response ( realm . heap ( ) ,  * response_holder - > response ( ) ,  request - > reserved_client ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:01:26 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 10. Set finalSandboxFlags to the union of targetSnapshotParams's sandboxing flags and responsePolicyContainer's CSP list's CSP-derived sandboxing flags.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        final_sandbox_flags  =  target_snapshot_params . sandboxing_flags  |  response_policy_container - > csp_list - > csp_derived_sandboxing_flags ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-17 17:11:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 11. Set responseOrigin to the result of determining the origin given response's URL, finalSandboxFlags, and entry's document state's initiator origin.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-26 07:44:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        response_origin  =  determine_the_origin ( response_holder - > response ( ) - > url ( ) ,  final_sandbox_flags ,  entry - > document_state ( ) - > initiator_origin ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 12. If navigable is a top-level traversable, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( navigable - > is_top_level_traversable ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 1. Set responseCOOP to the result of obtaining an opener policy given response and request's reserved client.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            response_coop  =  obtain_an_opener_policy ( * response_holder - > response ( ) ,  request - > reserved_client ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: 2. Set coopEnforcementResult to the result of enforcing the response's opener policy given navigable's active browsing context,
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            //    response's URL, responseOrigin, responseCOOP, coopEnforcementResult and request's referrer.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: 3. If finalSandboxFlags is not empty and responseCOOP's value is not "unsafe-none", then set response to an appropriate network error and break.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // NOTE: This results in a network error as one cannot simultaneously provide a clean slate to a response
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            //       using opener policy and sandbox the result of navigating to that response.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 13. FIXME If response is not a network error, navigable is a child navigable, and the result of performing a cross-origin resource policy check
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    with navigable's container document's origin, navigable's container document's relevant settings object, request's destination, response,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    and true is blocked, then set response to a network error and break.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // NOTE: Here we're running the cross-origin resource policy check against the parent navigable rather than navigable itself
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //       This is because we care about the same-originness of the embedded content against the parent context, not the navigation source.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 14. Set locationURL to response's location URL given currentURL's fragment.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-22 12:28:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        location_url  =  response_holder - > response ( ) - > location_url ( current_url . fragment ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 15. If locationURL is failure or null, then break.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( location_url . is_error ( )  | |  ! location_url . value ( ) . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 16. Assert: locationURL is a URL.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 17. Set entry's classic history API state to StructuredSerializeForStorage(null).
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        entry - > set_classic_history_api_state ( MUST ( structured_serialize_for_storage ( vm ,  JS : : js_null ( ) ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 18. Let oldDocState be entry's document state.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  old_doc_state  =  entry - > document_state ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 19. Set entry's document state to a new document state, with
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // history policy container: a clone of the oldDocState's history policy container if it is non-null; null otherwise
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // request referrer: oldDocState's request referrer
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // request referrer policy: oldDocState's request referrer policy
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // origin: oldDocState's origin
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // resource: oldDocState's resource
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // ever populated: oldDocState's ever populated
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // navigable target name: oldDocState's navigable target name
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-14 06:13:46 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  new_document_state  =  navigable - > heap ( ) . allocate < DocumentState > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        new_document_state - > set_history_policy_container ( old_doc_state - > history_policy_container ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        new_document_state - > set_request_referrer ( old_doc_state - > request_referrer ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        new_document_state - > set_request_referrer_policy ( old_doc_state - > request_referrer_policy ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        new_document_state - > set_origin ( old_doc_state - > origin ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        new_document_state - > set_resource ( old_doc_state - > resource ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        new_document_state - > set_ever_populated ( old_doc_state - > ever_populated ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        new_document_state - > set_navigable_target_name ( old_doc_state - > navigable_target_name ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        entry - > set_document_state ( new_document_state ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 20. If locationURL's scheme is not an HTTP(S) scheme, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! Fetch : : Infrastructure : : is_http_or_https_scheme ( location_url . value ( ) - > scheme ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 1. Set entry's document state's resource to null.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            entry - > document_state ( ) - > set_resource ( Empty  { } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 2. Break.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 21. Set currentURL to locationURL.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        current_url  =  location_url . value ( ) . value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 22. Set entry's URL to currentURL.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        entry - > set_url ( current_url ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 22. If locationURL is a URL whose scheme is not a fetch scheme, then return a new non-fetch scheme navigation params, with
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! location_url . is_error ( )  & &  location_url . value ( ) . has_value ( )  & &  ! Fetch : : Infrastructure : : is_fetch_scheme ( location_url . value ( ) . value ( ) . scheme ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // - id: navigationId
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // - navigable: navigable
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // - URL: locationURL
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // - target snapshot sandboxing flags: targetSnapshotParams's sandboxing flags
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // - source snapshot has transient activation: sourceSnapshotParams's has transient activation
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // - initiator origin: responseOrigin
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: - navigation timing type: navTimingType
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // - user involvement: userInvolvement
 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-15 15:04:23 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  vm . heap ( ) . allocate < NonFetchSchemeNavigationParams > ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            navigation_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            navigable , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            location_url . release_value ( ) . value ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            target_snapshot_params . sandboxing_flags , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            source_snapshot_params . has_transient_activation , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            move ( * response_origin ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            user_involvement ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 23. If any of the following are true:
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //       - response is a network error;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //       - locationURL is failure; or
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //       - locationURL is a URL whose scheme is a fetch scheme
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     then return null.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-18 15:26:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( response_holder - > response ( ) - > is_network_error ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // AD-HOC: We pass the error message if we have one in NullWithError
 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-02 20:51:45 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( response_holder - > response ( ) - > network_error_message ( ) . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-18 15:26:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  response_holder - > response ( ) - > network_error_message ( ) . value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        else 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-13 19:08:01 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Navigable : : NullOrError  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-18 15:26:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  if  ( location_url . is_error ( )  | |  ( location_url . value ( ) . has_value ( )  & &  Fetch : : Infrastructure : : is_fetch_scheme ( location_url . value ( ) . value ( ) . scheme ( ) ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-13 19:08:01 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  Navigable : : NullOrError  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 24. Assert: locationURL is null and response is not a network error.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( ! location_url . value ( ) . has_value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-23 01:03:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( ! response_holder - > response ( ) - > is_network_error ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 25. Let resultPolicyContainer be the result of determining navigation params policy container given response's URL,
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     entry's document state's history policy container, sourceSnapshotParams's source policy container, null, and responsePolicyContainer.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 14:30:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ptr < PolicyContainer >  history_policy_container  =  entry - > document_state ( ) - > history_policy_container ( ) . visit ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        [ ] ( GC : : Ref < PolicyContainer >  const &  c )  - >  GC : : Ptr < PolicyContainer >  {  return  c ;  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        [ ] ( DocumentState : : Client )  - >  GC : : Ptr < PolicyContainer >  {  return  { } ;  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-26 11:35:51 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  result_policy_container  =  determine_navigation_params_policy_container ( * response_holder - > response ( ) - > url ( ) ,  realm . heap ( ) ,  history_policy_container ,  source_snapshot_params . source_policy_container ,  { } ,  response_policy_container ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 26. If navigable's container is an iframe, and response's timing allow passed flag is set,
 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-24 11:18:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     then set navigable's container's pending resource-timing start time to null.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-08-25 07:22:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( navigable - > container ( )  & &  response_holder - > response ( ) - > timing_allow_passed ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto *  iframe_element  =  as_if < HTML : : HTMLIFrameElement > ( * navigable - > container ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            iframe_element - > set_pending_resource_start_time ( { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:06:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 27. Return a new navigation params, with
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     id: navigationId
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     navigable: navigable
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     request: request
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     response: response
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     fetch controller: fetchController
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     commit early hints: commitEarlyHints
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     opener policy: responseCOOP
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     reserved environment: request's reserved client
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     origin: responseOrigin
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     policy container: resultPolicyContainer
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     final sandboxing flag set: finalSandboxFlags
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     COOP enforcement result: coopEnforcementResult
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     FIXME: navigation timing type: navTimingType
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     about base URL: entry's document state's about base URL
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     user involvement: userInvolvement
 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-15 14:33:29 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  vm . heap ( ) . allocate < NavigationParams > ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        navigation_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        navigable , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        request , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        * response_holder - > response ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        fetch_controller , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        move ( commit_early_hints ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        coop_enforcement_result , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        request - > reserved_client ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        * response_origin , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        result_policy_container , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        final_sandbox_flags , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        response_coop , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        entry - > document_state ( ) - > about_base_url ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        user_involvement ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:11:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-08 11:56:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#populating-a-session-history-entry
  
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								WebIDL : : ExceptionOr < void >  Navigable : : populate_session_history_entry_document (  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ptr < SessionHistoryEntry >  entry , 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    SourceSnapshotParams  const &  source_snapshot_params , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    TargetSnapshotParams  const &  target_snapshot_params , 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    UserNavigationInvolvement  user_involvement , 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < String >  navigation_id , 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-18 15:26:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Navigable : : NavigationParamsVariant  navigation_params , 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:10:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    ContentSecurityPolicy : : Directives : : Directive : : NavigationType  csp_navigation_type , 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    bool  allow_POST , 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ptr < GC : : Function < void ( ) > >  completion_steps ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // AD-HOC: Not in the spec but subsequent steps will fail if the navigable doesn't have an active window.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! active_window ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: 1. Assert: this is running in parallel.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Assert: if navigationParams is non-null, then navigationParams's response is non-null.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-13 19:08:01 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! navigation_params . has < NullOrError > ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        VERIFY ( navigation_params . has < GC : : Ref < NavigationParams > > ( )  & &  navigation_params . get < GC : : Ref < NavigationParams > > ( ) - > response ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 12:31:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Let documentResource be entry's document state's resource.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  document_resource  =  entry - > document_state ( ) - > resource ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 12:31:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. If navigationParams is null, then:
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-13 19:08:01 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( navigation_params . has < NullOrError > ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-08 11:56:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. If documentResource is a string, then set navigationParams to the result of creating navigation params
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    from a srcdoc resource given entry, navigable, targetSnapshotParams, userInvolvement, navigationId, and
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    navTimingType.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( document_resource . has < String > ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            navigation_params  =  create_navigation_params_from_a_srcdoc_resource ( entry ,  this ,  target_snapshot_params ,  user_involvement ,  navigation_id ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Otherwise, if all of the following are true:
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        //    - entry's URL's scheme is a fetch scheme; and
 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-08 11:56:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        //    - documentResource is null, or allowPOST is true and documentResource's request body is not failure,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //      (FIXME: check if request body is not failure)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    then set navigationParams to the result of creating navigation params by fetching given entry, navigable,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    sourceSnapshotParams, targetSnapshotParams, cspNavigationType, userInvolvement, navigationId, and
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    navTimingType.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        else  if  ( Fetch : : Infrastructure : : is_fetch_scheme ( entry - > url ( ) . scheme ( ) )  & &  ( document_resource . has < Empty > ( )  | |  allow_POST ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            navigation_params  =  TRY ( create_navigation_params_by_fetching ( entry ,  this ,  source_snapshot_params ,  target_snapshot_params ,  csp_navigation_type ,  user_involvement ,  navigation_id ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-08 11:56:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. Otherwise, if entry's URL's scheme is not a fetch scheme, then set navigationParams to a new non-fetch
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    scheme navigation params, with:
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        else  if  ( ! Fetch : : Infrastructure : : is_fetch_scheme ( entry - > url ( ) . scheme ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // - id: navigationId
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // - navigable: navigable
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // - URL: entry's URL
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // - target snapshot sandboxing flags: targetSnapshotParams's sandboxing flags
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // - source snapshot has transient activation: sourceSnapshotParams's has transient activation
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // - initiator origin: entry's document state's initiator origin
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: - navigation timing type: navTimingType
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // - user involvement: userInvolvement
 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-15 15:04:23 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            navigation_params  =  vm ( ) . heap ( ) . allocate < NonFetchSchemeNavigationParams > ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                navigation_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                this , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                entry - > url ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                target_snapshot_params . sandboxing_flags , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                source_snapshot_params . has_transient_activation , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                * entry - > document_state ( ) - > initiator_origin ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                user_involvement ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // AD-HOC: Not in the spec but subsequent steps will fail if the navigable doesn't have an active window.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! active_window ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-05 23:36:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 12:31:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. Queue a global task on the navigation and traversal task source, given navigable's active window, to run these steps:
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:50:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    queue_global_task ( Task : : Source : : NavigationAndTraversal ,  * active_window ( ) ,  GC : : create_function ( heap ( ) ,  [ this ,  entry ,  navigation_params  =  move ( navigation_params ) ,  navigation_id ,  user_involvement ,  completion_steps ,  csp_navigation_type ] ( )  mutable  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-05 23:36:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // NOTE: This check is not in the spec but we should not continue navigation if navigable has been destroyed.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( has_been_destroyed ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. If navigable's ongoing navigation no longer equals navigationId, then run completionSteps and abort these steps.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( navigation_id . has_value ( )  & &  ( ! ongoing_navigation ( ) . has < String > ( )  | |  ongoing_navigation ( ) . get < String > ( )  ! =  * navigation_id ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 15:41:50 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( completion_steps ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                completion_steps - > function ( ) ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Let saveExtraDocumentState be true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  saveExtraDocumentState  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. If navigationParams is a non-fetch scheme navigation params, then:
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( navigation_params . has < GC : : Ref < NonFetchSchemeNavigationParams > > ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-08 11:56:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 1. Set entry's document state's document to the result of running attempt to create a non-fetch scheme
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            //    document given navigationParams.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            //    NOTE: This can result in setting entry's document state's document to null, e.g., when handing-off to
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            //    external software.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            entry - > document_state ( ) - > set_document ( attempt_to_create_a_non_fetch_scheme_document ( navigation_params . get < GC : : Ref < NonFetchSchemeNavigationParams > > ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 16:14:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( entry - > document ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                entry - > document_state ( ) - > set_ever_populated ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 2. Set saveExtraDocumentState to false.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            saveExtraDocumentState  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 4. Otherwise, if any of the following are true:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //  - navigationParams is null;
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:50:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        //  - the result of should navigation response to navigation request of type in target be blocked by Content Security Policy? given navigationParams's request, navigationParams's response, navigationParams's policy container's CSP list, cspNavigationType, and navigable is "Blocked";
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        //  - FIXME: navigationParams's reserved environment is non-null and the result of checking a navigation response's adherence to its embedder policy given navigationParams's response, navigable, and navigationParams's policy container's embedder policy is false; or
 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 00:33:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        //  - the result of checking a navigation response's adherence to `X-Frame-Options` given navigationParams's response, navigable, navigationParams's policy container's CSP list, and navigationParams's origin is false,
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        //    then:
 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-08 11:56:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        else  if  ( navigation_params . visit ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                     [ ] ( NullOrError )  {  return  true ;  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                     [ this ,  csp_navigation_type ] ( GC : : Ref < NavigationParams >  navigation_params )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                         auto  csp_result  =  ContentSecurityPolicy : : should_navigation_response_to_navigation_request_of_type_in_target_be_blocked_by_content_security_policy ( navigation_params - > request ,  * navigation_params - > response ,  navigation_params - > policy_container - > csp_list ,  csp_navigation_type ,  * this ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                         if  ( csp_result  = =  ContentSecurityPolicy : : Directives : : Directive : : Result : : Blocked ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                             return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                         // FIXME: Pass in navigationParams's policy container's CSP list
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                         return  ! check_a_navigation_responses_adherence_to_x_frame_options ( navigation_params - > response ,  this ,  navigation_params - > policy_container - > csp_list ,  navigation_params - > origin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                     } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                     [ ] ( GC : : Ref < NonFetchSchemeNavigationParams > )  {  return  false ;  } ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 1. Set entry's document state's document to the result of creating a document for inline content that doesn't have a DOM, given navigable, null, navTimingType, and userInvolvement. The inline content should indicate to the user the sort of error that occurred.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-02 20:51:45 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  error_message  =  navigation_params . has < NullOrError > ( )  ?  navigation_params . get < NullOrError > ( ) . value_or ( " Unknown error " _string )  :  " The request was denied. " _string ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-18 15:26:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  error_html  =  load_error_page ( entry - > url ( ) ,  error_message ) . release_value_but_fixme_should_propagate_errors ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            entry - > document_state ( ) - > set_document ( create_document_for_inline_content ( this ,  navigation_id ,  user_involvement ,  [ this ,  error_html ] ( auto &  document )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-03 21:56:58 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  parser  =  HTML : : HTMLParser : : create ( document ,  error_html ,  " utf-8 " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-15 23:51:45 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                document . set_url ( URL : : about_error ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 16:16:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                parser - > run ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-04 23:42:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // NOTE: Once the page has been set up, the user agent must act as if it had stopped parsing.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // FIXME: Directly calling parser->the_end results in a deadlock, because it waits for the warning image to load.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                //        However the response is never processed when parser->the_end is called.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                //        Queuing a global task is a workaround for now.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                queue_a_task ( Task : : Source : : Unspecified ,  HTML : : main_thread_event_loop ( ) ,  document ,  GC : : create_function ( heap ( ) ,  [ & document ] ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    HTMLParser : : the_end ( document ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 16:16:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 2. Make document unsalvageable given entry's document state's document and "navigation-failure".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            entry - > document ( ) - > make_unsalvageable ( " navigation-failure " _string ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 3. Set saveExtraDocumentState to false.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            saveExtraDocumentState  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 4. If navigationParams is not null, then:
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-13 19:08:01 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! navigation_params . has < NullOrError > ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-12 12:07:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                // 1. Run the environment discarding steps for navigationParams's reserved environment.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                navigation_params . visit ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    [ ] ( GC : : Ref < NavigationParams >  const &  it )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        it - > reserved_environment - > discard_environment ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    [ ] ( auto  const & )  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 12:31:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                // FIXME: 2. Invoke WebDriver BiDi navigation failed with navigable and a new WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is navigationParams's response's URL.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-08 11:56:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: 5. Otherwise, if navigationParams's response has a `Content-Disposition` header specifying the attachment
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    disposition type, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        else  if  ( false )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 6. Otherwise, if navigationParams's response's status is not 204 and is not 205, then set entry's document state's document to the result of
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    loading a document given navigationParams, sourceSnapshotParams, and entry's document state's initiator origin.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        else  if  ( auto  const &  response  =  navigation_params . get < GC : : Ref < NavigationParams > > ( ) - > response ;  response - > status ( )  ! =  204  & &  response - > status ( )  ! =  205 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  document  =  load_document ( navigation_params . get < GC : : Ref < NavigationParams > > ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            entry - > document_state ( ) - > set_document ( document ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 7. If entry's document state's document is not null, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( entry - > document ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 1. Set entry's document state's ever populated to true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            entry - > document_state ( ) - > set_ever_populated ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 2. If saveExtraDocumentState is true:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( saveExtraDocumentState )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // 1. Let document be entry's document state's document.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto  document  =  entry - > document ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                // 2. Set entry's document state's origin to document's origin.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                entry - > document_state ( ) - > set_origin ( document - > origin ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 14:30:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                // 3. If document's URL requires storing the policy container in history, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( url_requires_storing_the_policy_container_in_history ( document - > url ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    // 1. Assert: navigationParams is a navigation params (i.e., neither null nor a non-fetch scheme navigation params).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    VERIFY ( navigation_params . has < GC : : Ref < NavigationParams > > ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    // 2. Set entry's document state's history policy container to navigationParams's policy container.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    entry - > document_state ( ) - > set_history_policy_container ( GC : : Ref  {  * navigation_params . get < GC : : Ref < NavigationParams > > ( ) - > policy_container  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 3. If entry's document state's request referrer is "client", and navigationParams is a navigation params (i.e., neither null nor a non-fetch scheme navigation params), then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( entry - > document_state ( ) - > request_referrer ( )  = =  Fetch : : Infrastructure : : Request : : Referrer : : Client 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-13 19:08:01 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                & &  ( ! navigation_params . has < NullOrError > ( )  & &  navigation_params . has < GC : : Ref < NonFetchSchemeNavigationParams > > ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-23 11:01:49 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                // 1. Assert: navigationParams's request is not null.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                VERIFY ( navigation_params . has < GC : : Ref < NavigationParams > > ( )  & &  navigation_params . get < GC : : Ref < NavigationParams > > ( ) - > request ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-23 11:01:49 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // 2. Set entry's document state's request referrer to navigationParams's request's referrer.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                entry - > document_state ( ) - > set_request_referrer ( navigation_params . get < GC : : Ref < NavigationParams > > ( ) - > request - > referrer ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 00:28:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 8. Run completionSteps.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 15:41:50 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( completion_steps ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            completion_steps - > function ( ) ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 22:04:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-06 18:10:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								WebIDL : : ExceptionOr < void >  Navigable : : navigate ( NavigateParams  params )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-02-28 22:35:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // AD-HOC: Not in the spec but subsequent steps will fail if the navigable doesn't have an active window.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! active_window ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  source_document  =  params . source_document ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  exceptions_enabled  =  params . exceptions_enabled ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-26 07:46:48 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  active_document  =  * this - > active_document ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  realm  =  active_document . realm ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-26 07:46:48 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  page_client  =  active_document . page ( ) . client ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-09 11:40:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // AD-HOC: If we are not able to continue in this process, request a new process from the UI.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-26 07:46:48 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is_top_level_traversable ( )  & &  ! page_client . is_url_suitable_for_same_process_navigation ( active_document . url ( ) ,  params . url ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        page_client . request_new_process_for_navigation ( params . url ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-09 11:40:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Let sourceSnapshotParams be the result of snapshotting source snapshot params given sourceDocument.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  source_snapshot_params  =  source_document - > snapshot_source_snapshot_params ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Let initiatorOriginSnapshot be sourceDocument's origin.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  initiator_origin_snapshot  =  source_document - > origin ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. Let initiatorBaseURLSnapshot be sourceDocument's document base URL.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  initiator_base_url_snapshot  =  source_document - > base_url ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. If sourceDocument's node navigable is not allowed by sandboxing to navigate navigable given sourceSnapshotParams, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! source_document - > navigable ( ) - > allowed_by_sandboxing_to_navigate ( * this ,  source_snapshot_params ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. If exceptionsEnabled is true, then throw a "SecurityError" DOMException.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( exceptions_enabled )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 19:31:52 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  WebIDL : : SecurityError : : create ( realm ,  " Source document's node navigable is not allowed to navigate " _utf16 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2 Return.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-08 11:56:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( m_pending_navigations . is_empty ( )  & &  params . url . equals ( URL : : about_blank ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        begin_navigation ( move ( params ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! m_has_session_history_entry_and_ready_for_navigation )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        m_pending_navigations . append ( move ( params ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    begin_navigation ( move ( params ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// To navigate a navigable navigable to a URL url using an optional Document-or-null sourceDocument (default null),
  
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// with an optional POST resource, string, or null documentResource (default null),
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// an optional response-or-null response (default null), an optional boolean exceptionsEnabled (default false),
  
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// an optional NavigationHistoryBehavior historyHandling (default "auto"),
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// an optional serialized state-or-null navigationAPIState (default null),
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// an optional entry list or null formDataEntryList (default null),
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// an optional referrer policy referrerPolicy (default the empty string),
  
						 
					
						
							
								
									
										
										
										
											2025-01-30 14:14:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// an optional user navigation involvement userInvolvement (default "none"),
  
						 
					
						
							
								
									
										
										
										
											2025-05-15 12:28:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// an optional Element sourceElement (default null),
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// and an optional boolean initialInsertion (default false):
  
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate
  
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : begin_navigation ( NavigateParams  params )  
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // AD-HOC: Not in the spec but subsequent steps will fail if the navigable doesn't have an active window.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! active_window ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-10 16:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  url  =  params . url ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  source_document  =  params . source_document ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  document_resource  =  params . document_resource ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  response  =  params . response ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  history_handling  =  params . history_handling ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  navigation_api_state  =  params . navigation_api_state ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  form_data_entry_list  =  params . form_data_entry_list ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  referrer_policy  =  params . referrer_policy ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  user_involvement  =  params . user_involvement ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-30 14:14:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  source_element  =  params . source_element ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-15 12:28:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  initial_insertion  =  params . initial_insertion ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  active_document  =  * this - > active_document ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  vm  =  this - > vm ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Let cspNavigationType be "form-submission" if formDataEntryList is non-null; otherwise "other".
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:10:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  csp_navigation_type  =  form_data_entry_list . has_value ( )  ?  ContentSecurityPolicy : : Directives : : Directive : : NavigationType : : FormSubmission  :  ContentSecurityPolicy : : Directives : : Directive : : NavigationType : : Other ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Let sourceSnapshotParams be the result of snapshotting source snapshot params given sourceDocument.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-25 20:34:50 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  source_snapshot_params  =  source_document - > snapshot_source_snapshot_params ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Let initiatorOriginSnapshot be a new opaque origin.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  initiator_origin_snapshot  =  URL : : Origin : : create_opaque ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. Let initiatorBaseURLSnapshot be about:blank.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  initiator_base_url_snapshot  =  URL : : about_blank ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: 5. If sourceDocument is null:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( false )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Assert: userInvolvement is "browser UI".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        VERIFY ( user_involvement  = =  UserNavigationInvolvement : : BrowserUI ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. If url's scheme is "javascript", then set initiatorOriginSnapshot to navigable's active document's origin.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( url . scheme ( )  = =  " javascript " sv ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            initiator_origin_snapshot  =  active_document . origin ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 6. Otherwise:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Assert: userInvolvement is not "browser UI".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: We currently crash if we do this! Uncomment once other places are fixed to handle browser UI navigation.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // VERIFY(user_involvement != UserNavigationInvolvement::BrowserUI);
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. If sourceDocument's node navigable is not allowed by sandboxing to navigate navigable given sourceSnapshotParams:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // NB: This step is handled in Navigable::navigate()
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. Set initiatorOriginSnapshot to sourceDocument's origin.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        initiator_origin_snapshot  =  source_document - > origin ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 4. Set initiatorBaseURLSnapshot to sourceDocument's document base URL.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        initiator_base_url_snapshot  =  source_document - > base_url ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 15:58:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. If sourceDocument's node navigable is not allowed by sandboxing to navigate navigable given sourceSnapshotParams, then:
 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: This step is handled in Navigable::navigate()
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 7. Let navigationId be the result of generating a random UUID.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    String  navigation_id  =  MUST ( Crypto : : generate_random_uuid ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: 8. If the surrounding agent is equal to navigable's active document's relevant agent, then continue these steps.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //           Otherwise, queue a global task on the navigation and traversal task source given navigable's active window to continue these steps.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 9. If navigable's active document's unload counter is greater than 0,
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 12:31:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //    then invoke WebDriver BiDi navigation failed with navigable and a WebDriver BiDi navigation status whose id
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    is navigationId, status is "canceled", and url is url, and return.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( active_document . unload_counter ( )  >  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 12:31:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: invoke WebDriver BiDi navigation failed with navigable and a WebDriver BiDi navigation status whose id
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //        is navigationId, status is "canceled", and url is url
 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 10. Let container be navigable's container.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 16:06:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  container  =  m_container ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 15:58:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 11. If container is an iframe element and will lazy load element steps given container returns true,
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 15:58:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     then stop intersection-observing a lazy loading element container and set container's lazy load resumption steps to null.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 16:06:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( container  & &  container - > is_html_iframe_element ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  iframe_element  =  static_cast < HTMLIFrameElement & > ( * container ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( iframe_element . will_lazy_load_element ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            iframe_element . document ( ) . stop_intersection_observing_a_lazy_loading_element ( iframe_element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            iframe_element . set_lazy_load_resumption_steps ( nullptr ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 15:58:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 12. If historyHandling is "auto", then:
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( history_handling  = =  Bindings : : NavigationHistoryBehavior : : Auto )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: Fix spec typo targetNavigable --> navigable
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. If url equals navigable's active document's URL,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //     and initiatorOriginSnapshot is same origin with targetNavigable's active document's origin,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //     then set historyHandling to "replace".
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 00:43:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( url  = =  active_document . url ( )  & &  initiator_origin_snapshot . is_same_origin ( active_document . origin ( ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            history_handling  =  Bindings : : NavigationHistoryBehavior : : Replace ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Otherwise, set historyHandling to "push".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            history_handling  =  Bindings : : NavigationHistoryBehavior : : Push ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 13. If the navigation must be a replace given url and navigable's active document, then set historyHandling to "replace".
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( navigation_must_be_a_replace ( url ,  active_document ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        history_handling  =  Bindings : : NavigationHistoryBehavior : : Replace ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 14. If all of the following are true:
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 15:58:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     - documentResource is null;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     - response is null;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     - url equals navigable's active session history entry's URL with exclude fragments set to true; and
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     - url's fragment is non-null,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     then:
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( document_resource . has < Empty > ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        & &  ! response 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        & &  url . equals ( active_session_history_entry ( ) - > url ( ) ,  URL : : ExcludeFragment : : Yes ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-12 16:52:42 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        & &  url . fragment ( ) . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-30 14:14:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Navigate to a fragment given navigable, url, historyHandling, userInvolvement, sourceElement, navigationAPIState, and navigationId.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        navigate_to_a_fragment ( url ,  to_history_handling_behavior ( history_handling ) ,  user_involvement ,  source_element ,  navigation_api_state ,  navigation_id ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Return.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 15. If navigable's parent is non-null, then set navigable's is delaying load events to true.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( parent ( )  ! =  nullptr ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        set_delaying_load_events ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 16. Let targetSnapshotParams be the result of snapshotting target snapshot params given navigable.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 12:31:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    [[maybe_unused]]  auto  target_snapshot_params  =  snapshot_target_snapshot_params ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: 17. Invoke WebDriver BiDi navigation started with navigable and a new WebDriver BiDi navigation status whose id is navigationId, status is "pending", and url is url.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 18. If navigable's ongoing navigation is "traversal", then:
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ongoing_navigation ( ) . has < Traversal > ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 12:31:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: 1. Invoke WebDriver BiDi navigation failed with navigable and a new WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is url.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Return.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 19. Set the ongoing navigation for navigable to navigationId.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 15:22:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    set_ongoing_navigation ( navigation_id ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 20. If url's scheme is "javascript", then:
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( url . scheme ( )  = =  " javascript " sv )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-15 12:28:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Queue a global task on the navigation and traversal task source given navigable's active window to navigate to a javascript: URL given navigable, url, historyHandling, sourceSnapshotParams, initiatorOriginSnapshot, userInvolvement, cspNavigationType, and initialInsertion.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        VERIFY ( active_window ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-15 12:28:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        queue_global_task ( Task : : Source : : NavigationAndTraversal ,  * active_window ( ) ,  GC : : create_function ( heap ( ) ,  [ this ,  url ,  history_handling ,  source_snapshot_params ,  initiator_origin_snapshot ,  user_involvement ,  csp_navigation_type ,  initial_insertion ,  navigation_id ]  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            navigate_to_a_javascript_url ( url ,  to_history_handling_behavior ( history_handling ) ,  source_snapshot_params ,  initiator_origin_snapshot ,  user_involvement ,  csp_navigation_type ,  initial_insertion ,  navigation_id ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 22:04:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Return.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 21. If all of the following are true:
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     - userInvolvement is not "browser UI";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     - navigable's active document's origin is same origin-domain with sourceDocument's origin;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     - navigable's active document's is initial about:blank is false; and
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     - url's scheme is a fetch scheme
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     then:
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 22:21:20 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( user_involvement  ! =  UserNavigationInvolvement : : BrowserUI  & &  active_document . origin ( ) . is_same_origin_domain ( source_document - > origin ( ) )  & &  ! active_document . is_initial_about_blank ( )  & &  Fetch : : Infrastructure : : is_fetch_scheme ( url . scheme ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Let navigation be navigable's active window's navigation API.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        VERIFY ( active_window ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  navigation  =  active_window ( ) - > navigation ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Let entryListForFiring be formDataEntryList if documentResource is a POST resource; otherwise, null.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  entry_list_for_firing  =  [ & ] ( )  - >  Optional < Vector < XHR : : FormDataEntry > >  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( document_resource . has < POSTResource > ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  form_data_entry_list ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. Let navigationAPIStateForFiring be navigationAPIState if navigationAPIState is not null;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    otherwise, StructuredSerializeForStorage(undefined).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  navigation_api_state_for_firing  =  navigation_api_state . value_or ( MUST ( structured_serialize_for_storage ( vm ,  JS : : js_undefined ( ) ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 16:08:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 4. Let continue be the result of firing a push/replace/reload navigate event at navigation
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    with navigationType set to historyHandling, isSameDocument set to false, userInvolvement set to userInvolvement,
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-30 14:14:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        //    sourceElement set to sourceElement, formDataEntryList set to entryListForFiring, destinationURL set to url,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    and navigationAPIState set to navigationAPIStateForFiring.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 16:08:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  navigation_type  =  [ ] ( Bindings : : NavigationHistoryBehavior  history_handling )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            switch  ( history_handling )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  Bindings : : NavigationHistoryBehavior : : Push : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  Bindings : : NavigationType : : Push ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  Bindings : : NavigationHistoryBehavior : : Replace : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  Bindings : : NavigationType : : Replace ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  Bindings : : NavigationHistoryBehavior : : Auto : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } ( history_handling ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-30 14:14:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  continue_  =  navigation - > fire_a_push_replace_reload_navigate_event ( navigation_type ,  url ,  false ,  user_involvement ,  source_element ,  entry_list_for_firing ,  navigation_api_state_for_firing ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 16:08:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 5. If continue is false, then return.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! continue_ ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 15:58:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // AD-HOC: Tell the UI that we started loading.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-31 18:33:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is_top_level_traversable ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-03 20:29:37 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        active_browsing_context ( ) - > page ( ) . client ( ) . page_did_start_loading ( url ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-31 18:33:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 14:32:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: 22. If sourceDocument is navigable's container document, then reserve deferred fetch quota for navigable's container given url's origin.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 23. In parallel, run these steps:
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Platform : : EventLoopPlugin : : the ( ) . deferred_invoke ( GC : : create_function ( heap ( ) ,  [ this ,  source_snapshot_params ,  target_snapshot_params ,  csp_navigation_type ,  document_resource ,  url ,  navigation_id ,  referrer_policy ,  initiator_origin_snapshot ,  response ,  history_handling ,  initiator_base_url_snapshot ,  user_involvement ]  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // AD-HOC: Not in the spec but subsequent steps will fail if the navigable doesn't have an active window.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! active_window ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-05 02:41:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            set_delaying_load_events ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-05 23:36:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-05 02:41:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-05 23:36:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-02 23:56:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Let unloadPromptCanceled be the result of checking if unloading is user-canceled for navigable's active document's inclusive descendant navigables.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  unload_prompt_canceled  =  traversable_navigable ( ) - > check_if_unloading_is_canceled ( this - > active_document ( ) - > inclusive_descendant_navigables ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-08 12:54:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. If unloadPromptCanceled is not "continue", or navigable's ongoing navigation is no longer navigationId:
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-02 23:56:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( unload_prompt_canceled  ! =  TraversableNavigable : : CheckIfUnloadingIsCanceledResult : : Continue  | |  ! ongoing_navigation ( ) . has < String > ( )  | |  ongoing_navigation ( ) . get < String > ( )  ! =  navigation_id )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 12:31:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: 1. Invoke WebDriver BiDi navigation failed with navigable and a new WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is url.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-22 22:28:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 2. Abort these steps.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-05 02:41:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            set_delaying_load_events ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-22 22:28:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // AD-HOC: Not in the spec but subsequent steps will fail if the navigable doesn't have an active window.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! active_window ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            set_delaying_load_events ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-31 23:42:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. Queue a global task on the navigation and traversal task source given navigable's active window to abort a document and its descendants given navigable's active document.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        queue_global_task ( Task : : Source : : NavigationAndTraversal ,  * active_window ( ) ,  GC : : create_function ( heap ( ) ,  [ this ]  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( this - > active_document ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-31 23:42:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            this - > active_document ( ) - > abort_a_document_and_its_descendants ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 22:04:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 4. Let documentState be a new document state with
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    request referrer policy: referrerPolicy
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    initiator origin: initiatorOriginSnapshot
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-05 09:48:23 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        //    resource: documentResource
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        //    navigable target name: navigable's target name
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        GC : : Ref < DocumentState >  document_state  =  * heap ( ) . allocate < DocumentState > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        document_state - > set_request_referrer_policy ( referrer_policy ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        document_state - > set_initiator_origin ( initiator_origin_snapshot ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        document_state - > set_resource ( document_resource ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        document_state - > set_navigable_target_name ( target_name ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 15:58:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 5. If url matches about:blank or is about:srcdoc, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: Is calling url_matches_about_srcdoc() correct? https://github.com/whatwg/html/issues/10900
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-08 22:17:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( url_matches_about_blank ( url )  | |  url_matches_about_srcdoc ( url ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 15:58:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // AD-HOC: document_resource cannot have an Empty if the url is about:srcdoc since we rely on document_resource
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            //         having a String to call create_navigation_params_from_a_srcdoc_resource
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-08 22:17:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( url_matches_about_srcdoc ( url )  & &  document_resource . has < Empty > ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                document_state - > set_resource ( {  String  { }  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 1. Set documentState's origin to initiatorOriginSnapshot.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            document_state - > set_origin ( document_state - > initiator_origin ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // 2. Set documentState's about base URL to initiatorBaseURLSnapshot.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            document_state - > set_about_base_url ( initiator_base_url_snapshot ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 6. Let historyEntry be a new session history entry, with its URL set to url and its document state set to documentState.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        GC : : Ref < SessionHistoryEntry >  history_entry  =  * heap ( ) . allocate < SessionHistoryEntry > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        history_entry - > set_url ( url ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        history_entry - > set_document_state ( document_state ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:59:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 7. Let navigationParams be null.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-13 19:08:01 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        NavigationParamsVariant  navigation_params  =  Navigable : : NullOrError  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:59:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: 8. If response is non-null:
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( response )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-05 09:48:23 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 9. Attempt to populate the history entry's document for historyEntry, given navigable, "navigate",
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    sourceSnapshotParams, targetSnapshotParams, userInvolvement, navigationId, navigationParams,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    cspNavigationType, with allowPOST set to true and completionSteps set to the following step:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        populate_session_history_entry_document ( history_entry ,  source_snapshot_params ,  target_snapshot_params ,  user_involvement ,  navigation_id ,  navigation_params ,  csp_navigation_type ,  true ,  GC : : create_function ( heap ( ) ,  [ this ,  history_entry ,  history_handling ,  navigation_id ,  user_involvement ]  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 1. Append session history traversal steps to navigable's traversable to finalize a cross-document navigation given navigable, historyHandling, userInvolvement, and historyEntry.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            traversable_navigable ( ) - > append_session_history_traversal_steps ( GC : : create_function ( heap ( ) ,  [ this ,  history_entry ,  history_handling ,  navigation_id ,  user_involvement ]  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-05 23:36:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( this - > has_been_destroyed ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    // NOTE: This check is not in the spec but we should not continue navigation if navigable has been destroyed.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-05 02:41:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    set_delaying_load_events ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-05 23:36:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-09 22:58:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( this - > ongoing_navigation ( )  ! =  navigation_id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    // NOTE: This check is not in the spec but we should not continue navigation if ongoing navigation id has changed.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-05 02:41:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    set_delaying_load_events ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-09 22:58:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                finalize_a_cross_document_navigation ( * this ,  to_history_handling_behavior ( history_handling ) ,  user_involvement ,  history_entry ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 17:45:56 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 15:41:50 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } ) ) . release_value_but_fixme_should_propagate_errors ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-31 02:39:29 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:59:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate-fragid
  
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : navigate_to_a_fragment ( URL : : URL  const &  url ,  HistoryHandlingBehavior  history_handling ,  UserNavigationInvolvement  user_involvement ,  GC : : Ptr < DOM : : Element >  source_element ,  Optional < SerializationRecord >  navigation_api_state ,  String  navigation_id )  
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:59:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Let navigation be navigable's active window's navigation API.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( active_window ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:59:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  navigation  =  active_window ( ) - > navigation ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Let destinationNavigationAPIState be navigable's active session history entry's navigation API state.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. If navigationAPIState is not null, then set destinationNavigationAPIState to navigationAPIState.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  destination_navigation_api_state  =  navigation_api_state . has_value ( )  ?  * navigation_api_state  :  active_session_history_entry ( ) - > navigation_api_state ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:59:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-30 14:14:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. Let continue be the result of firing a push/replace/reload navigate event at navigation with navigationType
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    set to historyHandling, isSameDocument set to true, userInvolvement set to userInvolvement, sourceElement set
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    to sourceElement, destinationURL set to url, and navigationAPIState set to destinationNavigationAPIState.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:59:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  navigation_type  =  history_handling  = =  HistoryHandlingBehavior : : Push  ?  Bindings : : NavigationType : : Push  :  Bindings : : NavigationType : : Replace ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-30 14:14:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    bool  const  continue_  =  navigation - > fire_a_push_replace_reload_navigate_event ( navigation_type ,  url ,  true ,  user_involvement ,  source_element ,  { } ,  destination_navigation_api_state ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:59:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. If continue is false, then return.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! continue_ ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:31:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 6. Let historyEntry be a new session history entry, with
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //      URL: url
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //      document state: navigable's active session history entry's document state
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //      navigation API state: destinationNavigationAPIState
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //      scroll restoration mode: navigable's active session history entry's scroll restoration mode
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ref < SessionHistoryEntry >  history_entry  =  heap ( ) . allocate < SessionHistoryEntry > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    history_entry - > set_url ( url ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    history_entry - > set_document_state ( active_session_history_entry ( ) - > document_state ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    history_entry - > set_navigation_api_state ( destination_navigation_api_state ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    history_entry - > set_scroll_restoration_mode ( active_session_history_entry ( ) - > scroll_restoration_mode ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:31:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 7. Let entryToReplace be navigable's active session history entry if historyHandling is "replace", otherwise null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  entry_to_replace  =  history_handling  = =  HistoryHandlingBehavior : : Replace  ?  active_session_history_entry ( )  :  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-23 22:59:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 8. Let history be navigable's active document's history object.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  history  =  active_document ( ) - > history ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:31:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-23 22:59:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 9. Let scriptHistoryIndex be history's index.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  script_history_index  =  history - > m_index ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:31:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-23 22:59:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 10. Let scriptHistoryLength be history's length.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  script_history_length  =  history - > m_length ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:31:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 11. If historyHandling is "push", then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( history_handling  = =  HistoryHandlingBehavior : : Push )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:59:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Set history's state to null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        history - > set_state ( JS : : js_null ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-23 22:59:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Increment scriptHistoryIndex.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        script_history_index + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. Set scriptHistoryLength to scriptHistoryIndex + 1.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        script_history_length  =  script_history_index  +  1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:31:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 12. Set navigable's active session history entry to historyEntry.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_active_session_history_entry  =  history_entry ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-23 22:59:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 13. Update document for history step application given navigable's active document, historyEntry, true, scriptHistoryIndex, and scriptHistoryLength.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:59:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // AD HOC: Skip updating the navigation api entries twice here
 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-21 23:09:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    active_document ( ) - > update_for_history_step_application ( * history_entry ,  true ,  script_history_length ,  script_history_index ,  navigation_type ,  { } ,  { } ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:31:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:59:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 14. Update the navigation API entries for a same-document navigation given navigation, historyEntry, and historyHandling.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    navigation - > update_the_navigation_api_entries_for_a_same_document_navigation ( history_entry ,  navigation_type ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:31:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 15. Scroll to the fragment given navigable's active document.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: Specification doesn't say when document url needs to update during fragment navigation
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    active_document ( ) - > set_url ( url ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    active_document ( ) - > scroll_to_the_fragment ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 16. Let traversable be navigable's traversable navigable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  traversable  =  traversable_navigable ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 17. Append the following session history synchronous navigation steps involving navigable to traversable:
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    traversable - > append_session_history_synchronous_navigation_steps ( * this ,  GC : : create_function ( heap ( ) ,  [ this ,  traversable ,  history_entry ,  entry_to_replace ,  navigation_id ,  history_handling ,  user_involvement ]  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Finalize a same-document navigation given traversable, navigable, historyEntry, entryToReplace, historyHandling, and userInvolvement.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        finalize_a_same_document_navigation ( * traversable ,  * this ,  history_entry ,  entry_to_replace ,  history_handling ,  user_involvement ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:31:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 12:31:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: 2. Invoke WebDriver BiDi fragment navigated with navigable and a new WebDriver BiDi
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:31:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        //            navigation status whose id is navigationId, url is url, and status is "complete".
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 19:18:18 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        ( void ) navigation_id ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 17:45:56 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#evaluate-a-javascript:-url
  
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:27:26 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://whatpr.org/html/9893/browsing-the-web.html#evaluate-a-javascript:-url
  
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC : : Ptr < DOM : : Document >  Navigable : : evaluate_javascript_url ( URL : : URL  const &  url ,  URL : : Origin  const &  new_document_origin ,  UserNavigationInvolvement  user_involvement ,  String  navigation_id )  
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  vm  =  this - > vm ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( active_window ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  realm  =  active_window ( ) - > realm ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Let urlString be the result of running the URL serializer on url.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  url_string  =  url . serialize ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Let encodedScriptSource be the result of removing the leading "javascript:" from urlString.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-03 22:31:33 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  encoded_script_source  =  url_string . bytes_as_string_view ( ) . substring_view ( 11 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 13:47:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Let scriptSource be the UTF-8 decoding of the percent-decoding of encodedScriptSource.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-11 20:15:39 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  script_source  =  URL : : percent_decode ( encoded_script_source ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. Let settings be targetNavigable's active document's relevant settings object.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  settings  =  active_document ( ) - > relevant_settings_object ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. Let baseURL be settings's API base URL.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  base_url  =  settings . api_base_url ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:27:26 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 6. Let script be the result of creating a classic script given scriptSource, settings's realm, baseURL, and the default classic script fetch options.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  script  =  HTML : : ClassicScript : : create ( " (javascript url) " ,  script_source ,  settings . realm ( ) ,  base_url ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 7. Let evaluationStatus be the result of running the classic script script.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  evaluation_status  =  script - > run ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 8. Let result be null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    String  result ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 9. If evaluationStatus is a normal completion, and evaluationStatus.[[Value]] is a String, then set result to evaluationStatus.[[Value]].
 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-04 18:11:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( evaluation_status . type ( )  = =  JS : : Completion : : Type : : Normal  & &  evaluation_status . value ( ) . is_string ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        result  =  evaluation_status . value ( ) . as_string ( ) . utf8_string ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 10. Otherwise, return null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 11. Let response be a new response with
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     URL: targetNavigable's active document's URL
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     header list: «(`Content-Type`, `text/html;charset=utf-8`)»
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     body: the UTF-8 encoding of result, as a body
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  response  =  Fetch : : Infrastructure : : Response : : create ( vm ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    response - > url_list ( ) . append ( active_document ( ) - > url ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-26 13:24:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  header  =  Fetch : : Infrastructure : : Header : : from_string_pair ( " Content-Type " sv ,  " text/html " sv ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    response - > header_list ( ) - > append ( move ( header ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-04 16:06:01 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    response - > set_body ( Fetch : : Infrastructure : : byte_sequence_as_body ( realm ,  result . bytes ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 12. Let policyContainer be targetNavigable's active document's policy container.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  policy_container  =  active_document ( ) - > policy_container ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:50:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 13. Let finalSandboxFlags be policyContainer's CSP list's CSP-derived sandboxing flags.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  final_sandbox_flags  =  policy_container - > csp_list - > csp_derived_sandboxing_flags ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 14. Let coop be targetNavigable's active document's opener policy.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  coop  =  active_document ( ) - > opener_policy ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 15. Let coopEnforcementResult be a new opener policy enforcement result with
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     url: url
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     origin: newDocumentOrigin
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     opener policy: coop
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    OpenerPolicyEnforcementResult  coop_enforcement_result  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        . url  =  url , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        . origin  =  new_document_origin , 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        . opener_policy  =  coop , 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 16. Let navigationParams be a new navigation params, with
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     id: navigationId
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     navigable: targetNavigable
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     request: null
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     response: response
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     fetch controller: null
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     commit early hints: null
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     COOP enforcement result: coopEnforcementResult
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     reserved environment: null
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     origin: newDocumentOrigin
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     policy container: policyContainer
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     final sandboxing flag set: finalSandboxFlags
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-18 19:48:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     opener policy: coop
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     FIXME: navigation timing type: "navigate"
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     about base URL: targetNavigable's active document's about base URL
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    //     user involvement: userInvolvement
 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-15 14:33:29 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  navigation_params  =  vm . heap ( ) . allocate < NavigationParams > ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        navigation_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        this , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        nullptr , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        response , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        nullptr , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        nullptr , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        move ( coop_enforcement_result ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        nullptr , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        new_document_origin , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        policy_container , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        final_sandbox_flags , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        coop , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        active_document ( ) - > about_base_url ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        user_involvement ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 17. Return the result of loading an HTML document given navigationParams.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-28 13:10:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  load_document ( navigation_params ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate-to-a-javascript:-url
  
						 
					
						
							
								
									
										
										
										
											2025-05-15 12:28:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : navigate_to_a_javascript_url ( URL : : URL  const &  url ,  HistoryHandlingBehavior  history_handling ,  GC : : Ref < SourceSnapshotParams >  source_snapshot_params ,  URL : : Origin  const &  initiator_origin ,  UserNavigationInvolvement  user_involvement ,  ContentSecurityPolicy : : Directives : : Directive : : NavigationType  csp_navigation_type ,  InitialInsertion  initial_insertion ,  String  navigation_id )  
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:50:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  vm  =  this - > vm ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Assert: historyHandling is "replace".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( history_handling  = =  HistoryHandlingBehavior : : Replace ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Set the ongoing navigation for targetNavigable to null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    set_ongoing_navigation ( { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. If initiatorOrigin is not same origin-domain with targetNavigable's active document's origin, then return.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! initiator_origin . is_same_origin_domain ( active_document ( ) - > origin ( ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-04 16:06:01 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:50:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. Let request be a new request whose URL is url and whose policy container is sourceSnapshotParams's source policy container.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  request  =  Fetch : : Infrastructure : : Request : : create ( vm ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    request - > set_url ( url ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    request - > set_policy_container ( source_snapshot_params - > source_policy_container ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-23 22:39:16 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // AD-HOC: See https://github.com/whatwg/html/issues/4651, requires some investigation to figure out what we should be setting here.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    request - > set_client ( source_snapshot_params - > fetch_client ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 17:50:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. If the result of should navigation request of type be blocked by Content Security Policy? given request and cspNavigationType is "Blocked", then return.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ContentSecurityPolicy : : should_navigation_request_of_type_be_blocked_by_content_security_policy ( request ,  csp_navigation_type )  = =  ContentSecurityPolicy : : Directives : : Directive : : Result : : Blocked ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 6. Let newDocument be the result of evaluating a javascript: URL given targetNavigable, url, initiatorOrigin, and userInvolvement.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  new_document  =  evaluate_javascript_url ( url ,  initiator_origin ,  user_involvement ,  navigation_id ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-15 12:28:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 7. If newDocument is null:
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! new_document )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-15 12:28:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. If initialInsertion is true and targetNavigable's active document's is initial about:blank is true,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    then run the iframe load event steps given targetNavigable's container.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( initial_insertion  = =  InitialInsertion : : Yes  & &  active_document ( ) - > is_initial_about_blank ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            run_iframe_load_event_steps ( as < HTMLIFrameElement > ( * container ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Return.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // NOTE: In this case, some JavaScript code was executed, but no new Document was created, so we will not perform a navigation.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-04 16:06:01 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 8. Assert: initiatorOrigin is newDocument's origin.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( initiator_origin  = =  new_document - > origin ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 9. Let entryToReplace be targetNavigable's active session history entry.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  entry_to_replace  =  active_session_history_entry ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 10. Let oldDocState be entryToReplace's document state.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  old_doc_state  =  entry_to_replace - > document_state ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 11. Let documentState be a new document state with
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     document: newDocument
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     history policy container: a clone of the oldDocState's history policy container if it is non-null; null otherwise
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     request referrer: oldDocState's request referrer
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     request referrer policy: oldDocState's request referrer policy
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     initiator origin: initiatorOrigin
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     origin: initiatorOrigin
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     about base URL: oldDocState's about base URL
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     resource: null
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     ever populated: true
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     navigable target name: oldDocState's navigable target name
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ref < DocumentState >  document_state  =  * heap ( ) . allocate < DocumentState > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    document_state - > set_document ( new_document ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    document_state - > set_history_policy_container ( old_doc_state - > history_policy_container ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    document_state - > set_request_referrer ( old_doc_state - > request_referrer ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    document_state - > set_request_referrer_policy ( old_doc_state - > request_referrer_policy ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    document_state - > set_initiator_origin ( initiator_origin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    document_state - > set_origin ( initiator_origin ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 17:31:25 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    document_state - > set_about_base_url ( old_doc_state - > about_base_url ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    document_state - > set_ever_populated ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    document_state - > set_navigable_target_name ( old_doc_state - > navigable_target_name ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 12. Let historyEntry be a new session history entry, with
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     URL: entryToReplace's URL
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     document state: documentState
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ref < SessionHistoryEntry >  history_entry  =  * heap ( ) . allocate < SessionHistoryEntry > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    history_entry - > set_url ( entry_to_replace - > url ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    history_entry - > set_document_state ( document_state ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 15:03:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 13. Append session history traversal steps to targetNavigable's traversable to finalize a cross-document navigation with targetNavigable, historyHandling, userInvolvement, and historyEntry.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    traversable_navigable ( ) - > append_session_history_traversal_steps ( GC : : create_function ( heap ( ) ,  [ this ,  history_entry ,  history_handling ,  user_involvement ]  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        finalize_a_cross_document_navigation ( * this ,  history_handling ,  user_involvement ,  history_entry ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 17:45:56 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 17:46:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-07 00:08:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#reload
  
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : reload ( UserNavigationInvolvement  user_involvement )  
						 
					
						
							
								
									
										
										
										
											2023-04-07 00:08:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Set navigable's active session history entry's document state's reload pending to true.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    active_session_history_entry ( ) - > document_state ( ) - > set_reload_pending ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-07 00:08:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Let traversable be navigable's traversable navigable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  traversable  =  traversable_navigable ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 01:22:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Append the following session history traversal steps to traversable:
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    traversable - > append_session_history_traversal_steps ( GC : : create_function ( heap ( ) ,  [ traversable ,  user_involvement ]  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Apply the reload history step to traversable given userInvolvement.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        traversable - > apply_the_reload_history_step ( user_involvement ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 17:45:56 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-07 00:08:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-24 16:18:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#the-navigation-must-be-a-replace
  
						 
					
						
							
								
									
										
										
										
											2024-03-18 16:22:27 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  navigation_must_be_a_replace ( URL : : URL  const &  url ,  DOM : : Document  const &  document )  
						 
					
						
							
								
									
										
										
										
											2023-08-24 16:18:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  url . scheme ( )  = =  " javascript " sv  | |  document . is_initial_about_blank ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#allowed-to-navigate
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								bool  Navigable : : allowed_by_sandboxing_to_navigate ( Navigable  const &  target ,  SourceSnapshotParams  const &  source_snapshot_params )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  source  =  * this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  is_ancestor_of  =  [ ] ( Navigable  const &  a ,  Navigable  const &  b )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto  parent  =  b . parent ( ) ;  parent ;  parent  =  parent - > parent ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( parent . ptr ( )  = =  & a ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // A navigable source is allowed by sandboxing to navigate a second navigable target,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // given a source snapshot params sourceSnapshotParams, if the following steps return true:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. If source is target, then return true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( & source  = =  & target ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. If source is an ancestor of target, then return true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is_ancestor_of ( source ,  target ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. If target is an ancestor of source, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is_ancestor_of ( target ,  source ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. If target is not a top-level traversable, then return true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! target . is_top_level_traversable ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. If sourceSnapshotParams's has transient activation is true, and sourceSnapshotParams's sandboxing flags's
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    sandboxed top-level navigation with user activation browsing context flag is set, then return false.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( source_snapshot_params . has_transient_activation  & &  has_flag ( source_snapshot_params . sandboxing_flags ,  SandboxingFlagSet : : SandboxedTopLevelNavigationWithUserActivation ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. If sourceSnapshotParams's has transient activation is false, and sourceSnapshotParams's sandboxing flags's
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    sandboxed top-level navigation without user activation browsing context flag is set, then return false.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! source_snapshot_params . has_transient_activation  & &  has_flag ( source_snapshot_params . sandboxing_flags ,  SandboxingFlagSet : : SandboxedTopLevelNavigationWithoutUserActivation ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 4. Return true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. If target is a top-level traversable:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( target . is_top_level_traversable ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: 1. If source is the one permitted sandboxed navigator of target, then return true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. If sourceSnapshotParams's sandboxing flags's sandboxed navigation browsing context flag is set, then return false.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( has_flag ( source_snapshot_params . sandboxing_flags ,  SandboxingFlagSet : : SandboxedNavigation ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. Return true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. If sourceSnapshotParams's sandboxing flags's sandboxed navigation browsing context flag is set, then return false.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 6. Return true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  ! has_flag ( source_snapshot_params . sandboxing_flags ,  SandboxingFlagSet : : SandboxedNavigation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#snapshotting-target-snapshot-params
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								TargetSnapshotParams  Navigable : : snapshot_target_snapshot_params ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // To snapshot target snapshot params given a navigable targetNavigable, return a new target snapshot params
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // with sandboxing flags set to the result of determining the creation sandboxing flags given targetNavigable's
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // active browsing context and targetNavigable's container.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  {  determine_the_creation_sandboxing_flags ( * active_browsing_context ( ) ,  container ( ) )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#finalize-a-cross-document-navigation
  
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  finalize_a_cross_document_navigation ( GC : : Ref < Navigable >  navigable ,  HistoryHandlingBehavior  history_handling ,  UserNavigationInvolvement  user_involvement ,  GC : : Ref < SessionHistoryEntry >  history_entry )  
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-09-05 23:36:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: This is not in the spec but we should not navigate destroyed navigable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( navigable - > has_been_destroyed ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. FIXME: Assert: this is running on navigable's traversable navigable's session history traversal queue.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Set navigable's is delaying load events to false.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    navigable - > set_delaying_load_events ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. If historyEntry's document is null, then return.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 16:14:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! history_entry - > document ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. If all of the following are true:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    - navigable's parent is null;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    - historyEntry's document's browsing context is not an auxiliary browsing context whose opener browsing context is non-null; and
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    - historyEntry's document's origin is not navigable's active document's origin
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    then set historyEntry's document state's navigable target name to the empty string.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-17 21:43:25 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( navigable - > parent ( )  = =  nullptr 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        & &  ! ( history_entry - > document ( ) - > browsing_context ( ) - > is_auxiliary ( )  & &  history_entry - > document ( ) - > browsing_context ( ) - > opener_browsing_context ( )  ! =  nullptr ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        & &  history_entry - > document ( ) - > origin ( )  ! =  navigable - > active_document ( ) - > origin ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        history_entry - > document_state ( ) - > set_navigable_target_name ( String  { } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-17 21:43:25 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. Let entryToReplace be navigable's active session history entry if historyHandling is "replace", otherwise null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  entry_to_replace  =  history_handling  = =  HistoryHandlingBehavior : : Replace  ?  navigable - > active_session_history_entry ( )  :  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 6. Let traversable be navigable's traversable navigable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  traversable  =  navigable - > traversable_navigable ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 7. Let targetStep be null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    int  target_step ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 8. Let targetEntries be the result of getting session history entries for navigable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  target_entries  =  navigable - > get_session_history_entries ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 9. If entryToReplace is null, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( entry_to_replace  = =  nullptr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Clear the forward session history of traversable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        traversable - > clear_the_forward_session_history ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Set targetStep to traversable's current session history step + 1.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        target_step  =  traversable - > current_session_history_step ( )  +  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. Set historyEntry's step to targetStep.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        history_entry - > set_step ( target_step ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 4. Append historyEntry to targetEntries.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        target_entries . append ( history_entry ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Replace entryToReplace with historyEntry in targetEntries.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        * ( target_entries . find ( * entry_to_replace ) )  =  history_entry ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Set historyEntry's step to entryToReplace's step.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        history_entry - > set_step ( entry_to_replace - > step ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. If historyEntry's document state's origin is same origin with entryToReplace's document state's origin,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    then set historyEntry's navigation API key to entryToReplace's navigation API key.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( history_entry - > document_state ( ) - > origin ( ) . has_value ( )  & &  entry_to_replace - > document_state ( ) - > origin ( ) . has_value ( )  & &  history_entry - > document_state ( ) - > origin ( ) - > is_same_origin ( * entry_to_replace - > document_state ( ) - > origin ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            history_entry - > set_navigation_api_key ( entry_to_replace - > navigation_api_key ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 4. Set targetStep to traversable's current session history step.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        target_step  =  traversable - > current_session_history_step ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 10. Apply the push/replace history step targetStep to traversable given historyHandling and userInvolvement.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    traversable - > apply_the_push_or_replace_history_step ( target_step ,  history_handling ,  user_involvement ,  TraversableNavigable : : SynchronousNavigation : : No ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-26 12:30:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // AD-HOC: If we're inside a navigable container, let's trigger a relayout in the container document.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //         This allows size negotiation between the containing document and SVG documents to happen.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  container  =  navigable - > container ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-18 20:40:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  layout_node  =  container - > layout_node ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            layout_node - > set_needs_layout_update ( DOM : : SetNeedsLayoutReason : : FinalizeACrossDocumentNavigation ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-26 12:30:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-28 18:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:42:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#url-and-history-update-steps
  
						 
					
						
							
								
									
										
										
										
											2024-03-18 16:22:27 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  perform_url_and_history_update_steps ( DOM : : Document &  document ,  URL : : URL  new_url ,  Optional < SerializationRecord >  serialized_data ,  HistoryHandlingBehavior  history_handling )  
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:42:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Let navigable be document's node navigable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  navigable  =  document . navigable ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Let activeEntry be navigable's active session history entry.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  active_entry  =  navigable - > active_session_history_entry ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Let newEntry be a new session history entry, with
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //      URL: newURL
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //      serialized state: if serializedData is not null, serializedData; otherwise activeEntry's classic history API state
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //      document state: activeEntry's document state
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //      scroll restoration mode: activeEntry's scroll restoration mode
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:59:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: persisted user state: activeEntry's persisted user state
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ref < SessionHistoryEntry >  new_entry  =  document . heap ( ) . allocate < SessionHistoryEntry > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 15:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    new_entry - > set_url ( new_url ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    new_entry - > set_classic_history_api_state ( serialized_data . value_or ( active_entry - > classic_history_api_state ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    new_entry - > set_document_state ( active_entry - > document_state ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    new_entry - > set_scroll_restoration_mode ( active_entry - > scroll_restoration_mode ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:42:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. If document's is initial about:blank is true, then set historyHandling to "replace".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( document . is_initial_about_blank ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        history_handling  =  HistoryHandlingBehavior : : Replace ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. Let entryToReplace be activeEntry if historyHandling is "replace", otherwise null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  entry_to_replace  =  history_handling  = =  HistoryHandlingBehavior : : Replace  ?  active_entry  :  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 6. If historyHandling is "push", then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( history_handling  = =  HistoryHandlingBehavior : : Push )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-23 22:57:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Increment document's history object's index.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        document . history ( ) - > m_index + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Set document's history object's length to its index + 1.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        document . history ( ) - > m_length  =  document . history ( ) - > m_index  +  1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:42:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:59:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // If serializedData is not null, then restore the history object state given document and newEntry.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( serialized_data . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        document . restore_the_history_object_state ( new_entry ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:42:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 13:37:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 8. Set the URL given document to newURL.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:42:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    document . set_url ( new_url ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:59:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 9. Set document's latest entry to newEntry.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    document . set_latest_entry ( new_entry ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:42:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 10. Set navigable's active session history entry to newEntry.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    navigable - > set_active_session_history_entry ( new_entry ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:59:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 11. Update the navigation API entries for a same-document navigation given document's relevant global object's navigation API, newEntry, and historyHandling.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-21 09:12:05 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  relevant_global_object  =  as < Window > ( HTML : : relevant_global_object ( document ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:59:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  navigation_type  =  history_handling  = =  HistoryHandlingBehavior : : Push  ?  Bindings : : NavigationType : : Push  :  Bindings : : NavigationType : : Replace ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    relevant_global_object . navigation ( ) - > update_the_navigation_api_entries_for_a_same_document_navigation ( new_entry ,  navigation_type ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:42:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 12. Let traversable be navigable's traversable navigable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  traversable  =  navigable - > traversable_navigable ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 13. Append the following session history synchronous navigation steps involving navigable to traversable:
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    traversable - > append_session_history_synchronous_navigation_steps ( * navigable ,  GC : : create_function ( document . realm ( ) . heap ( ) ,  [ traversable ,  navigable ,  new_entry ,  entry_to_replace ,  history_handling ]  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 14:58:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Finalize a same-document navigation given traversable, navigable, newEntry, entryToReplace, historyHandling, and "none".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        finalize_a_same_document_navigation ( * traversable ,  * navigable ,  new_entry ,  entry_to_replace ,  history_handling ,  UserNavigationInvolvement : : None ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-31 11:51:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. FIXME: Invoke WebDriver BiDi history updated with navigable.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 17:45:56 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 14:42:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 16:00:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : scroll_offset_did_change ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // https://w3c.github.io/csswg-drafts/cssom-view-1/#scrolling-events
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Whenever a viewport gets scrolled (whether in response to user interaction or by an API), the user agent must run these steps:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // 1. Let doc be the viewport’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  doc  =  active_document ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( doc ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // 2. If doc is already in doc’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto &  target  :  doc - > pending_scroll_event_targets ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( target . ptr ( )  = =  doc ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // 3. Append doc to doc’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    doc - > pending_scroll_event_targets ( ) . append ( * doc ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelRect  Navigable : : to_top_level_rect ( CSSPixelRect  const &  a_rect )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  rect  =  a_rect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    rect . set_location ( to_top_level_position ( a_rect . location ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  rect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelPoint  Navigable : : to_top_level_position ( CSSPixelPoint  a_position )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  position  =  a_position ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-14 03:14:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  ancestor  =  this ;  ancestor ;  ancestor  =  ancestor - > parent ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 16:00:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( is < TraversableNavigable > ( * ancestor ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! ancestor - > container ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-14 11:14:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! ancestor - > container ( ) - > paintable ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 16:00:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-14 03:14:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: Handle CSS transforms that might affect the ancestor.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-14 11:14:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        position . translate_by ( ancestor - > container ( ) - > paintable ( ) - > box_type_agnostic_position ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 16:00:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-03 17:53:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : set_viewport_size ( CSSPixelSize  size )  
						 
					
						
							
								
									
										
										
										
											2023-08-22 16:00:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-06-17 16:29:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( m_viewport_size  = =  size ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 16:00:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-15 16:49:37 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    m_viewport_size  =  size ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-06-26 22:33:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! m_is_svg_page )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        m_backing_store_manager - > restart_resize_timer ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        m_backing_store_manager - > resize_backing_stores_if_needed ( Web : : Painting : : BackingStoreManager : : WindowResizingInProgress : : Yes ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        m_pending_set_browser_zoom_request  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 16:00:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  document  =  active_document ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-03 17:53:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // NOTE: Resizing the viewport changes the reference value for viewport-relative CSS lengths.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-04 10:01:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        document - > invalidate_style ( DOM : : StyleInvalidationReason : : NavigableSetViewportSize ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-08-05 16:56:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        document - > set_needs_media_query_evaluation ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-18 20:40:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  layout_node  =  document - > layout_node ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            layout_node - > set_needs_layout_update ( DOM : : SetNeedsLayoutReason : : NavigableSetViewportSize ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 16:00:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  document  =  active_document ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 16:47:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        document - > set_needs_display ( InvalidateDisplayList : : No ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-19 02:06:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 16:00:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        document - > inform_all_viewport_clients_about_the_current_viewport_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-03 17:53:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // Schedule the HTML event loop to ensure that a `resize` event gets fired.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        HTML : : main_thread_event_loop ( ) . schedule ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : perform_scroll_of_viewport ( CSSPixelPoint  new_position )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( m_viewport_scroll_offset  ! =  new_position )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        m_viewport_scroll_offset  =  new_position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        scroll_offset_did_change ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-06 15:32:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  document  =  active_document ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 16:47:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            document - > set_needs_display ( InvalidateDisplayList : : No ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-06 15:32:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            document - > set_needs_to_refresh_scroll_state ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-03 17:53:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            document - > inform_all_viewport_clients_about_the_current_viewport_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-06 15:32:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 16:00:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Schedule the HTML event loop to ensure that a `resize` event gets fired.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    HTML : : main_thread_event_loop ( ) . schedule ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-04 13:01:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/webappapis.html#rendering-opportunity
  
						 
					
						
							
								
									
										
										
										
											2023-09-20 08:09:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  Navigable : : has_a_rendering_opportunity ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // A navigable has a rendering opportunity if the user agent is currently able to present
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // the contents of the navigable to the user,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // accounting for hardware refresh rate constraints and user agent throttling for performance reasons,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // but considering content presentable even if it's outside the viewport.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // A navigable has no rendering opportunities if its active document is render-blocked
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // or if it is suppressed for view transitions;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // otherwise, rendering opportunities are determined based on hardware constraints
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // such as display refresh rates and other factors such as page performance
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // or whether the document's visibility state is "visible".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Rendering opportunities typically occur at regular intervals.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-18 20:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: Return `false` here if we're an inactive browser tab.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-26 22:33:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  is_ready_to_paint ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 08:09:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-26 15:39:13 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/nav-history-apis.html#inform-the-navigation-api-about-child-navigable-destruction
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : inform_the_navigation_api_about_child_navigable_destruction ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Inform the navigation API about aborting navigation in navigable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    inform_the_navigation_api_about_aborting_navigation ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: 2. Let navigation be navigable's active window's navigation API.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: 3. Let traversalAPIMethodTrackers be a clone of navigation's upcoming traverse API method trackers.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: 4. For each apiMethodTracker of traversalAPIMethodTrackers: reject the finished promise for apiMethodTracker with a new "AbortError" DOMException created in navigation's relevant realm.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 23:21:16 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/nav-history-apis.html#inform-the-navigation-api-about-aborting-navigation
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : inform_the_navigation_api_about_aborting_navigation ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: 1. If this algorithm is running on navigable's active window's relevant agent's event loop, then continue on to the following steps.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Otherwise, queue a global task on the navigation and traversal task source given navigable's active window to run the following steps.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // AD-HOC: Not in the spec but subsequent steps will fail if the navigable doesn't have an active window.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! active_window ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    queue_global_task ( Task : : Source : : NavigationAndTraversal ,  * active_window ( ) ,  GC : : create_function ( heap ( ) ,  [ this ]  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 23:21:16 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Let navigation be navigable's active window's navigation API.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 15:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        VERIFY ( active_window ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 23:21:16 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  navigation  =  active_window ( ) - > navigation ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. If navigation's ongoing navigate event is null, then return.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( navigation - > ongoing_navigate_event ( )  = =  nullptr ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 4. Abort the ongoing navigation given navigation.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        navigation - > abort_the_ongoing_navigation ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-16 22:04:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 23:21:16 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-18 12:52:13 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/browsing-the-web.html#event-uni
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								UserNavigationInvolvement  user_navigation_involvement ( DOM : : Event  const &  event )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // For convenience at certain call sites, the user navigation involvement for an Event event is defined as follows:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Assert: this algorithm is being called as part of an activation behavior definition.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Assert: event's type is "click".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( event . type ( )  = =  " click " _fly_string ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. If event's isTrusted is initialized to true, then return "activation".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. Return "none".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  event . is_trusted ( )  ?  UserNavigationInvolvement : : Activation  :  UserNavigationInvolvement : : None ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-26 16:59:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  Navigable : : is_focused ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  & m_page - > focused_navigable ( )  = =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								static  String  visible_text_in_range ( DOM : : Range  const &  range )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: This is an adaption of Range stringification, but we skip over DOM nodes that don't have a corresponding layout node.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    StringBuilder  builder ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( range . start_container ( )  = =  range . end_container ( )  & &  is < DOM : : Text > ( * range . start_container ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! range . start_container ( ) - > layout_node ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  String  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-24 12:05:52 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  static_cast < DOM : : Text  const & > ( * range . start_container ( ) ) . data ( ) . substring_view ( range . start_offset ( ) ,  range . end_offset ( )  -  range . start_offset ( ) ) . to_utf8_but_should_be_ported_to_utf16 ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-26 16:59:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is < DOM : : Text > ( * range . start_container ( ) )  & &  range . start_container ( ) - > layout_node ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-24 12:05:52 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        builder . append ( static_cast < DOM : : Text  const & > ( * range . start_container ( ) ) . data ( ) . substring_view ( range . start_offset ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-26 16:59:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-09 10:20:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    range . for_each_contained ( [ & ] ( GC : : Ref < DOM : : Node >  node )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( is < DOM : : Text > ( * node )  & &  node - > layout_node ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-26 16:59:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            builder . append ( static_cast < DOM : : Text  const & > ( * node ) . data ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-09 10:20:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  IterationDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-26 16:59:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is < DOM : : Text > ( * range . end_container ( ) )  & &  range . end_container ( ) - > layout_node ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-24 12:05:52 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        builder . append ( static_cast < DOM : : Text  const & > ( * range . end_container ( ) ) . data ( ) . substring_view ( 0 ,  range . end_offset ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-26 16:59:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  MUST ( builder . to_string ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								String  Navigable : : selected_text ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  document  =  const_cast < Navigable * > ( this ) - > active_document ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! document ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  String  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  selection  =  const_cast < DOM : : Document & > ( * document ) . get_selection ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  range  =  selection - > range ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! range ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  String  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  visible_text_in_range ( * range ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : select_all ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  document  =  active_document ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! document ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-04 11:29:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-26 16:59:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  selection  =  document - > get_selection ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! selection ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-04 11:29:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												LibWeb: Separate text control input events handling from contenteditable
This input event handling change is intended to address the following
design issues:
- Having `DOM::Position` is unnecessary complexity when `Selection`
  exists because caret position could be described by the selection
  object with a collapsed state. Before this change, we had to
  synchronize those whenever one of them was modified, and there were
  already bugs caused by that, i.e., caret position was not changed when
  selection offset was modified from the JS side.
- Selection API exposes selection offset within `<textarea>` and
  `<input>`, which is not supposed to happen. These objects should
  manage their selection state by themselves and have selection offset
  even when they are not displayed.
- `EventHandler` looks only at `DOM::Text` owned by `DOM::Position`
  while doing text manipulations. It works fine for `<input>` and
  `<textarea>`, but `contenteditable` needs to consider all text
  descendant text nodes; i.e., if the cursor is moved outside of
  `DOM::Text`, we need to look for an adjacent text node to move the
  cursor there.
With this change, `EventHandler` no longer does direct manipulations on
caret position or text content, but instead delegates them to the active
`InputEventsTarget`, which could be either
`FormAssociatedTextControlElement` (for `<input>` and `<textarea>`) or
`EditingHostManager` (for `contenteditable`). The `Selection` object is
used to manage both selection and caret position for `contenteditable`,
and text control elements manage their own selection state that is not
exposed by Selection API.
This change improves text editing on Discord, as now we don't have to
refocus the `contenteditable` element after character input. The problem
was that selection manipulations from the JS side were not propagated
to `DOM::Position`.
I expect this change to make future correctness improvements for
`contenteditable` (and `designMode`) easier, as now it's decoupled from
`<input>` and `<textarea>` and separated from `EventHandler`, which is
quite a busy file.
											 
										 
										
											2024-10-23 21:26:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  target  =  document - > active_input_events_target ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        target - > select_all ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-04 11:29:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  if  ( auto *  body  =  document - > body ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        ( void ) selection - > select_all_children ( * body ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-26 16:59:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : paste ( String  const &  text )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  document  =  active_document ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! document ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_event_handler . handle_paste ( text ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 10:26:01 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : register_navigation_observer ( Badge < NavigationObserver > ,  NavigationObserver &  navigation_observer )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  result  =  m_navigation_observers . set ( navigation_observer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( result  = =  AK : : HashSetResult : : InsertedNewEntry ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : unregister_navigation_observer ( Badge < NavigationObserver > ,  NavigationObserver &  navigation_observer )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    bool  was_removed  =  m_navigation_observers . remove ( navigation_observer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( was_removed ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 10:56:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/document-lifecycle.html#nav-stop
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : stop_loading ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Let document be navigable's active document.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  document  =  active_document ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. If document's unload counter is 0, and navigable's ongoing navigation is a navigation ID, then set the ongoing navigation for navigable to null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( document - > unload_counter ( )  = =  0  & &  ongoing_navigation ( ) . has < String > ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        set_ongoing_navigation ( Empty  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Abort a document and its descendants given document.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    document - > abort_a_document_and_its_descendants ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 00:22:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : set_has_session_history_entry_and_ready_for_navigation ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_has_session_history_entry_and_ready_for_navigation  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( ! m_pending_navigations . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  navigation_params  =  m_pending_navigations . take_first ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        begin_navigation ( navigation_params ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-06-26 22:33:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  Navigable : : is_ready_to_paint ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  m_number_of_queued_rasterization_tasks  < =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : ready_to_paint ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_number_of_queued_rasterization_tasks - - ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( m_number_of_queued_rasterization_tasks  > =  0  & &  m_number_of_queued_rasterization_tasks  <  2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : paint_next_frame ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-06-27 04:39:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  [ backing_store_id ,  painting_surface ]  =  m_backing_store_manager - > acquire_store_for_next_frame ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! painting_surface ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-26 22:33:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( m_number_of_queued_rasterization_tasks  < =  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_number_of_queued_rasterization_tasks + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  viewport_rect  =  page ( ) . css_to_device_rect ( this - > viewport_rect ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    PaintConfig  paint_config  {  . paint_overlay  =  true ,  . should_show_line_box_borders  =  m_should_show_line_box_borders ,  . canvas_fill_rect  =  Gfx : : IntRect  {  { } ,  viewport_rect . size ( ) . to_type < int > ( )  }  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-27 04:39:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    start_display_list_rendering ( * painting_surface ,  paint_config ,  [ this ,  viewport_rect ,  backing_store_id ]  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-26 22:33:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! is_top_level_traversable ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  traversable  =  * page ( ) . top_level_traversable ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        traversable . page ( ) . client ( ) . page_did_paint ( viewport_rect . to_type < int > ( ) ,  backing_store_id ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-06-27 04:39:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  Navigable : : start_display_list_rendering ( Gfx : : PaintingSurface &  painting_surface ,  PaintConfig  paint_config ,  Function < void ( ) > & &  callback )  
						 
					
						
							
								
									
										
										
										
											2025-06-26 22:33:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_needs_repaint  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  document  =  active_document ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! document )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        callback ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  display_list  =  document - > record_display_list ( paint_config ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! display_list )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        callback ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-25 01:39:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  document_paintable  =  * document - > paintable ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Painting : : ScrollStateSnapshotByDisplayList  scroll_state_snapshot_by_display_list ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    document_paintable . refresh_scroll_state ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  scroll_state_snapshot  =  document_paintable . scroll_state ( ) . snapshot ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    scroll_state_snapshot_by_display_list . set ( * display_list ,  move ( scroll_state_snapshot ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Collect scroll state snapshots for each nested navigable
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    document_paintable . for_each_in_inclusive_subtree_of_type < Painting : : NavigableContainerViewportPaintable > ( [ & scroll_state_snapshot_by_display_list ] ( auto &  navigable_container_paintable )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const *  hosted_document  =  navigable_container_paintable . layout_box ( ) . dom_node ( ) . content_document_without_origin_check ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! hosted_document  | |  ! hosted_document - > paintable ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  TraversalDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // We are only interested in collecting scroll state snapshots for visible nested navigables, which is
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // detectable by checking if they have a cached display list that should've been populated by
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // record_display_list() on top-level document.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  navigable_display_list  =  hosted_document - > cached_display_list ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! navigable_display_list ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  TraversalDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        const_cast < DOM : : Document & > ( * hosted_document ) . paintable ( ) - > refresh_scroll_state ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  navigable_scroll_state_snapshot  =  hosted_document - > paintable ( ) - > scroll_state ( ) . snapshot ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        scroll_state_snapshot_by_display_list . set ( * navigable_display_list ,  move ( navigable_scroll_state_snapshot ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  TraversalDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_rendering_thread . enqueue_rendering_task ( * display_list ,  move ( scroll_state_snapshot_by_display_list ) ,  painting_surface ,  move ( callback ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-26 22:33:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-10 19:24:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < Gfx : : SkiaBackendContext >  Navigable : : skia_backend_context ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  m_skia_backend_context ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-12 11:46:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}