RTCPeerConnection-ondatachannel.html (1714B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <title>RTCPeerConnection.prototype.ondatachannel</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="../webrtc/RTCPeerConnection-helper.js"></script> 7 <script> 8 'use strict'; 9 10 promise_test(async (t) => { 11 const resolver = new Resolver(); 12 const pc1 = new RTCPeerConnection(); 13 const pc2 = new RTCPeerConnection(); 14 t.add_cleanup(() => pc1.close()); 15 t.add_cleanup(() => pc2.close()); 16 17 const dc1 = pc1.createDataChannel('test', { 18 ordered: false, 19 maxRetransmits: 1, 20 protocol: 'custom', 21 priority: 'high' 22 }); 23 24 assert_equals(dc1.priority, 'high'); 25 26 pc2.ondatachannel = t.step_func((event) => { 27 const dc2 = event.channel; 28 29 assert_equals(dc2.priority, 'high'); 30 31 resolver.resolve(); 32 }); 33 34 exchangeIceCandidates(pc1, pc2); 35 await exchangeOfferAnswer(pc1, pc2); 36 37 await resolver; 38 }, 'In-band negotiated channel created on remote peer should match the same configuration as local ' + 39 'peer'); 40 41 promise_test(async (t) => { 42 const resolver = new Resolver(); 43 const pc1 = new RTCPeerConnection(); 44 const pc2 = new RTCPeerConnection(); 45 t.add_cleanup(() => pc1.close()); 46 t.add_cleanup(() => pc2.close()); 47 48 const dc1 = pc1.createDataChannel(''); 49 50 assert_equals(dc1.priority, 'low'); 51 52 pc2.ondatachannel = t.step_func((event) => { 53 const dc2 = event.channel; 54 assert_equals(dc2.priority, 'low'); 55 56 resolver.resolve(); 57 }); 58 59 exchangeIceCandidates(pc1, pc2); 60 await exchangeOfferAnswer(pc1, pc2); 61 62 await resolver; 63 }, 'In-band negotiated channel created on remote peer should match the same (default) ' + 64 'configuration as local peer'); 65 66 </script>