tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_peerConnection_toJSON.html (1297B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <script type="application/javascript" src="pc.js"></script>
      5 </head>
      6 <body>
      7 <pre id="test">
      8 <script type="application/javascript">
      9  createHTML({
     10    bug: "928304",
     11    title: "test toJSON() on RTCSessionDescription and RTCIceCandidate"
     12  });
     13 
     14  runNetworkTest(function () {
     15    /** Test for Bug 872377 */
     16 
     17    var rtcSession = new RTCSessionDescription({ sdp: "Picklechips!",
     18                                                 type: "offer" });
     19    var jsonCopy = JSON.parse(JSON.stringify(rtcSession));
     20    for (key in rtcSession) {
     21      if (typeof(rtcSession[key]) == "function") continue;
     22      is(rtcSession[key], jsonCopy[key], "key " + key + " should match.");
     23    }
     24 
     25    /** Test for Bug 928304 */
     26 
     27    var rtcIceCandidate = new RTCIceCandidate({ candidate: "dummy",
     28                                                   sdpMid: "test",
     29                                                   sdpMLineIndex: 3 });
     30    jsonCopy = JSON.parse(JSON.stringify(rtcIceCandidate));
     31    is(jsonCopy.candidate, "dummy");
     32    is(jsonCopy.sdpMid, "test");
     33    is(jsonCopy.sdpMLineIndex, 3);
     34    is(jsonCopy.usernameFragment, rtcIceCandidate.usernameFragment);
     35    is(Object.keys(jsonCopy).length, 4, "JSON limited to those four members.");
     36  });
     37 </script>
     38 </pre>
     39 </body>
     40 </html>