blob: b8b60758a0bb7634561263d68415fa0ea446c91a [file] [log] [blame]
<!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);
}
let defaultWidth;
let defaultHeight;
promise_test(async () => {
stream = await navigator.mediaDevices.getDisplayMedia({ video: true });
let settings = stream.getVideoTracks()[0].getSettings();
defaultWidth = settings.width;
defaultHeight = settings.height;
}, "setup");
promise_test((test) => {
return navigator.mediaDevices.getDisplayMedia({ 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 navigator.mediaDevices.getDisplayMedia({ 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>