[encrypted-media] Terminology "empty array" is incorrect for BufferSource (#592)

xhwang-chromium has just created a new issue for https://github.com/w3c/encrypted-media:

== Terminology "empty array" is incorrect for BufferSource ==
_Created with the help of AI._

**Problem Description:**
Throughout the specification, algorithms checking for zero-length `BufferSource` parameters (such as `ArrayBuffer` or `Uint8Array`) use the phrase "is an empty array". This is technically incorrect and inconsistent with WebIDL and modern specification standards.

A `BufferSource` is a union type of `(ArrayBufferView or ArrayBuffer)`. Neither of these types are technically "arrays" in WebIDL or JavaScript. They do not have an "empty" state in the way a sequence or a JS Array might; rather, they are defined by their content length (byte length). Referring to them as "empty arrays" is confusing and technically inaccurate.

**Affected Locations:**
1. **Section 5.1 `setServerCertificate()` Step 2**:
   > "If serverCertificate is an empty array, return a promise rejected with a new a newly created TypeError."
2. **Section 6.2 `generateRequest()` Step 5**:
   > "If initData is an empty array, return a promise rejected with a newly created TypeError."
3. **Section 6.2 `update()` Step 3**:
   > "If response is an empty array, return a promise rejected with a newly created TypeError."

**Historical Context**
`BufferSource` was introduced to EME in 
https://github.com/w3c/encrypted-media/commit/0666263a5e7044b4659704f0f43660c4a6e1cf8d. However, the "empty array" terminology existed before this change.

**Reference to Standards:**
Modern specifications handle `BufferSource` inputs by utilizing the Web IDL algorithm for [getting a copy of the bytes held by the buffer source](https://webidl.spec.whatwg.org/#dfn-get-buffer-source-copy). This converts the input into an **Infra byte sequence**, which can then be checked for "emptiness."

- **Web IDL Standard**: Defines that `BufferSource` types have an associated **byte length**. (See [Web IDL § BufferSource](https://webidl.spec.whatwg.org/#BufferSource))
- **Web Cryptography API**: In the `encrypt()` method, the spec uses this technique to process the `data` parameter:
  > "Let *data* be the result of [getting a copy of the bytes held by](https://webidl.spec.whatwg.org/#dfn-get-buffer-source-copy) the *data* parameter passed to the `encrypt()` method."
  (See [Web Crypto § 14.3.1](https://www.w3.org/TR/WebCryptoAPI/#dfn-SubtleCrypto-method-encrypt))

**Suggested Fix:**
Update the identified steps to use the standard Web IDL terminology for processing `BufferSource` data:

1. Let *buffer* be the result of [getting a copy of the bytes held by](https://webidl.spec.whatwg.org/#dfn-get-buffer-source-copy) the [parameter name] parameter.
2. If *buffer* **is empty**, return a promise rejected with a newly created TypeError.


Please view or discuss this issue at https://github.com/w3c/encrypted-media/issues/592 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 5 May 2026 16:50:19 UTC