Fix ReadableStream cancel error message (#37282)

Align error message with WHATWG Streams spec by changing:  
- `'stream is not locked'` to `'stream is locked'` 

This will match the step 2 of the readablestream cancel method that
requires the correct TypeError when the stream is locked.

Signed-off-by: Alice Okingo <annekadiso@gmail.com>
This commit is contained in:
Aokingo 2025-06-06 05:32:59 +03:00 committed by GitHub
parent a328aa474b
commit c7eba2dbba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1926,7 +1926,7 @@ impl ReadableStreamMethods<crate::DomTypeHolder> for ReadableStream {
// If ! IsReadableStreamLocked(this) is true, // If ! IsReadableStreamLocked(this) is true,
// return a promise rejected with a TypeError exception. // return a promise rejected with a TypeError exception.
let promise = Promise::new(&global, can_gc); let promise = Promise::new(&global, can_gc);
promise.reject_error(Error::Type("stream is not locked".to_owned()), can_gc); promise.reject_error(Error::Type("stream is locked".to_owned()), can_gc);
promise promise
} else { } else {
// Return ! ReadableStreamCancel(this, reason). // Return ! ReadableStreamCancel(this, reason).