Bug 1585915 [wpt PR 19488] - Check that enumerateDevices is returning new objects for every call, a=testonly

Automatic update from web-platform-tests
Check that enumerateDevices is returning new objects for every call (#19488)

* Check that enumerateDevices is returning new objects for every call

* Update mediacapture-streams/MediaDevices-enumerateDevices-returned-objects.https.html

Co-Authored-By: Philip Jägenstedt <philip@foolip.org>

--

wpt-commits: f2c6436b3496cddaef5340fe32bb71084facfb3e
wpt-pr: 19488

Differential Revision: https://phabricator.services.mozilla.com/D53451
This commit is contained in:
youennf 2019-11-04 10:45:26 +00:00 коммит произвёл moz-wptsync-bot
Родитель bcc6680346
Коммит b61fbc0630
1 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,34 @@
<!doctype html>
<html>
<head>
<title>enumerateDevices is returning new MediaDeviceInfo objects every time</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
</head>
<body>
<script>
function doTest(callGetUserMedia, testName)
{
promise_test(async () => {
if (callGetUserMedia)
await navigator.mediaDevices.getUserMedia({audio : true, video: true});
const deviceList1 = await navigator.mediaDevices.enumerateDevices();
const deviceList2 = await navigator.mediaDevices.enumerateDevices();
assert_equals(deviceList1.length, deviceList2.length);
for (let i = 0; i < deviceList1.length; i++) {
const device1 = deviceList1[i];
const device2 = deviceList2[i];
assert_not_equals(device1, device2);
assert_equals(device1.deviceId, device2.deviceId, "deviceId");
assert_equals(device1.kind, device2.kind, "kind");
}
}, testName);
}
doTest(false, "enumerateDevices returns new objects in case device-info permission is not granted");
doTest(true, "enumerateDevices returns new objects in case device-info permission is granted");
</script>
</body>
</html>