| youennf | adc0811 | 2019-01-17 15:55:21 | [diff] [blame^] | 1 | <!doctype html> | 
|  | 2 | <meta charset=utf-8> | 
|  | 3 | <title>RTCRtpTransceiver.prototype.stop</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 | // FIXME: Add a test adding a transceiver, stopping it and trying to create an empty offer. | 
|  | 9 |  | 
|  | 10 | promise_test(async (t)=> { | 
|  | 11 | const pc1 = new RTCPeerConnection(); | 
|  | 12 | t.add_cleanup(() => pc1.close()); | 
|  | 13 |  | 
|  | 14 | pc1.addTransceiver("audio", { direction: "sendonly" }); | 
|  | 15 | pc1.addTransceiver("video"); | 
|  | 16 | pc1.getTransceivers()[0].stop(); | 
|  | 17 |  | 
|  | 18 | const offer = await pc1.createOffer(); | 
|  | 19 |  | 
|  | 20 | assert_false(offer.sdp.includes("m=audio"), "offer should not contain an audio m-section"); | 
|  | 21 | assert_true(offer.sdp.includes("m=video"), "offer should contain a video m-section"); | 
|  | 22 | }, "A transceiver added and stopped before the initial offer generation should not trigger an offer m-section generation"); | 
|  | 23 |  | 
|  | 24 | promise_test(async (t)=> { | 
|  | 25 | const pc1 = new RTCPeerConnection(); | 
|  | 26 | const pc2 = new RTCPeerConnection(); | 
|  | 27 | t.add_cleanup(() => pc1.close()); | 
|  | 28 | t.add_cleanup(() => pc2.close()); | 
|  | 29 |  | 
|  | 30 | pc1.addTransceiver("audio"); | 
|  | 31 |  | 
|  | 32 | await exchangeOfferAnswer(pc1, pc2); | 
|  | 33 |  | 
|  | 34 | pc1.addTransceiver("video"); | 
|  | 35 |  | 
|  | 36 | pc1.getTransceivers()[0].stop(); | 
|  | 37 | pc1.getTransceivers()[1].stop(); | 
|  | 38 |  | 
|  | 39 | const offer = await pc1.createOffer(); | 
|  | 40 |  | 
|  | 41 | assert_true(offer.sdp.includes("m=audio"), "offer should contain an audio m-section"); | 
|  | 42 | assert_true(offer.sdp.includes("m=audio 0"), "The audio m-section should be rejected"); | 
|  | 43 |  | 
|  | 44 | assert_false(offer.sdp.includes("m=video"), "offer should not contain a video m-section"); | 
|  | 45 | }, "During renegotiation, adding and stopping a transceiver should not trigger a renegotiated offer m-section generation"); | 
|  | 46 |  | 
|  | 47 | promise_test(async (t)=> { | 
|  | 48 | const pc1 = new RTCPeerConnection(); | 
|  | 49 | const pc2 = new RTCPeerConnection(); | 
|  | 50 | t.add_cleanup(() => pc1.close()); | 
|  | 51 | t.add_cleanup(() => pc2.close()); | 
|  | 52 |  | 
|  | 53 | pc1.addTransceiver("audio"); | 
|  | 54 |  | 
|  | 55 | await exchangeOfferAnswer(pc1, pc2); | 
|  | 56 |  | 
|  | 57 | pc1.getTransceivers()[0].direction = "sendonly"; | 
|  | 58 | pc1.getTransceivers()[0].stop(); | 
|  | 59 |  | 
|  | 60 | const offer = await pc1.createOffer(); | 
|  | 61 |  | 
|  | 62 | assert_true(offer.sdp.includes("a=sendonly"), "The audio m-section should be sendonly"); | 
|  | 63 | }, "A stopped sendonly transceiver should generate an inactive m-section in the offer"); | 
|  | 64 |  | 
|  | 65 | promise_test(async (t)=> { | 
|  | 66 | const pc1 = new RTCPeerConnection(); | 
|  | 67 | const pc2 = new RTCPeerConnection(); | 
|  | 68 | t.add_cleanup(() => pc1.close()); | 
|  | 69 | t.add_cleanup(() => pc2.close()); | 
|  | 70 |  | 
|  | 71 | pc1.addTransceiver("audio"); | 
|  | 72 |  | 
|  | 73 | await exchangeOfferAnswer(pc1, pc2); | 
|  | 74 |  | 
|  | 75 | pc1.getTransceivers()[0].direction = "inactive"; | 
|  | 76 | pc1.getTransceivers()[0].stop(); | 
|  | 77 |  | 
|  | 78 | const offer = await pc1.createOffer(); | 
|  | 79 |  | 
|  | 80 | assert_true(offer.sdp.includes("a=inactive"), "The audio m-section should be inactive"); | 
|  | 81 | }, "A stopped inactive transceiver should generate an inactive m-section in the offer"); | 
|  | 82 | </script> |