mirror of
https://github.com/servo/servo.git
synced 2025-10-03 18:19:14 +01:00
156 lines
6.1 KiB
HTML
156 lines
6.1 KiB
HTML
<!doctype html>
|
|
<meta charset=utf-8>
|
|
<title>RTCDTMFSender.prototype.insertDTMF</title>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script>
|
|
'use strict';
|
|
|
|
promise_test(async t => {
|
|
assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia');
|
|
const stream = await navigator.mediaDevices.getDisplayMedia({video: true});
|
|
const [track] = stream.getTracks();
|
|
t.add_cleanup(() => track.stop());
|
|
assert_equals(stream.getTracks().length, 1);
|
|
assert_equals(stream.getVideoTracks().length, 1);
|
|
assert_equals(stream.getAudioTracks().length, 0);
|
|
}, 'getDisplayMedia() with video true');
|
|
|
|
// Empty constraint parameter and boolean values of false defaults to
|
|
// {video: true}. This is described in items 3-4 of section 5.1, see
|
|
// https://w3c.github.io/mediacapture-screen-share/#navigator-additions.
|
|
// Note that this results in some non-intuitive cases returning a video track,
|
|
// i.e. {video: false}.
|
|
promise_test(async t => {
|
|
assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia');
|
|
const stream = await navigator.mediaDevices.getDisplayMedia();
|
|
const [track] = stream.getTracks();
|
|
t.add_cleanup(() => track.stop());
|
|
assert_equals(stream.getTracks().length, 1);
|
|
assert_equals(stream.getVideoTracks().length, 1);
|
|
assert_equals(stream.getAudioTracks().length, 0);
|
|
}, 'getDisplayMedia() with no constraints');
|
|
|
|
promise_test(async t => {
|
|
assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia');
|
|
const stream = await navigator.mediaDevices.getDisplayMedia({video: false});
|
|
const [track] = stream.getTracks();
|
|
t.add_cleanup(() => track.stop());
|
|
assert_equals(stream.getTracks().length, 1);
|
|
assert_equals(stream.getVideoTracks().length, 1);
|
|
assert_equals(stream.getAudioTracks().length, 0);
|
|
}, 'getDisplayMedia() with video false');
|
|
|
|
promise_test(async t => {
|
|
assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia');
|
|
const stream = await navigator.mediaDevices.getDisplayMedia({audio: false});
|
|
const [track] = stream.getTracks();
|
|
t.add_cleanup(() => track.stop());
|
|
assert_equals(stream.getTracks().length, 1);
|
|
assert_equals(stream.getVideoTracks().length, 1);
|
|
assert_equals(stream.getAudioTracks().length, 0);
|
|
}, 'getDisplayMedia() with audio false');
|
|
|
|
promise_test(async t => {
|
|
assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia');
|
|
const stream = await navigator.mediaDevices.getDisplayMedia({audio: true});
|
|
const [track] = stream.getTracks();
|
|
t.add_cleanup(() => track.stop());
|
|
assert_equals(stream.getTracks().length, 1);
|
|
assert_equals(stream.getVideoTracks().length, 0);
|
|
assert_equals(stream.getAudioTracks().length, 1);
|
|
}, 'getDisplayMedia() with audio true');
|
|
|
|
promise_test(async t => {
|
|
assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia');
|
|
try {
|
|
const stream = await navigator.mediaDevices.getDisplayMedia(
|
|
{video: {advanced: [{zoom: 1}]}});
|
|
} catch (err) {
|
|
assert_equals(err.name, 'TypeError');
|
|
return;
|
|
}
|
|
assert_unreached('getDisplayMedia should have failed');
|
|
}, 'getDisplayMedia() with advanced constraint');
|
|
|
|
promise_test(async t => {
|
|
assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia');
|
|
try {
|
|
const stream = await navigator.mediaDevices.getDisplayMedia(
|
|
{video: {width: {min: 360}}});
|
|
} catch (err) {
|
|
assert_equals(err.name, 'TypeError');
|
|
return;
|
|
}
|
|
assert_unreached('getDisplayMedia should have failed');
|
|
}, 'getDisplayMedia() with min constraint');
|
|
|
|
promise_test(async t => {
|
|
assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia');
|
|
try {
|
|
const stream = await navigator.mediaDevices.getDisplayMedia(
|
|
{video: {width: {exact: 360}}});
|
|
} catch (err) {
|
|
assert_equals(err.name, 'TypeError');
|
|
return;
|
|
}
|
|
assert_unreached('getDisplayMedia should have failed');
|
|
}, 'getDisplayMedia() with exact constraint');
|
|
|
|
promise_test(async t => {
|
|
assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia');
|
|
const maxWidth = 360;
|
|
const stream = await navigator.mediaDevices.getDisplayMedia(
|
|
{video: {width: {max: maxWidth}}});
|
|
const [track] = stream.getTracks();
|
|
t.add_cleanup(() => track.stop());
|
|
assert_equals(stream.getVideoTracks().length, 1);
|
|
assert_equals(stream.getAudioTracks().length, 0);
|
|
assert_less_than_equal(
|
|
stream.getVideoTracks()[0].getSettings().width, maxWidth);
|
|
}, 'getDisplayMedia() with max constraint');
|
|
|
|
promise_test(async t => {
|
|
assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia');
|
|
const maxWidth = 360;
|
|
const maxFrameRate = 4;
|
|
const stream = await navigator.mediaDevices.getDisplayMedia(
|
|
{video: {width: {max: maxWidth}, frameRate: {max: maxFrameRate}}});
|
|
const [track] = stream.getTracks();
|
|
t.add_cleanup(() => track.stop());
|
|
assert_equals(stream.getVideoTracks().length, 1);
|
|
assert_equals(stream.getAudioTracks().length, 0);
|
|
const settings = stream.getVideoTracks()[0].getSettings();
|
|
assert_less_than_equal(settings.width, maxWidth);
|
|
assert_less_than_equal(settings.frameRate, maxFrameRate);
|
|
}, 'getDisplayMedia() with constraints applied');
|
|
|
|
promise_test(async t => {
|
|
assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia');
|
|
try {
|
|
const stream = await navigator.mediaDevices.getDisplayMedia(
|
|
{video: {width: {max: 0}}});
|
|
} catch (err) {
|
|
assert_equals(err.name, 'OverconstrainedError');
|
|
return;
|
|
}
|
|
assert_unreached('getDisplayMedia should have failed');
|
|
}, 'getDisplayMedia() overconstrained');
|
|
|
|
// Content shell picks a fake desktop device by default.
|
|
promise_test(async t => {
|
|
assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia');
|
|
const stream = await navigator.mediaDevices.getDisplayMedia({video: true});
|
|
const [track] = stream.getTracks();
|
|
t.add_cleanup(() => track.stop());
|
|
assert_equals(stream.getVideoTracks().length, 1);
|
|
assert_equals(stream.getAudioTracks().length, 0);
|
|
const settings = stream.getVideoTracks()[0].getSettings();
|
|
assert_any(
|
|
assert_equals, settings.displaySurface,
|
|
['monitor', 'window', 'application', 'browser']);
|
|
assert_any(assert_equals, settings.logicalSurface, [true, false]);
|
|
assert_any(assert_equals, settings.cursor, ['never', 'always', 'motion']);
|
|
}, 'getDisplayMedia() with getSettings');
|
|
|
|
</script>
|