| <!doctype html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <title>video track width and height should be set correctly when only one constraint is passed to getDisplayMedia</title> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| </head> |
| <body> |
| |
| <script> |
| if (window.testRunner) |
| testRunner.setUserMediaPermission(true); |
| if (window.internals) { |
| window.internals.setMockMediaCaptureDevicesEnabled(true); |
| window.internals.settings.setScreenCaptureEnabled(true); |
| } |
| |
| function callGetDisplayMedia(options) |
| { |
| let promise; |
| window.internals.withUserGesture(() => { |
| promise = navigator.mediaDevices.getDisplayMedia(options); |
| }); |
| return promise; |
| } |
| |
| let defaultWidth; |
| let defaultHeight; |
| promise_test(async () => { |
| stream = await callGetDisplayMedia({ video: true }); |
| let settings = stream.getVideoTracks()[0].getSettings(); |
| defaultWidth = settings.width; |
| defaultHeight = settings.height; |
| }, "setup"); |
| |
| promise_test((test) => { |
| return callGetDisplayMedia({ video: { width: {ideal: 640} } }) |
| .then((stream) => { |
| let settings = stream.getVideoTracks()[0].getSettings() |
| assert_equals(settings.height, Math.floor(640 * (defaultHeight / defaultWidth))); |
| }) |
| }, "height calculated correctly only width is specified"); |
| |
| promise_test((test) => { |
| |
| return callGetDisplayMedia({ video: { height: {ideal: 240} } }) |
| .then((stream) => { |
| let settings = stream.getVideoTracks()[0].getSettings() |
| assert_equals(settings.width, Math.floor(240 * (defaultWidth / defaultHeight))); |
| }) |
| }, "width calculated correctly only height is specified"); |
| |
| </script> |
| </body> |
| </html> |