mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 12:52:44 +00:00 
			
		
		
		
	LibJS+LibWeb: Clear exceptions after call'ing JavaScript functions
Decorated Interpreter::call() with [[nodiscard]] to provoke thinking about the returned value at each call site. This is definitely not perfect and we should really start thinking about slimming down the public-facing LibJS interpreter API. Fixes #3136.
This commit is contained in:
		
							parent
							
								
									c5127389ca
								
							
						
					
					
						commit
						bbe2d4a2d9
					
				
					 7 changed files with 24 additions and 9 deletions
				
			
		|  | @ -127,7 +127,10 @@ void Node::dispatch_event(NonnullRefPtr<Event> event) | |||
|             auto* event_wrapper = wrap(global_object, *event); | ||||
|             JS::MarkedValueList arguments(global_object.heap()); | ||||
|             arguments.append(event_wrapper); | ||||
|             document().interpreter().call(function, this_value, move(arguments)); | ||||
|             auto& interpreter = document().interpreter(); | ||||
|             (void)interpreter.call(function, this_value, move(arguments)); | ||||
|             if (interpreter.exception()) | ||||
|                 interpreter.clear_exception(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -94,7 +94,9 @@ void Window::timer_did_fire(Badge<Timer>, Timer& timer) | |||
|     } | ||||
| 
 | ||||
|     auto& interpreter = wrapper()->interpreter(); | ||||
|     interpreter.call(timer.callback(), wrapper()); | ||||
|     (void)interpreter.call(timer.callback(), wrapper()); | ||||
|     if (interpreter.exception()) | ||||
|         interpreter.clear_exception(); | ||||
| } | ||||
| 
 | ||||
| i32 Window::allocate_timer_id(Badge<Timer>) | ||||
|  | @ -123,7 +125,9 @@ i32 Window::request_animation_frame(JS::Function& callback) | |||
|         JS::MarkedValueList arguments(interpreter.heap()); | ||||
|         arguments.append(JS::Value(fake_timestamp)); | ||||
|         fake_timestamp += 10; | ||||
|         interpreter.call(function, {}, move(arguments)); | ||||
|         (void)interpreter.call(function, {}, move(arguments)); | ||||
|         if (interpreter.exception()) | ||||
|             interpreter.clear_exception(); | ||||
|         GUI::DisplayLink::unregister_callback(link_id); | ||||
|     }); | ||||
| 
 | ||||
|  |  | |||
|  | @ -98,7 +98,10 @@ void XMLHttpRequest::dispatch_event(NonnullRefPtr<DOM::Event> event) | |||
|             auto* this_value = wrap(global_object, *this); | ||||
|             JS::MarkedValueList arguments(global_object.heap()); | ||||
|             arguments.append(wrap(global_object, *event)); | ||||
|             function.interpreter().call(function, this_value, move(arguments)); | ||||
|             auto& interpreter = function.interpreter(); | ||||
|             (void)interpreter.call(function, this_value, move(arguments)); | ||||
|             if (interpreter.exception()) | ||||
|                 interpreter.clear_exception(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling