AX: <svg> elements with labels and no accessible contents are exposed as empty AXGroups
[WebKit-https.git] / LayoutTests / webrtc / remove-track.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 let firstConnection, secondConnection;
13 let stream;
14 let remoteAudioTrack, remoteVideoTrack;
15 promise_test(async (test) => {
16     if (window.testRunner)
17         testRunner.setUserMediaPermission(true);
18
19     stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
20     await new Promise((resolve, reject) => {
21         createConnections((connection) => {
22             firstConnection = connection;
23             firstConnection.addTrack(stream.getVideoTracks()[0], stream);
24             firstConnection.addTrack(stream.getAudioTracks()[0], stream);
25         }, (connection) => {
26             secondConnection = connection;
27             secondConnection.ontrack = (trackEvent) => {
28                 if (!remoteVideoTrack) {
29                     remoteVideoTrack = trackEvent.track;
30                     return;
31                 }
32                 remoteAudioTrack = trackEvent.track;
33                 resolve();
34             };
35         });
36         setTimeout(() => reject("Test timed out"), 5000);
37     });
38 }, "Setup audio video exchange");
39
40 async function renegotiate()
41 {
42     let d = await firstConnection.createOffer();
43     await firstConnection.setLocalDescription(d);
44     await secondConnection.setRemoteDescription(d);
45     d = await secondConnection.createAnswer();
46     await secondConnection.setLocalDescription(d);
47 }
48
49 promise_test((test) => {
50     const promise = new Promise((resolve, reject) => {
51         remoteVideoTrack.onmute = resolve;
52         setTimeout(() => reject("Test timed out"), 5000);
53     });
54
55     firstConnection.removeTrack(firstConnection.getSenders()[0]);
56     const promise2 = renegotiate();
57     return Promise.all([promise, promise2]);
58 }, "Remove video track");
59
60 promise_test((test) => {
61     const promise = new Promise((resolve, reject) => {
62         remoteAudioTrack.onmute = resolve;
63         setTimeout(() => reject("Test timed out"), 5000);
64     });
65
66     firstConnection.removeTrack(firstConnection.getSenders()[1]);
67     const promise2 = renegotiate();
68     return Promise.all([promise, promise2]);
69 }, "Remove audio track");
70
71 promise_test(async t => {
72     const stream = await navigator.mediaDevices.getUserMedia({audio: true});
73     const track = stream.getTracks()[0];
74     let pc = new RTCPeerConnection();
75     for (let i = 0; i <100; i++) {
76         let sender = pc.addTrack(track, stream);
77         pc.removeTrack(sender);
78     }
79     pc.close();
80 }, 'Add/remove audio tracks');
81
82 promise_test(async t => {
83     const stream = await navigator.mediaDevices.getUserMedia({video: true});
84     const track = stream.getTracks()[0];
85     let pc = new RTCPeerConnection();
86     for (let i = 0; i <100; i++) {
87         let sender = pc.addTrack(track, stream);
88         pc.removeTrack(sender);
89     }
90     pc.close();
91 }, 'Add/remove video tracks');
92
93         </script>
94     </body>
95 </html>