blob: 63fd0358a4a0cdd1db4686dfe6d92e5948dc4ed1 [file] [log] [blame]
<!doctype html>
<html>
<script src="../../../../resources/js-test-pre.js"></script>
<body>
<iframe id=none src="http://localhost:8000/media/media-stream/resources/enumerate-devices-iframe.html"></iframe>
<iframe id="microphone" allow="microphone" src="http://localhost:8000/media/media-stream/resources/enumerate-devices-iframe.html"></iframe>
<iframe id="camera" allow="camera" src="http://localhost:8000/media/media-stream/resources/enumerate-devices-iframe.html"></iframe>
<iframe id="camera+microphone" allow="camera;microphone" src="http://localhost:8000/media/media-stream/resources/enumerate-devices-iframe.html"></iframe>
<iframe id="same-origin" src="http://127.0.0.1:8000/media/media-stream/resources/enumerate-devices-iframe.html"></iframe>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
testRunner.setUserMediaPermission(true);
}
let expected = {
'microphone' : 'microphone',
'none' : '',
'camera+microphone' : 'camera+microphone',
'camera' : 'camera',
'same-origin' : 'camera+microphone'
};
let count = 0;
let success = true;
window.addEventListener("message", (event) => {
let visible = event.data.trim().split(':');
if (expected[visible[0]] != visible[1]) {
result.innerHTML += `FAIL: &LT;iframe id=${visible[0]}> saw "${visible[1]}", should have seen "${expected[visible[0]]}"<br>`;
success = false;
}
if (++count == 5) {
if (success)
result.innerHTML = 'PASS: "allow" attribute respected in all iframes';
if (window.testRunner)
testRunner.notifyDone();
}
}, false);
let enumerate = (evt) => { evt.target.contentWindow.postMessage(evt.target.id, '*'); }
Array.from(document.getElementsByTagName('iframe')).forEach(element => element.onload = enumerate);
</script>
<div id="result"></div>
</body>
</html>