2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								/*
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Copyright  ( c )  2020 ,  Andreas  Kling  < kling @ serenityos . org > 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:15:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								 *  Copyright  ( c )  2022 ,  Linus  Groh  < linusg @ serenityos . org > 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-22 01:24:48 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								 *  SPDX - License - Identifier :  BSD - 2 - Clause 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <AK/FlyString.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:59:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <AK/StringBuilder.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-03-06 00:24:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibJS/Heap/MarkedVector.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-09-28 23:54:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibJS/Runtime/Completion.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-03-06 00:24:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibJS/Runtime/PropertyDescriptor.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <LibJS/Runtime/PropertyKey.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <LibWeb/Bindings/CrossOriginAbstractOperations.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <LibWeb/Bindings/DOMExceptionWrapper.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  <LibWeb/Bindings/LocationObject.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-04-05 17:54:04 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/Bindings/LocationPrototype.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  <LibWeb/Bindings/WindowObject.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-03-06 00:24:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/DOM/DOMException.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  <LibWeb/DOM/Document.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-03-07 23:08:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/HTML/Window.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 14:54:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								namespace  Web : : Bindings  {  
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/history.html#the-location-interface
  
						 
					
						
							
								
									
										
										
										
											2022-08-16 00:20:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								LocationObject : : LocationObject ( JS : : Realm &  realm )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    :  Object ( static_cast < WindowObject & > ( realm . global_object ( ) ) . ensure_web_prototype < LocationPrototype > ( " Location " ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-06 00:24:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ,  m_default_properties ( heap ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-20 17:28:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-22 17:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  LocationObject : : initialize ( JS : : GlobalObject &  global_object )  
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2021-10-04 20:39:17 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto &  vm  =  global_object . vm ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-22 17:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    Object : : initialize ( global_object ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-19 21:47:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    u8  attr  =  JS : : Attribute : : Writable  |  JS : : Attribute : : Enumerable ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 08:21:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    define_native_accessor ( " href " ,  href_getter ,  href_setter ,  attr ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    define_native_accessor ( " host " ,  host_getter ,  { } ,  attr ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    define_native_accessor ( " hostname " ,  hostname_getter ,  { } ,  attr ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    define_native_accessor ( " pathname " ,  pathname_getter ,  { } ,  attr ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    define_native_accessor ( " hash " ,  hash_getter ,  { } ,  attr ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    define_native_accessor ( " search " ,  search_getter ,  { } ,  attr ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    define_native_accessor ( " protocol " ,  protocol_getter ,  { } ,  attr ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    define_native_accessor ( " port " ,  port_getter ,  { } ,  attr ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-18 22:05:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 08:21:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    define_native_function ( " reload " ,  reload ,  0 ,  JS : : Attribute : : Enumerable ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    define_native_function ( " replace " ,  replace ,  1 ,  JS : : Attribute : : Enumerable ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-04 20:39:17 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 08:21:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    define_native_function ( vm . names . toString ,  href_getter ,  0 ,  JS : : Attribute : : Enumerable ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-06 00:24:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 5. Set the value of the [[DefaultProperties]] internal slot of location to location.[[OwnPropertyKeys]]().
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // NOTE: In LibWeb this happens before the ESO is set up, so we must avoid location's custom [[OwnPropertyKeys]].
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    m_default_properties . extend ( MUST ( Object : : internal_own_property_keys ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:15:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/history.html#relevant-document
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								DOM : : Document  const *  LocationObject : : relevant_document ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // A Location object has an associated relevant Document, which is this Location object's
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // relevant global object's browsing context's active document, if this Location object's
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // relevant global object's browsing context is non-null, and null otherwise.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto *  browsing_context  =  static_cast < WindowObject & > ( global_object ( ) ) . impl ( ) . browsing_context ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  browsing_context  ?  browsing_context - > active_document ( )  :  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:17:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/history.html#concept-location-url
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								AK : : URL  LocationObject : : url ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // A Location object has an associated url, which is this Location object's relevant Document's URL,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // if this Location object's relevant Document is non-null, and about:blank otherwise.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  const *  relevant_document  =  this - > relevant_document ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  relevant_document  ?  relevant_document - > url ( )  :  " about:blank " sv ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  JS : : ThrowCompletionOr < LocationObject * >  typed_this_value ( JS : : GlobalObject &  global_object )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto &  vm  =  global_object . vm ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  this_value  =  vm . this_value ( global_object ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ! this_value . is_object ( )  | |  ! is < LocationObject > ( this_value . as_object ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  vm . throw_completion < JS : : TypeError > ( global_object ,  JS : : ErrorType : : NotAnObjectOfType ,  " Location " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  static_cast < LocationObject * > ( & this_value . as_object ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/history.html#dom-location-href
  
						 
					
						
							
								
									
										
										
										
											2021-10-31 08:21:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS_DEFINE_NATIVE_FUNCTION ( LocationObject : : href_getter )  
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto *  location_object  =  TRY ( typed_this_value ( global_object ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. Return this's url, serialized.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  JS : : js_string ( vm ,  location_object - > url ( ) . to_string ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/history.html#the-location-interface:dom-location-href-2
  
						 
					
						
							
								
									
										
										
										
											2021-10-31 08:21:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS_DEFINE_NATIVE_FUNCTION ( LocationObject : : href_setter )  
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-06-20 13:55:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto &  window  =  static_cast < WindowObject & > ( global_object ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 1. If this's relevant Document is null, then return.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. Parse the given value relative to the entry settings object. If that failed, throw a TypeError exception.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 08:21:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  new_href  =  TRY ( vm . argument ( 0 ) . to_string ( global_object ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-09 18:08:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  href_url  =  window . impl ( ) . associated_document ( ) . parse_url ( new_href ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 08:21:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( ! href_url . is_valid ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  vm . throw_completion < JS : : URIError > ( global_object ,  String : : formatted ( " Invalid URL '{}' " ,  new_href ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 3. Location-object navigate given the resulting URL record.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-02 12:09:24 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    window . impl ( ) . did_set_location_href ( { } ,  href_url ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-05 15:01:57 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  JS : : js_undefined ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/history.html#dom-location-pathname
  
						 
					
						
							
								
									
										
										
										
											2021-10-31 08:21:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS_DEFINE_NATIVE_FUNCTION ( LocationObject : : pathname_getter )  
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto *  location_object  =  TRY ( typed_this_value ( global_object ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. Return the result of URL path serializing this Location object's url.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  JS : : js_string ( vm ,  location_object - > url ( ) . path ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/history.html#dom-location-hostname
  
						 
					
						
							
								
									
										
										
										
											2021-10-31 08:21:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS_DEFINE_NATIVE_FUNCTION ( LocationObject : : hostname_getter )  
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto *  location_object  =  TRY ( typed_this_value ( global_object ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. If this's url's host is null, return the empty string.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( location_object - > url ( ) . host ( ) . is_null ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  JS : : js_string ( vm ,  String : : empty ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 3. Return this's url's host, serialized.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  JS : : js_string ( vm ,  location_object - > url ( ) . host ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/history.html#dom-location-host
  
						 
					
						
							
								
									
										
										
										
											2021-10-31 08:21:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS_DEFINE_NATIVE_FUNCTION ( LocationObject : : host_getter )  
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:59:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto *  location_object  =  TRY ( typed_this_value ( global_object ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. Let url be this's url.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  url  =  location_object - > url ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 3. If url's host is null, return the empty string.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( url . host ( ) . is_null ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  JS : : js_string ( vm ,  String : : empty ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 4. If url's port is null, return url's host, serialized.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ! url . port ( ) . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  JS : : js_string ( vm ,  url . host ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 5. Return url's host, serialized, followed by ":" and url's port, serialized.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  JS : : js_string ( vm ,  String : : formatted ( " {}:{} " ,  url . host ( ) ,  * url . port ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:59:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/history.html#dom-location-hash
  
						 
					
						
							
								
									
										
										
										
											2021-10-31 08:21:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS_DEFINE_NATIVE_FUNCTION ( LocationObject : : hash_getter )  
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto *  location_object  =  TRY ( typed_this_value ( global_object ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. If this's url's fragment is either null or the empty string, return the empty string.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( location_object - > url ( ) . fragment ( ) . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  JS : : js_string ( vm ,  String : : empty ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 3. Return "#", followed by this's url's fragment.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  JS : : js_string ( vm ,  String : : formatted ( " #{} " ,  location_object - > url ( ) . fragment ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/history.html#dom-location-search
  
						 
					
						
							
								
									
										
										
										
											2021-10-31 08:21:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS_DEFINE_NATIVE_FUNCTION ( LocationObject : : search_getter )  
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto *  location_object  =  TRY ( typed_this_value ( global_object ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. If this's url's query is either null or the empty string, return the empty string.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( location_object - > url ( ) . query ( ) . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  JS : : js_string ( vm ,  String : : empty ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 3. Return "?", followed by this's url's query.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  JS : : js_string ( vm ,  String : : formatted ( " ?{} " ,  location_object - > url ( ) . query ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/history.html#dom-location-protocol
  
						 
					
						
							
								
									
										
										
										
											2021-10-31 08:21:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS_DEFINE_NATIVE_FUNCTION ( LocationObject : : protocol_getter )  
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:59:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto *  location_object  =  TRY ( typed_this_value ( global_object ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. Return this's url's scheme, followed by ":".
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  JS : : js_string ( vm ,  String : : formatted ( " {}: " ,  location_object - > url ( ) . protocol ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:59:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/history.html#dom-location-port
  
						 
					
						
							
								
									
										
										
										
											2021-10-31 08:21:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS_DEFINE_NATIVE_FUNCTION ( LocationObject : : port_getter )  
						 
					
						
							
								
									
										
										
										
											2021-09-18 21:44:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto *  location_object  =  TRY ( typed_this_value ( global_object ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 2. If this's url's port is null, return the empty string.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ! location_object - > url ( ) . port ( ) . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  JS : : js_string ( vm ,  String : : empty ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 3. Return this's url's port, serialized.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-05 00:22:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  JS : : js_string ( vm ,  String : : number ( * location_object - > url ( ) . port ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-18 21:44:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/history.html#dom-location-reload
  
						 
					
						
							
								
									
										
										
										
											2021-10-31 08:21:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS_DEFINE_NATIVE_FUNCTION ( LocationObject : : reload )  
						 
					
						
							
								
									
										
										
										
											2020-05-18 22:05:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-06-20 13:55:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto &  window  =  static_cast < WindowObject & > ( global_object ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-18 22:05:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    window . impl ( ) . did_call_location_reload ( { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  JS : : js_undefined ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 23:35:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/history.html#dom-location-replace
  
						 
					
						
							
								
									
										
										
										
											2021-10-31 08:21:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS_DEFINE_NATIVE_FUNCTION ( LocationObject : : replace )  
						 
					
						
							
								
									
										
										
										
											2021-10-03 23:31:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto &  window  =  static_cast < WindowObject & > ( global_object ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 08:21:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  url  =  TRY ( vm . argument ( 0 ) . to_string ( global_object ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-03 23:31:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // FIXME: This needs spec compliance work.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    window . impl ( ) . did_call_location_replace ( { } ,  move ( url ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  JS : : js_undefined ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-06 00:24:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// 7.10.5.1 [[GetPrototypeOf]] ( ), https://html.spec.whatwg.org/multipage/history.html#location-getprototypeof
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								JS : : ThrowCompletionOr < JS : : Object * >  LocationObject : : internal_get_prototype_of ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 1. If IsPlatformObjectSameOrigin(this) is true, then return ! OrdinaryGetPrototypeOf(this).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( is_platform_object_same_origin ( * this ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  MUST ( JS : : Object : : internal_get_prototype_of ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. Return null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 7.10.5.2 [[SetPrototypeOf]] ( V ), https://html.spec.whatwg.org/multipage/history.html#location-setprototypeof
  
						 
					
						
							
								
									
										
										
										
											2021-09-28 23:54:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS : : ThrowCompletionOr < bool >  LocationObject : : internal_set_prototype_of ( Object *  prototype )  
						 
					
						
							
								
									
										
										
										
											2021-09-12 14:54:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 1. Return ! SetImmutablePrototype(this, V).
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-03 19:52:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  MUST ( set_immutable_prototype ( prototype ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 14:54:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-06 00:24:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// 7.10.5.3 [[IsExtensible]] ( ), https://html.spec.whatwg.org/multipage/history.html#location-isextensible
  
						 
					
						
							
								
									
										
										
										
											2021-09-29 00:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS : : ThrowCompletionOr < bool >  LocationObject : : internal_is_extensible ( )  const  
						 
					
						
							
								
									
										
										
										
											2021-09-12 14:54:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 1. Return true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-06 00:24:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// 7.10.5.4 [[PreventExtensions]] ( ), https://html.spec.whatwg.org/multipage/history.html#location-preventextensions
  
						 
					
						
							
								
									
										
										
										
											2021-09-29 00:13:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS : : ThrowCompletionOr < bool >  LocationObject : : internal_prevent_extensions ( )  
						 
					
						
							
								
									
										
										
										
											2021-09-12 14:54:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 1. Return false.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-06 00:24:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// 7.10.5.5 [[GetOwnProperty]] ( P ), https://html.spec.whatwg.org/multipage/history.html#location-getownproperty
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								JS : : ThrowCompletionOr < Optional < JS : : PropertyDescriptor > >  LocationObject : : internal_get_own_property ( JS : : PropertyKey  const &  property_key )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto &  global_object  =  HTML : : current_global_object ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto &  vm  =  global_object . vm ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 1. If IsPlatformObjectSameOrigin(this) is true, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( is_platform_object_same_origin ( * this ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 1. Let desc be OrdinaryGetOwnProperty(this, P).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  descriptor  =  MUST ( Object : : internal_get_own_property ( property_key ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 2. If the value of the [[DefaultProperties]] internal slot of this contains P, then set desc.[[Configurable]] to true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  property_key_value  =  property_key . is_symbol ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ?  JS : : Value  {  property_key . as_symbol ( )  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            :  JS : : js_string ( vm ,  property_key . to_string ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( m_default_properties . contains_slow ( property_key_value ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            descriptor - > configurable  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 3. Return desc.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  descriptor ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. Let property be CrossOriginGetOwnPropertyHelper(this, P).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  property  =  cross_origin_get_own_property_helper ( const_cast < LocationObject * > ( this ) ,  property_key ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 3. If property is not undefined, then return property.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( property . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  property ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 4. Return ? CrossOriginPropertyFallback(P).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  TRY ( cross_origin_property_fallback ( global_object ,  property_key ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 7.10.5.6 [[DefineOwnProperty]] ( P, Desc ), https://html.spec.whatwg.org/multipage/history.html#location-defineownproperty
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								JS : : ThrowCompletionOr < bool >  LocationObject : : internal_define_own_property ( JS : : PropertyKey  const &  property_key ,  JS : : PropertyDescriptor  const &  descriptor )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto &  global_object  =  HTML : : current_global_object ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto &  vm  =  global_object . vm ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 1. If IsPlatformObjectSameOrigin(this) is true, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( is_platform_object_same_origin ( * this ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 1. If the value of the [[DefaultProperties]] internal slot of this contains P, then return false.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 2. Return ? OrdinaryDefineOwnProperty(this, P, Desc).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  JS : : Object : : internal_define_own_property ( property_key ,  descriptor ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. Throw a "SecurityError" DOMException.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  vm . throw_completion < DOMExceptionWrapper > ( global_object ,  DOM : : SecurityError : : create ( String : : formatted ( " Can't define property '{}' on cross-origin object " ,  property_key ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 7.10.5.7 [[Get]] ( P, Receiver ), https://html.spec.whatwg.org/multipage/history.html#location-get
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								JS : : ThrowCompletionOr < JS : : Value >  LocationObject : : internal_get ( JS : : PropertyKey  const &  property_key ,  JS : : Value  receiver )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto &  global_object  =  HTML : : current_global_object ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 1. If IsPlatformObjectSameOrigin(this) is true, then return ? OrdinaryGet(this, P, Receiver).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( is_platform_object_same_origin ( * this ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  JS : : Object : : internal_get ( property_key ,  receiver ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. Return ? CrossOriginGet(this, P, Receiver).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  cross_origin_get ( global_object ,  static_cast < JS : : Object  const & > ( * this ) ,  property_key ,  receiver ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 7.10.5.8 [[Set]] ( P, V, Receiver ), https://html.spec.whatwg.org/multipage/history.html#location-set
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								JS : : ThrowCompletionOr < bool >  LocationObject : : internal_set ( JS : : PropertyKey  const &  property_key ,  JS : : Value  value ,  JS : : Value  receiver )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto &  global_object  =  HTML : : current_global_object ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 1. If IsPlatformObjectSameOrigin(this) is true, then return ? OrdinarySet(this, P, V, Receiver).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( is_platform_object_same_origin ( * this ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  JS : : Object : : internal_set ( property_key ,  value ,  receiver ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. Return ? CrossOriginSet(this, P, V, Receiver).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  cross_origin_set ( global_object ,  static_cast < JS : : Object & > ( * this ) ,  property_key ,  value ,  receiver ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 7.10.5.9 [[Delete]] ( P ), https://html.spec.whatwg.org/multipage/history.html#location-delete
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								JS : : ThrowCompletionOr < bool >  LocationObject : : internal_delete ( JS : : PropertyKey  const &  property_key )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto &  global_object  =  HTML : : current_global_object ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto &  vm  =  global_object . vm ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 1. If IsPlatformObjectSameOrigin(this) is true, then return ? OrdinaryDelete(this, P).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( is_platform_object_same_origin ( * this ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  JS : : Object : : internal_delete ( property_key ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. Throw a "SecurityError" DOMException.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  vm . throw_completion < DOMExceptionWrapper > ( global_object ,  DOM : : SecurityError : : create ( String : : formatted ( " Can't delete property '{}' on cross-origin object " ,  property_key ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 7.10.5.10 [[OwnPropertyKeys]] ( ), https://html.spec.whatwg.org/multipage/history.html#location-ownpropertykeys
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								JS : : ThrowCompletionOr < JS : : MarkedVector < JS : : Value > >  LocationObject : : internal_own_property_keys ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 1. If IsPlatformObjectSameOrigin(this) is true, then return OrdinaryOwnPropertyKeys(this).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( is_platform_object_same_origin ( * this ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  JS : : Object : : internal_own_property_keys ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. Return CrossOriginOwnPropertyKeys(this).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  cross_origin_own_property_keys ( this ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-18 21:42:40 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}