Enforce user gesture for getUserMedia in case a previous getUserMedia call was denied
[WebKit-https.git] / LayoutTests / http / tests / media / media-stream / resources / get-display-media-devices-iframe.html
1 <script>
2     function callGetDisplayMedia(options)
3     {
4         let promise;
5         window.internals.withUserGesture(() => {
6             promise = navigator.mediaDevices.getDisplayMedia(options);
7         });
8         return promise;
9     }
10
11     async function enumerate(event)
12     {
13         let result;
14         await callGetDisplayMedia({video: true})
15             .then((s) => result = "allow")
16             .catch((e) => result = "deny");
17         parent.postMessage(`${event.data}:${result}`, '*');
18         result.innerHTML = result;
19     }
20
21     window.addEventListener("message", (id) => enumerate(id));
22 </script>
23
24 <div id='result'></div>
25
26