webusb: Use [PassAsSpan] to handle BufferSource arguments
This change simplifies the implementation of WebUSB methods which accept
a BufferSource argument by using the [PassAsSpan] WebIDL attribute.
Using this requires a behavior change: Passing a detached buffer is now
no longer fatal (except when it causes other argument validation errors)
because a detached buffer turns into an empty span. I think this is a
safe change to make because it matches the WebIDL rules for handling
detached buffers (throwing a specific error was unspecified behavior)
and this case is developer error, so sites shouldn't be depending on it.
Change-Id: I8af158d51b1760625984f697eac880ecd808d13b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5924242
Commit-Queue: Reilly Grant reillyg@chromium.org
Auto-Submit: Reilly Grant reillyg@chromium.org
Reviewed-by: Matt Reynolds mattreynolds@chromium.org
Cr-Commit-Position: refs/heads/main@{#1372209}