最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Auto allowing WebRTC permissions in unit tests - Stack Overflow

matteradmin7PV0评论

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.

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.

Share Improve this question asked Sep 26, 2013 at 23:01 RickRick 8,9069 gold badges52 silver badges79 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 7

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.

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

Post a comment

comment list (0)

  1. No comments so far