nonTrickleIce.js (3550B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 function removeTrickleOption(desc) { 6 var sdp = desc.sdp.replace(/\r\na=ice-options:trickle\r\n/, "\r\n"); 7 return new RTCSessionDescription({ type: desc.type, sdp }); 8 } 9 10 function makeOffererNonTrickle(chain) { 11 chain.replace("PC_LOCAL_SETUP_ICE_HANDLER", [ 12 function PC_LOCAL_SETUP_NOTRICKLE_ICE_HANDLER(test) { 13 // We need to install this callback before calling setLocalDescription 14 // otherwise we might miss callbacks 15 test.pcLocal.setupIceCandidateHandler(test, () => {}); 16 // We ignore ICE candidates because we want the full offer 17 }, 18 ]); 19 chain.replace("PC_REMOTE_GET_OFFER", [ 20 function PC_REMOTE_GET_FULL_OFFER(test) { 21 return test.pcLocal.endOfTrickleIce.then(() => { 22 test._local_offer = removeTrickleOption(test.pcLocal.localDescription); 23 test._offer_constraints = test.pcLocal.constraints; 24 test._offer_options = test.pcLocal.offerOptions; 25 }); 26 }, 27 ]); 28 chain.insertAfter("PC_REMOTE_SANE_REMOTE_SDP", [ 29 function PC_REMOTE_REQUIRE_REMOTE_SDP_CANDIDATES(test) { 30 info( 31 "test.pcLocal.localDescription.sdp: " + 32 JSON.stringify(test.pcLocal.localDescription.sdp) 33 ); 34 info("test._local_offer.sdp" + JSON.stringify(test._local_offer.sdp)); 35 is( 36 test.pcRemote._pc.canTrickleIceCandidates, 37 false, 38 "Remote thinks that trickle isn't supported" 39 ); 40 ok(!test.localRequiresTrickleIce, "Local does NOT require trickle"); 41 ok( 42 test._local_offer.sdp.includes("a=candidate"), 43 "offer has ICE candidates" 44 ); 45 ok( 46 test._local_offer.sdp.includes("a=end-of-candidates"), 47 "offer has end-of-candidates" 48 ); 49 }, 50 ]); 51 chain.remove("PC_REMOTE_CHECK_CAN_TRICKLE_SYNC"); 52 } 53 54 function makeAnswererNonTrickle(chain) { 55 chain.replace("PC_REMOTE_SETUP_ICE_HANDLER", [ 56 function PC_REMOTE_SETUP_NOTRICKLE_ICE_HANDLER(test) { 57 // We need to install this callback before calling setLocalDescription 58 // otherwise we might miss callbacks 59 test.pcRemote.setupIceCandidateHandler(test, () => {}); 60 // We ignore ICE candidates because we want the full offer 61 }, 62 ]); 63 chain.replace("PC_LOCAL_GET_ANSWER", [ 64 function PC_LOCAL_GET_FULL_ANSWER(test) { 65 return test.pcRemote.endOfTrickleIce.then(() => { 66 test._remote_answer = removeTrickleOption( 67 test.pcRemote.localDescription 68 ); 69 test._answer_constraints = test.pcRemote.constraints; 70 }); 71 }, 72 ]); 73 chain.insertAfter("PC_LOCAL_SANE_REMOTE_SDP", [ 74 function PC_LOCAL_REQUIRE_REMOTE_SDP_CANDIDATES(test) { 75 info( 76 "test.pcRemote.localDescription.sdp: " + 77 JSON.stringify(test.pcRemote.localDescription.sdp) 78 ); 79 info("test._remote_answer.sdp" + JSON.stringify(test._remote_answer.sdp)); 80 is( 81 test.pcLocal._pc.canTrickleIceCandidates, 82 false, 83 "Local thinks that trickle isn't supported" 84 ); 85 ok(!test.remoteRequiresTrickleIce, "Remote does NOT require trickle"); 86 ok( 87 test._remote_answer.sdp.includes("a=candidate"), 88 "answer has ICE candidates" 89 ); 90 ok( 91 test._remote_answer.sdp.includes("a=end-of-candidates"), 92 "answer has end-of-candidates" 93 ); 94 }, 95 ]); 96 chain.remove("PC_LOCAL_CHECK_CAN_TRICKLE_SYNC"); 97 }