mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
LibWeb: Implement ReadableStreamBYOBRequest.respond
The parameter in IDL is left as an unsigned long instead of an unsigned long long as the IDL generator does not currently support that.
This commit is contained in:
parent
08be5deb3f
commit
feb7fbb95d
3 changed files with 24 additions and 1 deletions
|
@ -39,4 +39,24 @@ void ReadableStreamBYOBRequest::visit_edges(Cell::Visitor& visitor)
|
||||||
visitor.visit(m_view);
|
visitor.visit(m_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebIDL::ExceptionOr<void> ReadableStreamBYOBRequest::respond(u64 bytes_written)
|
||||||
|
{
|
||||||
|
// 1. If this.[[controller]] is undefined, throw a TypeError exception.
|
||||||
|
if (!m_controller)
|
||||||
|
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Controller is undefined"_string };
|
||||||
|
|
||||||
|
// 2. If ! IsDetachedBuffer(this.[[view]].[[ArrayBuffer]]) is true, throw a TypeError exception.
|
||||||
|
if (m_view->viewed_array_buffer()->is_detached())
|
||||||
|
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Unable to respond to detached ArrayBuffer"_string };
|
||||||
|
|
||||||
|
// 3. Assert: this.[[view]].[[ByteLength]] > 0.
|
||||||
|
VERIFY(m_view->viewed_array_buffer()->byte_length() > 0);
|
||||||
|
|
||||||
|
// 4. Assert: this.[[view]].[[ViewedArrayBuffer]].[[ByteLength]] > 0.
|
||||||
|
VERIFY(m_view->viewed_array_buffer()->byte_length() > 0);
|
||||||
|
|
||||||
|
// 5. Perform ? ReadableByteStreamControllerRespond(this.[[controller]], bytesWritten).
|
||||||
|
return readable_byte_stream_controller_respond(*m_controller, bytes_written);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ public:
|
||||||
|
|
||||||
void set_view(JS::GCPtr<WebIDL::ArrayBufferView> value) { m_view = value; }
|
void set_view(JS::GCPtr<WebIDL::ArrayBufferView> value) { m_view = value; }
|
||||||
|
|
||||||
|
WebIDL::ExceptionOr<void> respond(u64 bytes_written);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit ReadableStreamBYOBRequest(JS::Realm&);
|
explicit ReadableStreamBYOBRequest(JS::Realm&);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
interface ReadableStreamBYOBRequest {
|
interface ReadableStreamBYOBRequest {
|
||||||
readonly attribute ArrayBufferView? view;
|
readonly attribute ArrayBufferView? view;
|
||||||
|
|
||||||
// FIXME: undefined respond([EnforceRange] unsigned long long bytesWritten);
|
// FIXME: Should be unsigned long long
|
||||||
|
undefined respond([EnforceRange] unsigned long bytesWritten);
|
||||||
// FIXME: undefined respondWithNewView(ArrayBufferView view);
|
// FIXME: undefined respondWithNewView(ArrayBufferView view);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue