diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/mediacapture-image/MediaStreamTrack-applyConstraints-reject.https.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/mediacapture-image/MediaStreamTrack-applyConstraints-reject.https.html')
-rw-r--r-- | testing/web-platform/tests/mediacapture-image/MediaStreamTrack-applyConstraints-reject.https.html | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/testing/web-platform/tests/mediacapture-image/MediaStreamTrack-applyConstraints-reject.https.html b/testing/web-platform/tests/mediacapture-image/MediaStreamTrack-applyConstraints-reject.https.html new file mode 100644 index 0000000000..ac6216ae19 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-image/MediaStreamTrack-applyConstraints-reject.https.html @@ -0,0 +1,78 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<script src="/mediacapture-image/resources/imagecapture-helpers.js"></script> +<script> + +// This test verifies that MediaStreamTrack.applyConstraints() rejects if any +// passed constraint is unsupported or outside its allowed range. +var makePromiseTest = function(getConstraint) { + image_capture_test(async (t, imageCaptureTest) => { + await test_driver.set_permission({name: 'camera', panTiltZoom: true}, + 'granted'); + + imageCaptureTest.mockImageCapture().state().supportsTorch = false; + + let stream = await navigator.mediaDevices.getUserMedia({video: true}); + let videoTrack = stream.getVideoTracks()[0]; + + try { + const constraints = { + advanced : [ getConstraint(imageCaptureTest.mockImageCapture().state()) ] + }; + + await videoTrack.applyConstraints(constraints); + assert_unreached('expected applyConstraints to reject'); + } catch (error) { + assert_equals(error.name, 'OverconstrainedError'); + } + }); +}; + +const constraintGenerators = [ + capabilities => ({ whiteBalanceMode: 'manual' }), + capabilities => ({ exposureMode: 'none' }), + capabilities => ({ focusMode: 'continuous' }), + capabilities => ({ + exposureCompensation: capabilities.exposureCompensation.max + 1 + }), + capabilities => ({ + exposureCompensation: capabilities.exposureCompensation.min - 1 + }), + capabilities => ({ + colorTemperature: capabilities.colorTemperature.max + 1 + }), + capabilities => ({ + colorTemperature: capabilities.colorTemperature.min - 1 + }), + capabilities => ({ iso: capabilities.iso.max + 1 }), + capabilities => ({ iso: capabilities.iso.min - 1 }), + capabilities => ({ brightness: capabilities.brightness.max + 1 }), + capabilities => ({ brightness: capabilities.brightness.min - 1 }), + capabilities => ({ contrast: capabilities.contrast.max + 1 }), + capabilities => ({ contrast: capabilities.contrast.min - 1 }), + capabilities => ({ saturation: capabilities.saturation.max + 1 }), + capabilities => ({ saturation: capabilities.saturation.min - 1 }), + capabilities => ({ sharpness: capabilities.sharpness.max + 1 }), + capabilities => ({ sharpness: capabilities.sharpness.min - 1 }), + capabilities => ({ pan: capabilities.pan.max + 1 }), + capabilities => ({ pan: capabilities.pan.min - 1 }), + capabilities => ({ tilt: capabilities.tilt.max + 1 }), + capabilities => ({ tilt: capabilities.tilt.min - 1 }), + capabilities => ({ zoom: capabilities.zoom.max + 1 }), + capabilities => ({ zoom: capabilities.zoom.min - 1 }), + capabilities => ({ torch: true }), +]; + +for (key in constraintGenerators) { + generate_tests( + makePromiseTest, [[ + 'MediaStreamTrack.applyConstraints(constraints) rejects with bad' + + ' constraints, #' + key, + constraintGenerators[key] + ]]); +} + +</script> |