w3c / encrypted-media

Encrypted Media Extensions
https://w3c.github.io/encrypted-media/
Other
180 stars 80 forks source link

Inconsistent handling of invalid parameters #433

Open jrummell-chromium opened 6 years ago

jrummell-chromium commented 6 years ago

Most of the parameters provided to the CDM are expected to be validated by the User Agent and return a TypeError if it's invalid. There are cases where the User Agent may not know how to validate a parameter, so additional validation may be done by the CDM. For example, section 6.7.1 for update() states how the CDM should handle an invalid |response| parameter:

6.7.1 If the format of sanitized response is invalid in any way, reject promise with a newly created TypeError.

However, if the CDM fails to process the |serverCertificate| provided for setServerCertificate(), the CDM must:

5.2 Use this object's cdm instance to process sanitized certificate. 5.3 If the preceding step failed, resolve promise with a new DOMException whose name is the appropriate error name.

Invalid data for setServerCertificate() results in a DOMException, while invalid data for Update() results in a TypeError. TypeError is not a DOMException.

Noticed this as the W3C EME test drm-invalid-license.https.html expects a TypeError when update() called with invalid data, while drm-mp4-syntax-mediakeys.https.html expects a DOMException when setServerCertificate() called with invalid data (new Uint8Array(200)).