mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:12:44 +00:00 
			
		
		
		
	Browser+LibWeb: Add support for spoofing the browser user agent
This is helpful when testing certain sites like twitter.com which display differently based on the user agent.
This commit is contained in:
		
							parent
							
								
									aab99d5945
								
							
						
					
					
						commit
						bc9cd55da4
					
				
					 5 changed files with 59 additions and 1 deletions
				
			
		|  | @ -48,7 +48,7 @@ ResourceLoader& ResourceLoader::the() | |||
| 
 | ||||
| ResourceLoader::ResourceLoader() | ||||
|     : m_protocol_client(Protocol::Client::construct()) | ||||
|     , m_user_agent("Mozilla/4.0 (SerenityOS; x86) LibWeb+LibJS (Not KHTML, nor Gecko) LibWeb") | ||||
|     , m_user_agent(default_user_agent) | ||||
| { | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -37,6 +37,8 @@ class Client; | |||
| 
 | ||||
| namespace Web { | ||||
| 
 | ||||
| constexpr auto default_user_agent = "Mozilla/4.0 (SerenityOS; x86) LibWeb+LibJS (Not KHTML, nor Gecko) LibWeb"; | ||||
| 
 | ||||
| class ResourceLoader : public Core::Object { | ||||
|     C_OBJECT(ResourceLoader) | ||||
| public: | ||||
|  | @ -55,6 +57,7 @@ public: | |||
|     Protocol::Client& protocol_client() { return *m_protocol_client; } | ||||
| 
 | ||||
|     const String& user_agent() const { return m_user_agent; } | ||||
|     void set_user_agent(const String& user_agent) { m_user_agent = user_agent; } | ||||
| 
 | ||||
|     void clear_cache(); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Idan Horowitz
						Idan Horowitz