Set getUserMedia permission to true by default on WTR
[WebKit-https.git] / LayoutTests / fast / mediastream / delayed-permission-denied.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <script>
8 description("Tests that no callbacks are invoked until permission is denied.");
9 window.jsTestIsAsync = true;
10
11 function denyPermission() {
12     permissionSet = true;
13     if (window.testRunner)
14         testRunner.setUserMediaPermission(false);
15 }
16
17 if (window.testRunner)
18     testRunner.resetUserMediaPermission();
19
20 var error;
21 var options = {audio: true, video: true};
22 navigator.mediaDevices.getUserMedia(options)
23     .then(stream => {
24         testFailed('Success callback invoked unexpectedly');
25         finishJSTest();
26     })
27     .catch(err => {
28         if (permissionSet) {
29             error = err;
30             shouldBeEqualToString('error.name', 'NotAllowedError');
31         } else
32             testFailed('Error callback invoked unexpectedly');
33         finishJSTest();
34     });
35
36 window.setTimeout(denyPermission, 100);
37 </script>
38 <script src="../../resources/js-test-post.js"></script>
39 </body>
40 </html>