c176efcebe6aaaa150d5a2a1c78e9194504ddfd0
[WebKit-https.git] / LayoutTests / fast / mediastream / overconstrainederror-constraint.html
1 <!doctype html>
2 <html>
3     <head>
4         <meta charset="utf-8">
5         <title>OverConstrainedError.constraint testing</title>
6         <script src="../../resources/testharness.js"></script>
7         <script src="../../resources/testharnessreport.js"></script>
8     </head>
9     <body>
10
11         <script>
12 if (window.testRunner)
13     testRunner.setUserMediaPermission(true);
14 if (window.internals)
15     window.internals.setMockMediaCaptureDevicesEnabled(true);
16
17 promise_test(async () => {
18     return navigator.mediaDevices.getUserMedia({audio: {deviceId: {exact:"none"}}}).then(
19         () => assert_not_reached("gum should fail"),
20         (e) => {
21             assert_true(e instanceof OverconstrainedError);
22             assert_equals(e.constraint, "", "constraint should be the empty string");
23         }
24     );
25 }, "Before grant");
26
27 promise_test(async(test) => {
28     await navigator.mediaDevices.getUserMedia({audio: true});
29     return navigator.mediaDevices.getUserMedia({audio: {deviceId: {exact:"none"}}}).then(
30         () => assert_not_reached("gum should fail"),
31         (e) => {
32             assert_true(e instanceof OverconstrainedError);
33             assert_equals(e.constraint, "deviceId", "constraint should be deviceId");
34         }
35     );
36 }, "After grant");
37         </script>
38     </body>
39 </html>