mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:32:46 +00:00 
			
		
		
		
	 be9d478d92
			
		
	
	
		be9d478d92
		
	
	
	
	
		
			
			Also make HostResolveImportedModule fail on the browser to prevent module loading for now.
		
			
				
	
	
		
			27 lines
		
	
	
	
		
			795 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
	
		
			795 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibJS/Module.h>
 | |
| #include <LibJS/Runtime/VM.h>
 | |
| #include <LibWeb/Bindings/MainThreadVM.h>
 | |
| 
 | |
| namespace Web::Bindings {
 | |
| 
 | |
| JS::VM& main_thread_vm()
 | |
| {
 | |
|     static RefPtr<JS::VM> vm;
 | |
|     if (!vm) {
 | |
|         vm = JS::VM::create(make<WebEngineCustomData>());
 | |
|         static_cast<WebEngineCustomData*>(vm->custom_data())->event_loop.set_vm(*vm);
 | |
| 
 | |
|         vm->host_resolve_imported_module = [&](JS::ScriptOrModule, JS::ModuleRequest const&) -> JS::ThrowCompletionOr<NonnullRefPtr<JS::Module>> {
 | |
|             return vm->throw_completion<JS::InternalError>(vm->current_realm()->global_object(), JS::ErrorType::NotImplemented, "Modules in the browser");
 | |
|         };
 | |
|     }
 | |
|     return *vm;
 | |
| }
 | |
| 
 | |
| }
 |