LibWeb: Widen assertion to avoid accidentally writing to a closed stream

This widens the assertion from only checking if the WritableStream's
state is Errored or Erroring to asserting that the WritableStream is not
in a Writable state.
This commit is contained in:
Kenneth Myhra 2025-04-14 19:21:12 +02:00 committed by Tim Flynn
commit b285202951
Notes: github-actions[bot] 2025-04-14 18:51:59 +00:00
4 changed files with 530 additions and 2 deletions

View file

@ -4974,8 +4974,8 @@ JS::Value writable_stream_default_controller_get_chunk_size(WritableStreamDefaul
{
// 1. If controller.[[strategySizeAlgorithm]] is undefined, then:
if (!controller.strategy_size_algorithm()) {
// 1. Assert: controller.[[stream]].[[state]] is "erroring" or "errored".
VERIFY(controller.stream()->state() == WritableStream::State::Erroring || controller.stream()->state() == WritableStream::State::Errored);
// 1. Assert: controller.[[stream]].[[state]] is not "writable".
VERIFY(controller.stream()->state() != WritableStream::State::Writable);
// 2. Return 1.
return JS::Value { 1.0 };