Automatic resolution of WebRTC permissions in unit tests

I am writing unit tests for a library using WebRTC.

My test suite requires Chrome permissions for almost every unit test, which requires me to manually click the "allow" button for each test.

Is there a flag or parameter that I can change to always allow access to multimedia globally so that my test suite does not ask for permission?

I am using the Jasmine test runner in Chrome.

+6
source share
2 answers
Good question.

EDIT: with the Chrome -use-fake-ui-for-media-stream flag, all gUM calls will be automatically accepted and the user interface will never appear.

I believe that there was some discussion of the browser flag, which would mean that permission confirmation was never required using the user interface, but as far as I know, this was not implemented in any browser. (I can imagine potential security issues.)

A few suggestions (which probably won't work for you, considering you are writing a library, not an application ...)

  • Can you run the test from a Chrome app? If you use the audioCapture / videoCapture permission, permission is requested only once, when installing the application, and not for each session.

  • Use HTTPS for the page that calls getUserMedia (). This means that permission is requested only once for this domain, the first time gUM is called.

+6
source

There is a list of policies that Chromium respects your interest in these two options: VideoCaptureAllowed and VideoCaptureAllowedUrls . Also this option was useful for me DefaultMediaStreamSetting , but now it is deprecated (I set it to 1). How to configure - it depends only on your operating system. Look for Linux , Mac OS X and Windows

+1
source

Source: https://habr.com/ru/post/954729/


All Articles