summaryrefslogtreecommitdiffstats
path: root/android_webview/tools/system_webview_shell/test/data/blink-apis/webrtc/mediastream-callbacks.html
blob: 7db56fc73328e680a936aab0585e4d3819f2eea4 (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
<!DOCTYPE html>
<html>
  <script src="../../resources/js-test.js"></script>
  <body>
    <script type="text/javascript">
      description("Test MediaStream API callbacks in WebView");
      window.jsTestIsAsync = true;

      function error(e) {
        testFailed('getUserMedia error callback, reason: ' + e.name);
        finishJSTest();
      }

      function gotStream(stream) {
        testPassed('getUserMedia succeeded.');
        track = stream.getVideoTracks()[0];
        activeStream = stream;
        shouldBeEqualToString('track.readyState', 'live');
        shouldBeTrue('activeStream.active');
        finishJSTest();
      }

      function getUserMedia(constraints, callback) {
        try {
          navigator.webkitGetUserMedia(constraints, callback, error);
        } catch (e) {
          testFailed('webkitGetUserMedia threw exception :' + e);
          finishJSTest();
        }
      }

      getUserMedia({audio:true, video:true}, gotStream);
    </script>
  </body>
</html>