mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:48:10 +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)
|
||||
{
|
||||
auto& buffer = array_buffer.buffer();
|
||||
auto byte_length = array_buffer.byte_length();
|
||||
TRY(print_type(print_context, "ArrayBuffer"sv));
|
||||
|
||||
auto byte_length = array_buffer.byte_length();
|
||||
TRY(js_out(print_context, "\n byteLength: "));
|
||||
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)
|
||||
return {};
|
||||
|
||||
auto& buffer = array_buffer.buffer();
|
||||
TRY(js_out(print_context, "\n"));
|
||||
for (size_t i = 0; i < byte_length; ++i) {
|
||||
TRY(js_out(print_context, "{:02x}", buffer[i]));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue