Bug 1611320 [wpt PR 21400] - Gate Longtasks and PaintTiming tests under assert_precon...
[gecko.git] / testing / web-platform / tests / mediacapture-depth / dictionary-manual.https.html
blob0a5b824881509baee240f385a9eeaa380a579948
1 <!DOCTYPE html>
2 <meta charset="utf-8">
3 <title>Media Capture Depth Dictionary Test</title>
4 <link rel="author" title="Intel" href="http://www.intel.com">
5 <link rel="help" href="https://w3c.github.io/mediacapture-depth/#extensions">
6 <script src="/resources/testharness.js"></script>
7 <script src="/resources/testharnessreport.js"></script>
8 <script src="dictionary-helper.js"></script>
9 <meta name="flags" content="interact">
11 <h2>Preconditions</h2>
12 <ol>
13 <li>
14 Use a test device with depth camera(embedded or external).
15 </li>
16 <li>
17 When prompted, accept to share your depth/color(RGB) stream.
18 </li>
19 </ol>
21 <div id="log"></div>
23 <script>
25 let advanced_constraints_depth = [{
26 videoKind: "depth",
27 }];
29 let advanced_constraints_color = [{
30 videoKind: "color",
31 }];
33 function validateMediaTrackCapabilities(capabilities, type) {
34 assert_string_field(capabilities, 'videoKind');
38 function validateMediaTrackConstraintSet(constraints, type) {
39 assert_constrain_string_field(constraints, 'videoKind');
42 function validateMediaTrackSettings(settings, type) {
43 assert_string_field(settings, 'videoKind');
44 assert_enum_field(settings, 'videoKind', ['color', 'depth'])
47 function validateMediaTrackSupportedConstraints(supports) {
48 assert_boolean_field(supports, 'videoKind', true);
51 function runDictionaryTests(type, constraints) {
52 promise_test(t => {
53 return navigator.mediaDevices.getUserMedia({video: {advanced: constraints}})
54 .then(stream => {
55 let capabilities = stream.getTracks()[0].getCapabilities();
56 validateMediaTrackCapabilities(capabilities, type);
57 });
58 }, `MediaTrackCapabilities dictionary of ${type} include attributes are correct`);
60 promise_test(t => {
61 return navigator.mediaDevices.getUserMedia({video: {advanced: constraints}})
62 .then(stream => {
63 let constraints = stream.getTracks()[0].getConstraints()["advanced"][0];
64 validateMediaTrackConstraintSet(constraints);
65 });
66 }, `MediaTrackConstraintSet dictionary of ${type} include attributes are correct`);
68 promise_test(t => {
69 return navigator.mediaDevices.getUserMedia({video: {advanced: constraints}})
70 .then(stream => {
71 let settings = stream.getTracks()[0].getSettings();
72 validateMediaTrackSettings(settings, type);
73 });
74 }, `MediaTrackSettings dictionary of ${type} include attributes are correct`);
77 test(() => {
78 let supports = navigator.mediaDevices.getSupportedConstraints();
79 validateMediaTrackSupportedConstraints(supports);
80 }, "MediaTrackSupportedConstraints dictionary include attributes are correct");
82 runDictionaryTests("depth", advanced_constraints_depth);
83 runDictionaryTests("color", advanced_constraints_color);
85 </script>