RTCRtpReceiver-getContributingSources.https.html (1464B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <title>RTCRtpReceiver.prototype.getContributingSources</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="RTCPeerConnection-helper.js"></script> 7 <script> 8 'use strict'; 9 10 async function connectAndExpectNoCsrcs(t, kind) { 11 const pc1 = new RTCPeerConnection(); 12 t.add_cleanup(() => pc1.close()); 13 const pc2 = new RTCPeerConnection(); 14 t.add_cleanup(() => pc2.close()); 15 16 const stream = await getNoiseStream({[kind]:true}); 17 const [track] = stream.getTracks(); 18 t.add_cleanup(() => track.stop()); 19 pc1.addTrack(track, stream); 20 21 exchangeIceCandidates(pc1, pc2); 22 const trackEvent = await exchangeOfferAndListenToOntrack(t, pc1, pc2); 23 await exchangeAnswer(pc1, pc2); 24 25 // Some browsers might need an audio element attached to the DOM. 26 const element = document.createElement(kind); 27 element.autoplay = true; 28 element.srcObject = trackEvent.streams[0]; 29 document.body.appendChild(element); 30 t.add_cleanup(() => { document.body.removeChild(element) }); 31 32 assert_array_equals(trackEvent.receiver.getContributingSources(), []); 33 } 34 35 promise_test(async t => { 36 await connectAndExpectNoCsrcs(t, 'audio'); 37 }, '[audio] getContributingSources() returns an empty list in loopback call'); 38 39 promise_test(async t => { 40 await connectAndExpectNoCsrcs(t, 'video'); 41 }, '[video] getContributingSources() returns an empty list in loopback call'); 42 </script>