Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto allowing WebRTC permissions in unit tests

I am writing unit tests for a library that uses WebRTC.

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

Is there a flag or setting I can change to always allow media access globally so that my test suite is not prompted for permissions?

I am using the Jasmine test runner in Chrome.

like image 704
Rick Avatar asked Sep 26 '13 23:09

Rick


2 Answers

Good question.

EDIT: With Chrome's --use-fake-ui-for-media-stream flag, all gUM calls will be auto-accepted and no UI will ever pop up.

I believe there was some discussion of a browser flag that would mean permission confirmation was never required via the UI, but as far as I'm aware this hasn't been implemented in any browser. (I can imagine potential security problems.)

Couple of suggestions (which probably won't work for you, given that you're writing a library, not an app...)

  1. Could you run the test from a Chrome app? If you use the audioCapture/videoCapture permission, permission is only requested once, on app installation, not for every session.

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

like image 171
Sam Dutton Avatar answered Oct 25 '22 04:10

Sam Dutton


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

like image 31
Alexander Kobelev Avatar answered Oct 25 '22 05:10

Alexander Kobelev