From bdfc14f24d199b0e0783da0400e93ff391b97989 Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Sat, 22 Apr 2023 01:57:12 -0700 Subject: [PATCH] LibWeb: Accept explicit "type: undefined" in UnderlyingSource --- Userland/Libraries/LibWeb/Streams/UnderlyingSource.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibWeb/Streams/UnderlyingSource.cpp b/Userland/Libraries/LibWeb/Streams/UnderlyingSource.cpp index 27caa53435..45e68750ea 100644 --- a/Userland/Libraries/LibWeb/Streams/UnderlyingSource.cpp +++ b/Userland/Libraries/LibWeb/Streams/UnderlyingSource.cpp @@ -26,13 +26,13 @@ JS::ThrowCompletionOr UnderlyingSource::from_value(JS::VM& vm, .auto_allocate_chunk_size = {}, }; - if (TRY(object.has_property("type"))) { - auto type_value = TRY(TRY(object.get("type")).to_string(vm)); - if (type_value == "bytes"sv) { + auto type_value = TRY(object.get("type")); + if (!type_value.is_undefined()) { + auto type_string = TRY(type_value.to_string(vm)); + if (type_string == "bytes"sv) underlying_source.type = ReadableStreamType::Bytes; - } else { + else return vm.throw_completion(DeprecatedString::formatted("Unknown stream type '{}'", type_value)); - } } if (TRY(object.has_property("autoAllocateChunkSize")))