Closed Bug 1309299 Opened 5 years ago Closed 5 years ago

[EME] navigator.requestMediaKeySystemAccess should reject with TypeError on empty keySystem string or configs

Categories

(Core :: Audio/Video: Playback, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla52
Tracking Status
firefox52 --- fixed

People

(Reporter: cpearce, Assigned: cpearce)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

The EME spec says we should reject requestMediaKeySystemAccess('', []) with TypeError, but we're rejecting with InvalidAccessError.

https://www.w3.org/TR/encrypted-media/#navigator-extension-requestmediakeysystemaccess

This causes http://www.w3c-test.org/encrypted-media/drm-mp4-syntax-mediakeysystemaccess.html to fail.
Assignee: nobody → cpearce
Once I fix this, we start failing with:

navigator.requestMediaKeySystemAccess(new Uint8Array(0), [{}]); }" expected "NotSupportedError" but got "TypeError"

It seems that |new Uint8Array(0)| is being converted to the empty string (''), which we'll reject now.

The web platform test claims that toString() is called on the first argument passed to navigator.requestMediaKeySystemAccess. However when I call toString(new Uint8Array(0)) in Firefox that returns "undefined", not the empty string, and in Chrome it returns "[object Undefined]"

bz: do you know what a Uint8Array is supposed to be converted into when it's passed as the first argument to navigator.requestMediaKeySystemAccess()?
Flags: needinfo?(bzbarsky)
> However when I call toString(new Uint8Array(0)) in Firefox that returns "undefined"
> not the empty string, and in Chrome it returns "[object Undefined]"

The right thing to check is what String(new Uint8Array(0)) returns, which is the same thing as what (new Uint8Array(0)).toString() returns.  And it should return "" in all browsers.  That's because it calls https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.tostring which calls https://tc39.github.io/ecma262/#sec-array.prototype.tostring which does join() (with no args), which for an empty array will return an empty string.

> do you know what a Uint8Array is supposed to be converted into when it's passed as
> the first argument to navigator.requestMediaKeySystemAccess()?

Given the IDL for it, empty string.
Flags: needinfo?(bzbarsky)
Note that Chrome also rejects requestMediaKeySystemAccess('', []) with NotSupportedError.  So maybe the spec just needs to change to align with implementations...  Either way, the test is buggy; behavior for "" and new Uint8Array(0) should be identical.
Comment on attachment 8799945 [details]
Bug 1309299 - make navigator.requestMediaKeySystemAccess() reject with TypeError for empty keysystem string or config.

https://reviewboard.mozilla.org/r/84998/#review83558
Attachment #8799945 - Flags: review?(gsquelart) → review+
Pushed by cpearce@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8559d0b32326
make navigator.requestMediaKeySystemAccess() reject with TypeError for empty keysystem string or config. r=gerald
It's been pointed out that this was expected. When you re-land, can you either adjust the test's expectations for the new reality or disable the test until it can be fixed upstream?
Just fix the test in our tree and then the fix for it will get upstreamed...
(In reply to Boris Zbarsky [:bz] (still a bit busy) from comment #9)
> Just fix the test in our tree and then the fix for it will get upstreamed...

Upstream is fixed and the version of the EME tests in our tree is out of date. I'll mark the test as expected fail, and we'll pickup the fixed test in the next pull from upstream.
Pushed by cpearce@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/aa789d732c6c
make navigator.requestMediaKeySystemAccess() reject with TypeError for empty keysystem string or config. r=gerald
sorry had to back this out for failures in windows wpt-4 tests like https://treeherder.mozilla.org/logviewer.html#?job_id=37436623&repo=mozilla-inbound
Backout by cbook@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/e9cae5f43de9
Backed out changeset aa789d732c6c for wpt-4 test failures on own test
Pushed by cpearce@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/4ea2b81e7ffc
make navigator.requestMediaKeySystemAccess() reject with TypeError for empty keysystem string or config. r=gerald
https://hg.mozilla.org/mozilla-central/rev/4ea2b81e7ffc
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla52
Flags: needinfo?(cpearce)
You need to log in before you can comment on or make changes to this bug.