LibWeb: Implement Blob::bytes()

Implements https://w3c.github.io/FileAPI/#dom-blob-bytes.
This commit is contained in:
Kemal Zebari 2024-07-23 23:48:01 -07:00 committed by Andreas Kling
commit c5f1e47883
Notes: github-actions[bot] 2024-07-26 08:22:29 +00:00
12 changed files with 52 additions and 10 deletions

View file

@ -277,7 +277,7 @@ ErrorOr<SerializedFormData> serialize_to_multipart_form_data(Vector<XHR::FormDat
TRY(builder.try_append(TRY(String::formatted("Content-Disposition: form-data; name=\"{}\"; filename=\"{}\"\r\n", escaped_name, escaped_filename))));
// The parts of the generated multipart/form-data resource that correspond to file fields must have a `Content-Type` header specified.
TRY(builder.try_append(TRY(String::formatted("Content-Type: {}\r\n\r\n", file->type()))));
TRY(builder.try_append(file->bytes()));
TRY(builder.try_append(file->raw_bytes()));
TRY(builder.try_append("\r\n"sv));
return {};
},

View file

@ -210,7 +210,7 @@ JS::NonnullGCPtr<JS::Promise> WindowOrWorkerGlobalScopeMixin::create_image_bitma
// 1. Let imageData be the result of reading image's data. If an error occurs during reading of the
// object, then reject p with an "InvalidStateError" DOMException and abort these steps.
// FIXME: I guess this is always fine for us as the data is already read.
auto const image_data = blob->bytes();
auto const image_data = blob->raw_bytes();
// FIXME:
// 2. Apply the image sniffing rules to determine the file format of imageData, with MIME type of