summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/mediacapture-streams/support/iframe-MediaStreamTrack-transfer-video.html
blob: 9f37ba0ffa5a259fdb998a7ab55ccae13d9dc8f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!DOCTYPE html>
<html>
  <head>
    <title>iframe</title>
    <script>
      function onMsg(e) {
          if(e.data instanceof MediaStreamTrack) {
              const track = e.data;
              video = document.getElementById("myvideo");
              video.srcObject = new MediaStream ([track]);
              video.play();

              parent.postMessage({result: 'Success'});
          } else {
              parent.postMessage({
                  result: 'Failure',
                  error: `${e.data} is not a MediaStreamTrack`
              });
        }
      }
      window.addEventListener("message", onMsg);
    </script>
  </head>
  <body>
    <video id="myvideo"></video>
  </body>
</html>