LibWeb/FileAPI: Make sure to always run the constructor steps for Blob

Previously we did not execute the constructor steps if we constructed a
Blob from a ByteBuffer and a String. Though we only construct a Blob
from ByteBuffer and String internally we still need to run these steps.

By creating the new type 'BlobPartsOrByteBuffer' we can consolidate
those two approaches to creating a Blob into our already existing
constructor steps.
This commit is contained in:
Kenneth Myhra 2025-09-03 18:13:57 +02:00 committed by Jelle Raaijmakers
commit a021134457
Notes: github-actions[bot] 2025-09-03 19:45:09 +00:00
4 changed files with 27 additions and 15 deletions

View file

@ -43,7 +43,7 @@ GC::Ref<File> File::create(JS::Realm& realm)
}
// https://w3c.github.io/FileAPI/#ref-for-dom-file-file
WebIDL::ExceptionOr<GC::Ref<File>> File::create(JS::Realm& realm, Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options)
WebIDL::ExceptionOr<GC::Ref<File>> File::create(JS::Realm& realm, BlobParts const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options)
{
auto& vm = realm.vm();
@ -83,7 +83,7 @@ WebIDL::ExceptionOr<GC::Ref<File>> File::create(JS::Realm& realm, Vector<BlobPar
return realm.create<File>(realm, move(bytes), move(name), move(type), last_modified);
}
WebIDL::ExceptionOr<GC::Ref<File>> File::construct_impl(JS::Realm& realm, Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options)
WebIDL::ExceptionOr<GC::Ref<File>> File::construct_impl(JS::Realm& realm, BlobParts const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options)
{
return create(realm, file_bits, file_name, options);
}