Automatic update from web-platform-tests [CE] Default HTMLUserMediaElement to request both camera and microphone. This change modifies the behavior of the HTMLUserMediaElement in standard mode to be in line with the spec. Upon insertion into the DOM, the element will now asynchronously apply default constraints to request both video and audio capture permissions. Previously, the element required an explicit call to `setConstraints` to define which permissions were needed. Now, if `setConstraints` is not called, it defaults to requesting both camera and microphone. Change-Id: I3093488063a681a39bcbc1125eb7e1c9a71f3d9e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8041783 Reviewed-by: Joey Arhar <jarhar@chromium.org> Reviewed-by: Thomas Nguyen <tungnh@chromium.org> Commit-Queue: Thomas Nguyen <tungnh@chromium.org> Cr-Commit-Position: refs/heads/main@{#1659867} -- wpt-commits: 7c53508a3c63a04238445e66cc5d5bd3db375378 wpt-pr: 61202
72 lines
2.6 KiB
HTML
72 lines
2.6 KiB
HTML
<!doctype html>
|
|
<meta charset="utf-8" />
|
|
<meta name="timeout" content="long" />
|
|
<title>HTMLUserMediaElement setConstraints() behavior combinations in Standard Mode</title>
|
|
<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="resources/pepc-helper.js"></script>
|
|
<body>
|
|
<script>
|
|
|
|
const testCases = [
|
|
// In standard mode, the element always requests both camera and microphone.
|
|
// Missing constraints default to enabled.
|
|
{ name: "Case 0: No constraints", video: undefined, audio: undefined },
|
|
{ name: "Case 1: Video set, Audio missing", video: true, audio: undefined },
|
|
{ name: "Case 2: Audio set, Video missing", video: undefined, audio: true },
|
|
{ name: "Case 3: Both set", video: true, audio: true },
|
|
];
|
|
|
|
for (const testCase of testCases) {
|
|
promise_test(async (t) => {
|
|
await test_driver.set_permission({ name: "camera" }, "granted");
|
|
await test_driver.set_permission({ name: "microphone" }, "granted");
|
|
|
|
const usermedia = document.createElement("usermedia");
|
|
document.body.appendChild(usermedia);
|
|
t.add_cleanup(() => {
|
|
if (usermedia.parentNode) {
|
|
document.body.removeChild(usermedia);
|
|
}
|
|
});
|
|
|
|
const stream_promise = new Promise((resolve) => {
|
|
usermedia.onstream = resolve;
|
|
});
|
|
|
|
const constraints = {};
|
|
if (testCase.video !== undefined) {
|
|
constraints.video = {};
|
|
}
|
|
if (testCase.audio !== undefined) {
|
|
constraints.audio = {};
|
|
}
|
|
usermedia.setConstraints(constraints);
|
|
|
|
// Wait until the element is clickable.
|
|
await new Promise((r) => t.step_timeout(r, PEPC_CLICK_DELAY));
|
|
|
|
// In all these cases, we expect success because:
|
|
// - Standard mode always has both descriptors (camera + mic).
|
|
// - Missing constraints default to enabled.
|
|
// - Both permissions are granted.
|
|
await test_driver.click(usermedia);
|
|
await stream_promise;
|
|
|
|
const stream = usermedia.stream;
|
|
t.add_cleanup(() => {
|
|
if (stream) {
|
|
stream.getTracks().forEach((track) => track.stop());
|
|
}
|
|
});
|
|
|
|
assert_true(stream instanceof MediaStream, `stream type check`);
|
|
assert_equals(stream.getVideoTracks().length, 1, `video tracks mismatch`);
|
|
assert_equals(stream.getAudioTracks().length, 1, `audio tracks mismatch`);
|
|
}, testCase.name);
|
|
}
|
|
</script>
|
|
</body>
|