summaryrefslogtreecommitdiffstats
path: root/dom/media/tests/mochitest/test_getUserMedia_basicTabshare.html
blob: c61b5c9b133215f8aca74045b260b3c5c1fa3ea1 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE HTML>
<html>
<head>
  <script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
  createHTML({
    title: "getUserMedia Basic Tabshare Test",
    bug: "1193075"
  });
  /**
   * Run a test to verify that we can complete a start and stop media playback
   * cycle for a tabshare LocalMediaStream on a video HTMLMediaElement.
   *
   * Additionally, exercise applyConstraints code for tabshare viewport offset.
   */
  runTest(function () {
    const isWinXP = navigator.userAgent.indexOf("Windows NT 5.1") != -1;
    if (IsMacOSX10_6orOlder() || isWinXP) {
        ok(true, "Screensharing disabled for OSX10.6 and WinXP");
        return;
    }
    var testVideo = createMediaElement('video', 'testVideo');

    return Promise.resolve()
      .then(() => getUserMedia({
        video: { mediaSource: "browser",
                 scrollWithPage: true },
        fake: false
      }))
      .then(stream => {
        var playback = new LocalMediaStreamPlayback(testVideo, stream);
        return playback.playMediaWithDeprecatedStreamStop(false);
      })
      .then(() => getUserMedia({
        video: {
          mediaSource: "browser",
          viewportOffsetX: 0,
          viewportOffsetY: 0,
          viewportWidth: 100,
          viewportHeight: 100
        },
        fake: false
      }))
      .then(stream => {
        var playback = new LocalMediaStreamPlayback(testVideo, stream);
        playback.startMedia(false);
        return playback.verifyPlaying()
          .then(() => Promise.all([
            () => testVideo.srcObject.getVideoTracks()[0].applyConstraints({
              mediaSource: "browser",
              viewportOffsetX: 10,
              viewportOffsetY: 50,
              viewportWidth: 90,
              viewportHeight: 50
            }),
            () => listenUntil(testVideo, "resize", () => true)
          ]))
          .then(() => playback.verifyPlaying()) // still playing
          .then(() => playback.deprecatedStopStreamInMediaPlayback())
          .then(() => playback.detachFromMediaElement());
      });
  });

</script>
</pre>
</body>
</html>