| <!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() { |
| iframeNavigator = iframe.contentWindow.navigator; |
| iframe.remove(); |
| onIframeUnloaded(); |
| } |
| |
| function onIframeUnloaded() { |
| var options = {audio: true, video: true}; |
| iframeNavigator.mediaDevices.getUserMedia(options) |
| .then(stream => { |
| testFailed('Promise resolved unexpectedly.'); |
| finishJSTest(); |
| }) |
| .catch(err => { |
| testPassed('Promise rejected as expected.'); |
| finishJSTest(); |
| }); |
| |
| setTimeout(function() { |
| testFailed('Timeout: promise resolve and reject functions not called.'); |
| finishJSTest(); |
| }, 100); |
| } |
| |
| 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> |