mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Script: implement ReadableStreamBYOBReader::Read
(#35040)
* Script: implement ReadableStreamBYOBReader::Read Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com> * fix ReadRequest::close_steps Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com> * fix clippy Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com> * implement viewed_buffer_array_byte_length and byte_length Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com> * fix clippy Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com> * Correct BufferSource implemntation Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com> * Correct detach_buffer implemantation Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com> * fix JS_IsArrayBufferViewObject usage Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com> * Reduce BufferSource to two variants ArrayBuffer and ArrayBufferView Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com> * Add more doc and use promise.reject_error Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com> --------- Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
This commit is contained in:
parent
177b5b2cef
commit
9943e97726
7 changed files with 406 additions and 224 deletions
|
@ -49,6 +49,8 @@ impl ReadRequest {
|
|||
pub(crate) fn chunk_steps(&self, chunk: RootedTraceableBox<Heap<JSVal>>) {
|
||||
match self {
|
||||
ReadRequest::Read(promise) => {
|
||||
// chunk steps, given chunk
|
||||
// Resolve promise with «[ "value" → chunk, "done" → false ]».
|
||||
promise.resolve_native(&ReadableStreamReadResult {
|
||||
done: Some(false),
|
||||
value: chunk,
|
||||
|
@ -64,6 +66,8 @@ impl ReadRequest {
|
|||
pub(crate) fn close_steps(&self) {
|
||||
match self {
|
||||
ReadRequest::Read(promise) => {
|
||||
// close steps
|
||||
// Resolve promise with «[ "value" → undefined, "done" → true ]».
|
||||
let result = RootedTraceableBox::new(Heap::default());
|
||||
result.set(UndefinedValue());
|
||||
promise.resolve_native(&ReadableStreamReadResult {
|
||||
|
@ -80,7 +84,11 @@ impl ReadRequest {
|
|||
/// <https://streams.spec.whatwg.org/#read-request-error-steps>
|
||||
pub(crate) fn error_steps(&self, e: SafeHandleValue) {
|
||||
match self {
|
||||
ReadRequest::Read(promise) => promise.reject_native(&e),
|
||||
ReadRequest::Read(promise) => {
|
||||
// error steps, given e
|
||||
// Reject promise with e.
|
||||
promise.reject_native(&e)
|
||||
},
|
||||
ReadRequest::DefaultTee { tee_read_request } => {
|
||||
tee_read_request.error_steps();
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue