pub(crate) fn get_buffer_source_copy(
source: ArrayBufferViewOrArrayBufferRef<'_>,
) -> Vec<u8> ⓘExpand description
https://webidl.spec.whatwg.org/#dfn-get-buffer-source-copy
Spec steps and how they’re covered:
-
Convert to JS value: Handled by WebIDL bindings before this function receives the typed
ArrayBufferViewOrArrayBufferunion. -
ArrayBufferView offset/length:
view.to_vec()(mozjs) callsGetArrayBufferViewLengthAndData, which respects the view’s[[ByteOffset]]and[[ByteLength]]— only the viewed bytes are copied. -
ArrayBuffer:
buffer.to_vec()(mozjs) callsGetArrayBufferLengthAndData, copying the entire buffer contents. -
Detached buffer: When a buffer is detached, SpiderMonkey’s
GetArrayBuffer(LengthAndData|ViewLengthAndData)returns a null pointer and zero length.to_vec()thus produces an emptyVec<u8>. -
SharedArrayBuffer: Not applicable —
ArrayBufferViewOrArrayBufferdoes not include a SharedArrayBuffer variant.