mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:47:34 +00:00
LibWeb: Properly convert UnderlyingSource's autoAllocateChunkSize to u64
The JS::Value being passed through is not a bigint, and needs to be converted using ConvertToInt, as per: https://webidl.spec.whatwg.org/#es-unsigned-long-long Furthermore, the IDL definition also specifies that this is associated with the [EnforceRange] extended attribute. This makes it actually possible to pass through an autoAllocateChunkSize to the ReadableStream constructor without it throwing a TypeError.
This commit is contained in:
parent
99bf986889
commit
6b88fc2e05
3 changed files with 18 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
|
||||
* Copyright (c) 2023, Shannon Booth <shannon@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -7,7 +8,9 @@
|
|||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibWeb/Streams/AbstractOperations.h>
|
||||
#include <LibWeb/Streams/UnderlyingSource.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
#include <LibWeb/WebIDL/CallbackType.h>
|
||||
#include <LibWeb/WebIDL/Types.h>
|
||||
|
||||
namespace Web::Streams {
|
||||
|
||||
|
@ -35,8 +38,10 @@ JS::ThrowCompletionOr<UnderlyingSource> UnderlyingSource::from_value(JS::VM& vm,
|
|||
return vm.throw_completion<JS::TypeError>(ByteString::formatted("Unknown stream type '{}'", type_value));
|
||||
}
|
||||
|
||||
if (TRY(object.has_property("autoAllocateChunkSize")))
|
||||
underlying_source.auto_allocate_chunk_size = TRY(TRY(object.get("autoAllocateChunkSize")).to_bigint_uint64(vm));
|
||||
if (TRY(object.has_property("autoAllocateChunkSize"))) {
|
||||
auto value = TRY(object.get("autoAllocateChunkSize"));
|
||||
underlying_source.auto_allocate_chunk_size = TRY(WebIDL::convert_to_int<WebIDL::UnsignedLongLong>(vm, value, WebIDL::EnforceRange::Yes));
|
||||
}
|
||||
|
||||
return underlying_source;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue