4 <script src=
"../../resources/js-test.js"></script>
8 description("Tests the RTCPeerConnection lifetime.");
12 function dataChannelMessage(m
)
14 testPassed("dataChannelMessage");
18 function dataChannelOpen()
20 testPassed("dataChannelOpen");
21 dc
.onmessage
= dataChannelMessage
;
22 shouldNotThrow("dc.send('xyzzy');");
25 function createPeerConnectionAndDataChannel()
27 // The Peer Connection object is leaked
28 var pc
= new webkitRTCPeerConnection({iceServers
:[]}, null);
29 dc
= pc
.createDataChannel("label");
30 dc
.onopen
= dataChannelOpen
;
34 var observationB
= null;
36 // Test that the PeerConnection object is gc'd if close is called.
37 var pcA
= new webkitRTCPeerConnection(null, null);
38 var observationA
= internals
.observeGC(pcA
);
42 shouldBeTrue('observationA.wasCollected');
45 // Test that the PeerConnection object is not gc'd if close is not called.
46 pcB
= new webkitRTCPeerConnection(null, null);
47 observationB
= internals
.observeGC(pcB
);
50 shouldBeFalse('observationB.wasCollected');
53 // This test times out if the Peer connection object is garbage collected.
54 createPeerConnectionAndDataChannel();
59 window
.jsTestIsAsync
= true;