LibWeb/FileAPI: Handle an aborted stream in Blob::get_stream() close

The streams AO that we were calling to close the stream would assert
if it was not in a readable state. This version of close is exported
publicly in the streams specification, and properly handles this
situation.

Fixes a crash in the imported test, and happens to fix some others!
This commit is contained in:
Shannon Booth 2025-05-31 16:34:13 +12:00 committed by Tim Flynn
commit caf959f06c
Notes: github-actions[bot] 2025-05-31 13:14:02 +00:00
5 changed files with 132 additions and 9 deletions

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2022-2024, Kenneth Myhra <kennethmyhra@serenityos.org>
* Copyright (c) 2023, Shannon Booth <shannon@serenityos.org>
* Copyright (c) 2023-2025, Shannon Booth <shannon@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -357,7 +357,7 @@ GC::Ref<Streams::ReadableStream> Blob::get_stream()
// FIXME: Spec bug: https://github.com/w3c/FileAPI/issues/206
//
// We need to close the stream so that the stream will finish reading.
Streams::readable_stream_close(*stream);
stream->close();
}));
}
}