blob: fa07c942be1a5929d77e6b930fdfae17577ee3c4 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<style>
iframe { border: 1px solid black; }
</style>
<script src="../../../../resources/js-test-pre.js"></script>
<script>
var frameInfos = [];
window.jsTestIsAsync = true;
if (window.testRunner)
testRunner.setUserMediaPermission(true);
function setup()
{
description("Tests that mediaDevices.enumerateDevices returns a unique ID for deviceId in each domain.");
}
function handler(event)
{
event.data.deviceIds.forEach(function(id) {
frameInfos.push({origin : event.data.origin, deviceId : id});
});
if (frameInfos.length != 12)
return;
var success = true;
var idOrigins = [];
for (var i = 0; i < frameInfos.length; i++) {
var deviceId = frameInfos[i].deviceId;
if (idOrigins[deviceId] === undefined) {
idOrigins[deviceId] = frameInfos[i].origin;
testPassed(`: device id ${i + 1} is unique`);
} else {
testFailed(`Duplicate device IDs in ${frameInfos[i].origin} and ${idOrigins[deviceId]}`);
success = false;
}
}
debug('');
if (success)
testPassed(`: all device IDs are unique`);
debug('');
finishJSTest();
}
addEventListener("message", handler, false);
</script>
</head>
<body onload="setup()">
<iframe src="http://localhost:8000/media/media-stream/resources/enumerate-devices-source-id-frame.html"></iframe>
<br>
<iframe src="http://127.0.0.1:8000/media/media-stream/resources/enumerate-devices-source-id-frame.html"></iframe>
<br>
<iframe src="http://localhost:8000/media/media-stream/resources/enumerate-devices-source-id-frame.html"></iframe>
<div id="console"></div>
<script src="../../../../resources/js-test-post.js"></script>
</body>
</html>