mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:52:45 +00:00 
			
		
		
		
	LibJS: Show when an ArrayBuffer is detached when printing
This commit is contained in:
		
							parent
							
								
									286bf307d2
								
							
						
					
					
						commit
						34c5d34b95
					
				
					 1 changed files with 9 additions and 2 deletions
				
			
		|  | @ -384,13 +384,20 @@ ErrorOr<void> print_promise(JS::PrintContext& print_context, JS::Promise const& | ||||||
| 
 | 
 | ||||||
| ErrorOr<void> print_array_buffer(JS::PrintContext& print_context, JS::ArrayBuffer const& array_buffer, HashTable<JS::Object*>& seen_objects) | ErrorOr<void> print_array_buffer(JS::PrintContext& print_context, JS::ArrayBuffer const& array_buffer, HashTable<JS::Object*>& seen_objects) | ||||||
| { | { | ||||||
|     auto& buffer = array_buffer.buffer(); |  | ||||||
|     auto byte_length = array_buffer.byte_length(); |  | ||||||
|     TRY(print_type(print_context, "ArrayBuffer"sv)); |     TRY(print_type(print_context, "ArrayBuffer"sv)); | ||||||
|  | 
 | ||||||
|  |     auto byte_length = array_buffer.byte_length(); | ||||||
|     TRY(js_out(print_context, "\n  byteLength: ")); |     TRY(js_out(print_context, "\n  byteLength: ")); | ||||||
|     TRY(print_value(print_context, JS::Value((double)byte_length), seen_objects)); |     TRY(print_value(print_context, JS::Value((double)byte_length), seen_objects)); | ||||||
|  |     if (array_buffer.is_detached()) { | ||||||
|  |         TRY(js_out(print_context, "\n  Detached")); | ||||||
|  |         return {}; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     if (byte_length == 0) |     if (byte_length == 0) | ||||||
|         return {}; |         return {}; | ||||||
|  | 
 | ||||||
|  |     auto& buffer = array_buffer.buffer(); | ||||||
|     TRY(js_out(print_context, "\n")); |     TRY(js_out(print_context, "\n")); | ||||||
|     for (size_t i = 0; i < byte_length; ++i) { |     for (size_t i = 0; i < byte_length; ++i) { | ||||||
|         TRY(js_out(print_context, "{:02x}", buffer[i])); |         TRY(js_out(print_context, "{:02x}", buffer[i])); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 PrestonLTaylor
						PrestonLTaylor