Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
The Most Interesting Part
So here's a couple very fun facts:
NotAllowedError
would mean either that the user disallowed access to the camera/mic, or the connection was insecure. As such, the only way I can think of distinguishing them is by checking forhttps
(as we sortof were before I "fixed" it in a previous PR)NotAllowedError
thankfully only means that the user disallowed access to the camera/mic. However, insecure connections are instead handled by hidingnavigator.mediaDevices
,navigator.getUserMedia
, and possibly other things. The absence of those things used to be our way of testing for outdated browsers. So now, we need a way to distinguish between insecure and outdated, and the best way I can think of is to check for the existence of some other fields.So we had to handle all that. The polyfill was already handling missing
getUserMedia
as an "unsupported" error, so I changed it to distinguish between the "unsupported" and "insecure" errors and return accordingly. I let the function that callsgetUserMedia
continue to handle all errors by giving an appropriate user message, but now I include the two potentially returned by the polyfill and I disambiguateNotAllowedError
.Question
As a separate matter, I wonder whether
getUserMediaPolyfill
is technically a polyfill anymore. By definition it looks like they're supposed to make older browsers behave like newer ones. Here, I'm making newer browsers behave like older ones, because it's just easier to handle errors this way. So the options I can think of: