AX: <svg> elements with labels and no accessible contents are exposed as empty AXGroups
[WebKit-https.git] / LayoutTests / webrtc / video-addLegacyTransceiver.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         <video id="video" autoplay=""></video>
11         <canvas id="canvas" width="640" height="480"></canvas>
12         <script src ="routines.js"></script>
13         <script>
14 if (window.testRunner)
15     testRunner.setWebRTCUnifiedPlanEnabled(false);
16
17 test(() => {
18     assert_equals(Object.keys(RTCRtpTransceiver.prototype).indexOf("currentDirection"), -1, "No currentDirection if unified plan is off");
19 }, "Expose currentDirection only for unified plan");
20
21 promise_test((test) => {
22     var pc = new RTCPeerConnection();
23     pc.addTransceiver("video");
24
25     return pc.createOffer().then((offer) => {
26         assert_true(offer.sdp.indexOf("mid:video") !== -1);
27         assert_true(offer.sdp.indexOf("a=recvonly") !== -1);
28
29         pc.addTransceiver("audio");
30         return pc.createOffer();
31     }).then((offer) => {
32         assert_true(offer.sdp.indexOf("mid:audio") !== -1);
33     });
34 }, "Setting up calls with addTransceiver but with no track");
35
36 promise_test((test) => {
37     if (window.testRunner)
38         testRunner.setUserMediaPermission(true);
39
40     return navigator.mediaDevices.getUserMedia({ video: true }).then((stream) => {
41         var pc = new RTCPeerConnection();
42         pc.addTransceiver("video");
43         pc.getSenders()[0].replaceTrack(stream.getVideoTracks()[0]);
44
45         return pc.createOffer().then((offer) => {
46             assert_true(offer.sdp.indexOf("mid:video") !== -1);
47             // Replacing the track is not done yet so we still set it as a recvonly.
48             assert_true(offer.sdp.indexOf("a=recvonly") !== -1);
49         });
50     });
51 }, "Setting up calls with addTransceiver with a track");
52
53 function testImage()
54 {
55     canvas.width = video.videoWidth;
56     canvas.height = video.videoHeight;
57     canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
58
59     imageData = canvas.getContext('2d').getImageData(10, 325, 250, 1);
60     data = imageData.data;
61
62     var index = 20;
63     assert_true(data[index] < 100);
64     assert_true(data[index + 1] < 100);
65     assert_true(data[index + 2] < 100);
66
67     index = 80;
68     assert_true(data[index] > 200);
69     assert_true(data[index + 1] > 200);
70     assert_true(data[index + 2] > 200);
71
72     index += 80;
73     assert_true(data[index] > 200);
74     assert_true(data[index + 1] > 200);
75     assert_true(data[index + 2] < 100);
76 }
77
78 promise_test((test) => {
79     if (window.testRunner)
80         testRunner.setUserMediaPermission(true);
81
82     return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) => {
83         return new Promise((resolve, reject) => {
84             createConnections((firstConnection) => {
85                 var track = stream.getVideoTracks()[0];
86                 firstConnection.addTransceiver("video");
87                 return firstConnection.getSenders()[0].replaceTrack(stream.getVideoTracks()[0]);
88             }, (secondConnection) => {
89                 secondConnection.ontrack = (trackEvent) => {
90                     resolve(trackEvent.streams[0]);
91                 };
92             });
93             setTimeout(() => reject("Test timed out"), 5000);
94         });
95     }).then((stream) => {
96         video.srcObject = stream;
97         return video.play();
98     }).then(() => {
99         testImage();
100     });
101 }, "Basic video exchange set up with addTransceiver");
102
103         </script>
104     </body>
105 </html>