mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:47:46 +00:00
LibWeb: Port IDL implementations Blob and File to new String
This commit is contained in:
parent
31a9bd2bfd
commit
9a5a8d617d
10 changed files with 63 additions and 52 deletions
|
@ -108,7 +108,7 @@ WebIDL::ExceptionOr<JS::Value> package_data(JS::Realm& realm, ByteBuffer bytes,
|
|||
case PackageDataType::Blob: {
|
||||
// Return a Blob whose contents are bytes and type attribute is mimeType.
|
||||
// NOTE: If extracting the mime type returns failure, other browsers set it to an empty string - not sure if that's spec'd.
|
||||
auto mime_type_string = mime_type.has_value() ? mime_type->serialized() : DeprecatedString::empty();
|
||||
auto mime_type_string = mime_type.has_value() ? TRY_OR_THROW_OOM(vm, String::from_deprecated_string(mime_type->serialized())) : String {};
|
||||
return TRY(FileAPI::Blob::create(realm, move(bytes), move(mime_type_string)));
|
||||
}
|
||||
case PackageDataType::FormData:
|
||||
|
|
|
@ -75,7 +75,7 @@ WebIDL::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm,
|
|||
length = blob->size();
|
||||
// If object’s type attribute is not the empty byte sequence, set type to its value.
|
||||
if (!blob->type().is_empty())
|
||||
type = blob->type().to_byte_buffer();
|
||||
type = TRY_OR_THROW_OOM(vm, ByteBuffer::copy(blob->type().bytes()));
|
||||
return {};
|
||||
},
|
||||
[&](ReadonlyBytes bytes) -> WebIDL::ExceptionOr<void> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue