summaryrefslogtreecommitdiffstats
path: root/dom/media/tests/crashtests/812785.html
blob: f26168e49be624efb911077e11d6f551cb137b79 (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 class="reftest-wait">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=812785
-->
<head>
  <meta charset="utf-8">
  <title>Bug 812785 - WebRTC use-after-free crash</title>
  <script type="application/javascript">
    var pc1, pc2, pc1_offer, pc2_answer, localAudio, remoteAudio;

    function onFailure(code) {
      stop();
    }

    function stop() {
      pc1.close(); pc1 = null;
      pc2.close(); pc2 = null;

      var index = localStorage.index || 0;
      if (index < 5) {
        localStorage.index = index + 1;
        window.location.reload();
      }
      else {
        finish();
      }
    }

    function start() {
      localAudio = document.getElementById("local");
      remoteAudio = document.getElementById("remote");

      var stream = localAudio.mozCaptureStreamUntilEnded();

      pc1 = new RTCPeerConnection();
      pc2 = new RTCPeerConnection();

      pc1.addStream(stream);
      pc1.createOffer(function (offer) {
        pc1_offer = offer;
        pc1.setLocalDescription(pc1_offer, function () {
          pc2.setRemoteDescription(pc1_offer, function () {
            pc2.createAnswer(function (answer) {
              pc2_answer = answer;
              pc2.setLocalDescription(pc2_answer, function () {
                pc1.setRemoteDescription(pc2_answer, function step6() {
                  stop();
                }, onFailure);
              }, onFailure);
            }, onFailure);
          }, onFailure);
        }, onFailure);
      }, onFailure);
    }

    function finish() {
      delete localStorage["index"];

      document.documentElement.removeAttribute("class");
    }
  </script>
</head>

<body onload="setTimeout(start, 100)">
  <audio id="local" controls autoplay><source type="audio/wav" src="" /></audio>
  <audio id="remote" controls></audio>
</body>
</html>