Improve debugging ability of some webrtc tests
[WebKit-https.git] / LayoutTests / webrtc / video-getParameters.html
1 <!doctype html>
2 <html>
3     <head>
4         <meta charset="utf-8">
5         <title>Testing getParameters on a basic video exchange</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 var firstConnection, secondConnection;
13 promise_test((test) => {
14     if (window.testRunner)
15         testRunner.setUserMediaPermission(true);
16
17     var sender, receiver;
18     var localStream, remoteStream;
19     return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) => {
20         localStream = stream;
21         return new Promise((resolve, reject) => {
22             createConnections((connection) => {
23                 firstConnection = connection;
24                 sender = firstConnection.addTrack(stream.getVideoTracks()[0], stream);
25             }, (connection) => {
26                 secondConnection = connection;
27                 receiver = secondConnection.addTransceiver("video").receiver;
28                 secondConnection.ontrack = (trackEvent) => {
29                     remoteStream = trackEvent.streams[0];
30                     resolve();
31                 };
32             });
33             setTimeout(() => reject("Test timed out"), 5000);
34         });
35     }).then(() => {
36         assert_true(!!sender, "sender should not be undefined");
37         assert_true(!!receiver, "receiver should not be undefined");
38         var senderParameters = sender.getParameters();
39         var receiverParameters = receiver.getParameters();
40         assert_true(!!senderParameters, "sender parameters should not be undefined or null");
41         assert_true(!!receiverParameters, "receiver parameters should not be undefined or null");
42
43         assert_equals(JSON.stringify(senderParameters), JSON.stringify(receiverParameters), "testing sender vs. receiver parameters");
44
45         senderParameters.encodings[0].fec.ssrc = 1;
46         senderParameters.encodings[0].rtx.ssrc = 1;
47         senderParameters.encodings[0].ssrc = 1;
48         assert_equals(JSON.stringify(senderParameters), '{"codecs":[],"degradationPreference":"balanced","encodings":[{"active":true,"dtx":"disabled","fec":{"ssrc":1},"maxBitrate":0,"maxFramerate":0,"priority":"medium","rid":"","rtx":{"ssrc":1},"scaleResolutionDownBy":1,"ssrc":1}],"headerExtensions":[],"transactionId":""}', "Testing sanitized parameters");
49     });
50 }, "Basic video stats");
51         </script>
52     </body>
53 </html>