1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:07:44 +00:00

LibWeb: Implement Streams AO CanTransferArrayBuffer

This commit is contained in:
Shannon Booth 2023-12-02 20:28:17 +13:00 committed by Andreas Kling
parent 9d0700e770
commit 0245be70d8
2 changed files with 19 additions and 0 deletions

View file

@ -3736,6 +3736,24 @@ bool is_non_negative_number(JS::Value value)
return true;
}
// https://streams.spec.whatwg.org/#can-transfer-array-buffer
bool can_transfer_array_buffer(JS::ArrayBuffer const& array_buffer)
{
// 1. Assert: Type(O) is Object.
// 2. Assert: O has an [[ArrayBufferData]] internal slot.
// 3. If ! IsDetachedBuffer(O) is true, return false.
if (array_buffer.is_detached())
return false;
// 4. If SameValue(O.[[ArrayBufferDetachKey]], undefined) is false, return false.
if (!JS::same_value(array_buffer.detach_key(), JS::js_undefined()))
return false;
// 5. Return true.
return true;
}
// https://streams.spec.whatwg.org/#close-sentinel
// Non-standard function that implements the "close sentinel" value.
JS::Value create_close_sentinel()