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

Unified Diff: third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-getConstraints.html

Issue 1910463002: Implement MediaStreamTrack.getConstraints (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments on layout test Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-getConstraints.html
diff --git a/third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-getConstraints.html b/third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-getConstraints.html
new file mode 100644
index 0000000000000000000000000000000000000000..e4996693640c119d51b3c2c777d8118f9bafc8eb
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-getConstraints.html
@@ -0,0 +1,89 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+</head>
+<body>
+<script>
+
+// If a constraint is specified, it should come back in getConstraints().
+promise_test(function() {
+ return navigator.mediaDevices.getUserMedia({audio: { echoCancellation: { exact: true}}})
+ .then(function(s) {
+ constraints = s.getAudioTracks()[0].getConstraints();
+ assert_equals(Object.keys(constraints).length, 1);
+ assert_true(constraints.hasOwnProperty('echoCancellation'));
+ assert_true(constraints.echoCancellation.exact);
+ });
+}, 'A set constraint is returned on getConstraints');
+
+promise_test(function() {
+ return navigator.mediaDevices.getUserMedia({audio: { echoCancellation: { exact: true}, notKnownName: { exact: true }}})
+ .then(function(s) {
+ constraints = s.getAudioTracks()[0].getConstraints();
+ assert_equals(Object.keys(constraints).length, 1);
+ assert_false(constraints.hasOwnProperty('notKnownName'));
+ });
+}, 'An unknown constraint is NOT returned on getConstraints');
+
+function constraintElementsEqual(a, b) {
+ if (a === b)
+ return true;
+ if (!(a instanceof Object))
+ return false;
+ if (!(b instanceof Object))
+ return false;
+ if (Object.keys(a).length != Object.keys(b).length)
+ return false;
+ for (var p in a) {
+ if (!a.hasOwnProperty(p))
+ continue; // Skip prototypes and such things.
+ if (!b.hasOwnProperty(p))
+ return false;
+ if (a[p] instanceof Object && b[p] instanceof Object) {
+ if (!constraintElementsEqual(a[p], b[p]))
+ return false;
+ continue;
+ }
+ if (a[p] !== b[p]) return false; // Simple types.
+ }
+ return true;
+}
+
+promise_test(function() {
+ // We construct a constraint set that covers all defined constraints.
+ // All these constraints make sense for video.
+ const complexConstraintSet = {
+ width: { min: 30, max: 480 },
+ height: { min: 30, max: 480, exact: 350 },
+ aspectRatio: { ideal: 1.3333333, exact: 1.4444 },
+ frameRate: { exact: 30.0 },
+ facingMode: { ideal: [ "user" ] }
+ };
+ // These constraints are syntactically valid, but may cause rejection.
+ // They are included in an "advanced" constraint.
+ const ignorableConstraintSet = {
+ volume: { exact: 1.0 },
+ sampleRate: { exact: 42 },
+ sampleSize: { exact: 3 },
+ echoCancellation: { exact: false },
+ latency: { exact: 0.22 },
+ channelCount: { exact: 2 },
+ deviceId: { exact: ["foo"] },
+ groupId: { exact: ["bar"] }
+ };
+ let complexConstraints = complexConstraintSet;
+ complexConstraints.advanced = [ ignorableConstraintSet ];
+
+ return navigator.mediaDevices.getUserMedia({video: complexConstraints})
+ .then(function(s) {
+ constraints = s.getVideoTracks()[0].getConstraints();
+ assert_true(constraintElementsEqual(constraints, complexConstraints),
+ "Unexpected result:" + JSON.stringify(constraints, null, 2));
+ });
+}, 'All valid keys are returned for complex constraints');
+
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698