diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/mediacapture-extensions | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/mediacapture-extensions')
-rw-r--r-- | testing/web-platform/tests/mediacapture-extensions/GUM-backgroundBlur.https.html | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/testing/web-platform/tests/mediacapture-extensions/GUM-backgroundBlur.https.html b/testing/web-platform/tests/mediacapture-extensions/GUM-backgroundBlur.https.html new file mode 100644 index 0000000000..605a4e0831 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-extensions/GUM-backgroundBlur.https.html @@ -0,0 +1,150 @@ +<!DOCTYPE html> +<html> +<head> +<title>Test background blur support</title> +<link rel="help" href="https://w3c.github.io/mediacapture-extensions/"> +</head> +<body> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks background blur support.</p> +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script> +"use strict"; + +const constraintSet = { + backgroundBlur: true +}; + +Object.keys(constraintSet).forEach(property => { + test(t => { + const supportedConstraints = + navigator.mediaDevices.getSupportedConstraints(); + assert_implements_optional( + supportedConstraints[property], + `Optional property ${property} not in supported constraints`); + }, `Test getSupportedConstraints().${property}`); + + promise_test(async t => { + const supportedConstraints = + navigator.mediaDevices.getSupportedConstraints(); + + const stream = await navigator.mediaDevices.getUserMedia({video: true}); + assert_equals(stream.getAudioTracks().length, 0); + assert_equals(stream.getVideoTracks().length, 1); + const [videoTrack] = stream.getVideoTracks(); + + assert_equals(typeof videoTrack.getCapabilities, 'function'); + const capabilities = videoTrack.getCapabilities(); + assert_equals(typeof capabilities, 'object'); + + if (!supportedConstraints[property]) { + assert_false(property in capabilities); + } + + assert_implements_optional( + property in capabilities, + `Optional property ${property} not in capabilities`); + + // Accept [false], [false, true], [true] and [true, false]. + assert_array_equals( + capabilities[property], + capabilities[property].length == 1 + ? [!!capabilities[property][0]] + : [!!capabilities[property][0], !capabilities[property][0]]); + }, `Test getCapabilities().${property}`); + + promise_test(async t => { + const supportedConstraints = + navigator.mediaDevices.getSupportedConstraints(); + + const stream = await navigator.mediaDevices.getUserMedia({video: true}); + assert_equals(stream.getAudioTracks().length, 0); + assert_equals(stream.getVideoTracks().length, 1); + const [videoTrack] = stream.getVideoTracks(); + + const capabilities = videoTrack.getCapabilities(); + + assert_equals(typeof videoTrack.getSettings, 'function'); + const settings = videoTrack.getSettings(); + assert_equals(typeof settings, 'object'); + + if (!supportedConstraints[property] || !(property in capabilities)) + assert_false(property in settings); + + assert_implements_optional( + property in capabilities, + `Optional property ${property} not in capabilities`); + + assert_in_array(settings[property], capabilities[property]); + }, `Test getSettings().${property}`); + + promise_test(async t => { + const supportedConstraints = + navigator.mediaDevices.getSupportedConstraints(); + + const stream = await navigator.mediaDevices.getUserMedia({video: true}); + assert_equals(stream.getAudioTracks().length, 0); + assert_equals(stream.getVideoTracks().length, 1); + const [videoTrack] = stream.getVideoTracks(); + + const capabilities = videoTrack.getCapabilities(); + const constraints = {advanced: [{ + [property]: constraintSet[property] + }]}; + const oldSettings = videoTrack.getSettings(); + + if (supportedConstraints[property] && !(property in capabilities)) { + // The user agent supports |constraints| but |videoTrack| is not capable + // to apply them. + await videoTrack.applyConstraints(constraints).then( + () => { + assert_unreached('Unexpected success applying constraints'); + }, + error => {}); + } else { + // The user agent does not support |constraints| and will ignore them or + // the user agent supports |constraints| and |videoTrack| is capable to + // apply them. + await videoTrack.applyConstraints(constraints).then( + () => {}, + error => { + assert_unreached(`Error applying constraints: ${error.message}`); + }); + } + + assert_equals(typeof videoTrack.getConstraints, 'function'); + const appliedConstraints = videoTrack.getConstraints(); + assert_equals(typeof appliedConstraints, 'object'); + const newSettings = videoTrack.getSettings(); + + if (!supportedConstraints[property] || !(property in capabilities)) { + // The user agent does not support |constraints| and ignored them or + // the user agent supports |constraints| but |videoTrack| was not capable + // to apply them. + assert_object_equals(appliedConstraints, {}); + } else { + // The user agent supports |constraints| and |videoTrack| was capable to + // apply them. + assert_object_equals(appliedConstraints, constraints); + } + + if (!supportedConstraints[property] || !(property in capabilities) || + !capabilities[property].includes(constraintSet[property])) { + // The user agent does not support |constraints| and ignored them or + // the user agent supports |constraints| but |videoTrack| was not capable + // to apply them or the user agent supports |constraints| and + // |videoTrack| was capable to apply them but could not satisfy advanced + // constraints and skipped them. + assert_object_equals(newSettings, oldSettings); + } else { + // The user agent supports |constraints| and |videoTrack| was capable to + // apply them and could satisfy advanced constraints. + assert_equals(newSettings[property], constraintSet[property]); + } + }, `Test applyConstraints() with ${property}`); +}); +</script> +</body> +</html> |