LibWebRTCRtpReceiverBackend::getSynchronizationSources should use Vector::append
[WebKit-https.git] / LayoutTests / webrtc / ephemeral-certificates-and-cnames.html
1 <!doctype html>
2 <html>
3     <head>
4         <meta charset="utf-8">
5         <title>Testing basic video exchange from offerer to receiver</title>
6         <script src="../resources/testharness.js"></script>
7         <script src="../resources/testharnessreport.js"></script>
8     </head>
9     <body>
10         <script src ="routines.js"></script>
11         <script>
12 function fingerprintFromSDP(sdp)
13 {
14     var fingerprint;
15     sdp.split("\r\n").forEach((line) => {
16         if (line.startsWith("a=fingerprint"))
17             fingerprint = line.substring(14);
18     });
19     return fingerprint;
20 }
21
22 function cnameFromSDP(sdp)
23 {
24     var expression = new RegExp("^a=ssrc:(\\d+) cname:([\\w+/\\-@\\.\\{\\}]+).*$");
25
26     var cname;
27     sdp.split("\r\n").forEach((line) => {
28         let match = line.match(expression);
29         if (match)
30             cname = match[2];
31     });
32     return cname;
33 }
34
35 promise_test((test) => {
36     if (window.testRunner)
37         testRunner.setUserMediaPermission(true);
38
39     var offerFingerprint, answerFingerprint;
40     var offerCName;
41     return navigator.mediaDevices.getUserMedia({ video: true, audio: true}).then((stream) => {
42         return new Promise((resolve, reject) => {
43             createConnections((firstConnection) => {
44                 firstConnection.addTrack(stream.getVideoTracks()[0], stream);
45             }, (secondConnection) => {
46             }, {observeOffer : (offer) => {
47                 offerFingerprint = fingerprintFromSDP(offer.sdp);
48                 offerCName = cnameFromSDP(offer.sdp);
49             }, observeAnswer: (answer) => {
50                 answerFingerprint = fingerprintFromSDP(answer.sdp);
51                 resolve();
52             }});
53             setTimeout(() => reject("Test timed out 1"), 2000);
54         });
55     }).then(() => {
56         return navigator.mediaDevices.getUserMedia({ video: true, audio: true}).then((stream) => {
57             return new Promise((resolve, reject) => {
58                 createConnections((firstConnection) => {
59                     firstConnection.addTrack(stream.getVideoTracks()[0], stream);
60                 }, (secondConnection) => {
61                 }, {observeOffer : (offer) => {
62                     assert_not_equals(fingerprintFromSDP(offer.sdp), offerFingerprint);
63                     assert_not_equals(cnameFromSDP(offer.sdp), offerCName);
64                 }, observeAnswer: (answer) => {
65                     assert_not_equals(fingerprintFromSDP(answer.sdp), answerFingerprint);
66                     resolve();
67                 }});
68                 setTimeout(() => reject("Test timed out 2"), 2000);
69             });
70         });
71     });
72 }, "Ensuring certificates and cnames are ephemerals");
73         </script>
74     </body>
75 </html>