Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/mediastream/getusermedia-constraints.html

Issue 1977513004: Adds multiple forms of MediaStreamTrack constraints (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Tommi's comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE HTML> 1 <!DOCTYPE HTML>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/testharness.js"></script> 4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script> 5 <script src="../../resources/testharnessreport.js"></script>
6 </head> 6 </head>
7 <body> 7 <body>
8 <script> 8 <script>
9 9
10 // Formatting of promises is done according to 10 // Formatting of promises is done according to
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 assert_unreached('getUserMedia should have failed'); 49 assert_unreached('getUserMedia should have failed');
50 }) 50 })
51 .catch(function(e) { 51 .catch(function(e) {
52 assert_equals(e.name, 'Error'); 52 assert_equals(e.name, 'Error');
53 }); 53 });
54 }, 'getUserMedia() with empty constraints (neither mandatory nor optional) shoul d fail with Error'); 54 }, 'getUserMedia() with empty constraints (neither mandatory nor optional) shoul d fail with Error');
55 55
56 // The following set of tests verify behavior when trying to use the 56 // The following set of tests verify behavior when trying to use the
57 // dictionary form of constraints. The behaviors currently expected are: 57 // dictionary form of constraints. The behaviors currently expected are:
58 // - Unknown names in dictionary: ignored - which means Error 58 // - Unknown names in dictionary: ignored - which means Error
59 // - Known names but illegal syntax for value: TypeError 59 // - Known names and legal syntax for value: Error
60 // - Known names and legal syntax for value: Error (no handler yet). 60 // All constraints allow a primitive value (boolean, string or number),
61 // and Javascript is capable of coercing just about anything into those values,
62 // so we never get TypeError thrown here.
63 //
64 // Tests that the values are parsed and returned correctly are in
65 // MediaStreamTrack-getConstraints.html.
61 66
62 function check_constraints(name, constraints, expected_error) { 67 function check_constraints(name, constraints, expected_error) {
63 promise_test(function() { 68 promise_test(function() {
64 return navigator.mediaDevices.getUserMedia({'video': constraints}) 69 return navigator.mediaDevices.getUserMedia({'video': constraints})
65 .then(function(s) { 70 .then(function(s) {
66 assert_unreached('getUserMedia should have failed'); 71 assert_unreached('getUserMedia should have failed');
67 }) 72 })
68 .catch(function(e) { 73 .catch(function(e) {
69 assert_equals(e.name, expected_error); 74 assert_equals(e.name, expected_error);
70 }); 75 });
71 }, name); 76 }, name);
72 } 77 }
73 78
74 check_constraints( 79 check_constraints(
75 'Constraint with unsupported name gets ignored', 80 'Constraint with unsupported name gets ignored',
76 {'unsupported_name': 47}, 'Error'); 81 {'unsupported_name': 47}, 'Error');
77 82
78 check_constraints( 83 check_constraints(
79 'Constraint with exact Long value should be parsed', 84 'Constraint with exact Long value should be parsed',
80 {'height': {exact: 47}}, 'Error'); 85 {'height': {exact: 47}}, 'Error');
81 check_constraints( 86 check_constraints(
82 'Constraint with naked value should fail with TypeError (until supported)', 87 'Constraint with Long naked value should be parsed',
83 {height: 47}, 'TypeError'); 88 {height: 47}, 'Error');
84 89
85 check_constraints( 90 check_constraints(
86 'Constraint with boolean value should be parsed', 91 'Constraint with boolean value should be parsed',
87 {'echoCancellation': {exact: true}}, 'Error'); 92 {'echoCancellation': {exact: true}}, 'Error');
88 check_constraints( 93 check_constraints(
89 'Constraint with boolean value should fail on naked value (until supported)', 94 'Constraint with boolean naked value should be parsed',
90 {'echoCancellation': true}, 'TypeError'); 95 {'echoCancellation': true}, 'Error');
91 96
92 check_constraints( 97 check_constraints(
93 'Constraint with string value should work on exact with array', 98 'Constraint with string value should work on exact with array',
94 {'facingMode': {exact: ['user']}}, 'Error'); 99 {'facingMode': {exact: ['user']}}, 'Error');
100
95 check_constraints( 101 check_constraints(
96 'Constraint with exact string value should fail (until supported)', 102 'Constraint with exact string value should work',
97 {'facingMode': {exact: 'user'}}, 'TypeError'); 103 {'facingMode': {exact: 'user'}}, 'Error');
104
98 check_constraints( 105 check_constraints(
99 'Constraint with naked string value should fail (until supported)', 106 'Constraint with naked string value should be parsed',
100 {'facingMode': 'user'}, 'TypeError'); 107 {'facingMode': 'user'}, 'Error');
108
101 check_constraints( 109 check_constraints(
102 'Using both mandatory and height should give TypeError', 110 'Using both mandatory and height should give TypeError',
103 {'mandatory': {'height': '270'}, 'height': '270'}, 'TypeError'); 111 {'mandatory': {'height': '270'}, 'height': '270'}, 'TypeError');
104 112
105 // Shows that the advanced element is not ignored.
106 check_constraints(
107 'Advanced constraints with illegal content gives TypeError',
108 {'advanced': [{'height': 270}]}, 'TypeError');
109
110 </script> 113 </script>
111 </body> 114 </body>
112 </html> 115 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698