ServiceWorkers API should reject promises when calling objects inside detached frames
[WebKit-https.git] / LayoutTests / http / tests / media / media-stream / disconnected-frame.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <script>
8 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.");
9 window.jsTestIsAsync = true;
10
11 if (window.testRunner)
12     testRunner.setUserMediaPermission(true);
13
14 function onIframeLoaded() {
15     iframeNavigator = iframe.contentWindow.navigator;
16     iframe.remove();
17     onIframeUnloaded();
18 }
19
20 function onIframeUnloaded() {
21     var options = {audio: true, video: true};
22     iframeNavigator.mediaDevices.getUserMedia(options)
23         .then(stream => {
24             testFailed('Success callback invoked unexpectedly');
25             finishJSTest();
26         })
27         .catch(err => {
28             testFailed('Error callback invoked unexpectedly');
29             finishJSTest();
30         });
31
32     setTimeout(function() {
33         testPassed('No callbacks invoked');
34         finishJSTest();
35     }, 100);
36 }
37
38 var iframe = document.createElement('iframe');
39 iframe.src = 'resources/disconnected-frame-inner.html';
40 document.body.appendChild(iframe);
41
42 </script>
43 <script src="../../resources/js-test-post.js"></script>
44 </body>
45 </html>