mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 13:32:45 +00:00 
			
		
		
		
	LibWeb: Add a simple internals objects only available during testing
				
					
				
			This object is available as `window.internals` (or just `internals`) and is only accessible while running in "test mode". This first version only has one API: gc(), which triggers a garbage collection immediately. In the future, we can add more APIs here to help us test parts of the engine that are hard or impossible to reach via public web APIs.
This commit is contained in:
		
							parent
							
								
									ba236e3f21
								
							
						
					
					
						commit
						ec24d7555a
					
				
					 14 changed files with 109 additions and 5 deletions
				
			
		
							
								
								
									
										33
									
								
								Userland/Libraries/LibWeb/Internals/Internals.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								Userland/Libraries/LibWeb/Internals/Internals.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,33 @@ | |||
| /*
 | ||||
|  * Copyright (c) 2023, Andreas Kling <kling@serenityos.org> | ||||
|  * | ||||
|  * SPDX-License-Identifier: BSD-2-Clause | ||||
|  */ | ||||
| 
 | ||||
| #include <LibJS/Runtime/VM.h> | ||||
| #include <LibWeb/Bindings/InternalsPrototype.h> | ||||
| #include <LibWeb/Bindings/Intrinsics.h> | ||||
| #include <LibWeb/Internals/Internals.h> | ||||
| 
 | ||||
| namespace Web::Internals { | ||||
| 
 | ||||
| Internals::Internals(JS::Realm& realm) | ||||
|     : Bindings::PlatformObject(realm) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| Internals::~Internals() = default; | ||||
| 
 | ||||
| JS::ThrowCompletionOr<void> Internals::initialize(JS::Realm& realm) | ||||
| { | ||||
|     TRY(Base::initialize(realm)); | ||||
|     Object::set_prototype(&Bindings::ensure_web_prototype<Bindings::InternalsPrototype>(realm, "Internals")); | ||||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| void Internals::gc() | ||||
| { | ||||
|     vm().heap().collect_garbage(); | ||||
| } | ||||
| 
 | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling