blob: 6db4b4e9d05437da53f3416e670253fc20fd1d13 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Tests that when a request is made on a UserMedia object and its Frame is disconnected before a callback is made, the error callback is invoked with the correct error message.");
window.jsTestIsAsync = true;
if (window.testRunner)
testRunner.setUserMediaPermission(true);
function onIframeLoaded() {
iframeMediaDevices = iframe.contentWindow.navigator.mediaDevices;
iframe.remove();
onIframeUnloaded();
}
function onIframeUnloaded() {
handle = setTimeout(function() {
testFailed('Timeout: promise resolve and reject functions not called.');
finishJSTest();
}, 100);
var options = {audio: true, video: true};
iframeMediaDevices.getUserMedia(options)
.then(stream => {
testFailed('Promise resolved unexpectedly.');
clearTimeout(handle);
finishJSTest();
})
.catch(err => {
testPassed('Promise rejected as expected.');
clearTimeout(handle);
finishJSTest();
});
}
var iframe = document.createElement('iframe');
iframe.src = 'resources/disconnected-frame-inner.html';
document.body.appendChild(iframe);
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>