Skip to content

Commit

Permalink
[embedlite-components] Add a html test for webrtc permissions. JB#53942
Browse files Browse the repository at this point in the history
  • Loading branch information
d-grigorev committed Jun 8, 2021
1 parent 344972b commit 2477d1f
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/htmltests/webrtc.html
@@ -0,0 +1,41 @@
<html>
<body>
<button id="microphone">Microphone</button><br>
<button id="camera">Camera</button><br>
<button id="camera+microphone">Camera + Microphone</button><br>
<style>
button {
background-color: white;
color: black;
padding: 16px 32px;
font-size: 32px;
margin: 16px;
width: 50%;
}
.success {
background-color: green;
}
.error {
background-color: red;
}
</style>
<script>
const testPermissions = {
"microphone": {audio: true},
"camera": {video: true},
"camera+microphone": {audio: true, video: true},
};

for (const [perm, params] of Object.entries(testPermissions)) {
var button = document.getElementById(perm);
button.addEventListener('click', function(event) {
navigator.mediaDevices.getUserMedia(params)
.then(
() => { event.target.className = "button success"},
() => { event.target.className = "button error"}
)
}
);
}
</script>
</body>

0 comments on commit 2477d1f

Please sign in to comment.