OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
| 5 <script src="../../resources/observeGC.js"></script> |
5 </head> | 6 </head> |
6 <body> | 7 <body> |
7 <script> | 8 <script> |
8 description("Tests the RTCPeerConnection lifetime."); | 9 description("Tests the RTCPeerConnection lifetime."); |
9 | 10 |
10 var dc = null; | 11 var dc = null; |
11 | 12 |
12 function dataChannelMessage(m) | 13 function dataChannelMessage(m) |
13 { | 14 { |
14 testPassed("dataChannelMessage"); | 15 testPassed("dataChannelMessage"); |
(...skipping 13 matching lines...) Expand all Loading... |
28 var pc = new webkitRTCPeerConnection({iceServers:[]}, null); | 29 var pc = new webkitRTCPeerConnection({iceServers:[]}, null); |
29 dc = pc.createDataChannel("label"); | 30 dc = pc.createDataChannel("label"); |
30 dc.onopen = dataChannelOpen; | 31 dc.onopen = dataChannelOpen; |
31 } | 32 } |
32 | 33 |
33 var pcB = null; | 34 var pcB = null; |
34 var observationB = null; | 35 var observationB = null; |
35 | 36 |
36 // Test that the PeerConnection object is gc'd if close is called. | 37 // Test that the PeerConnection object is gc'd if close is called. |
37 var pcA = new webkitRTCPeerConnection(null, null); | 38 var pcA = new webkitRTCPeerConnection(null, null); |
38 var observationA = internals.observeGC(pcA); | 39 var observationA = observeGC(() => {return pcA;}); |
39 pcA.close(); | 40 pcA.close(); |
40 pcA = null; | 41 pcA = null; |
41 asyncGC(function() { | 42 asyncGC(function() { |
42 shouldBeTrue('observationA.wasCollected'); | 43 shouldBeTrue('observationA.wasCollected'); |
43 observationA = null; | 44 observationA = null; |
44 | 45 |
45 // Test that the PeerConnection object is not gc'd if close is not called. | 46 // Test that the PeerConnection object is not gc'd if close is not called. |
46 pcB = new webkitRTCPeerConnection(null, null); | 47 pcB = new webkitRTCPeerConnection(null, null); |
47 observationB = internals.observeGC(pcB); | 48 observationB = observeGC(() => {return pcB;}); |
48 pcB = null; | 49 pcB = null; |
49 asyncGC(function() { | 50 asyncGC(function() { |
50 shouldBeFalse('observationB.wasCollected'); | 51 shouldBeFalse('observationB.wasCollected'); |
51 observationB = null; | 52 observationB = null; |
52 | 53 |
53 // This test times out if the Peer connection object is garbage collecte
d. | 54 // This test times out if the Peer connection object is garbage collecte
d. |
54 createPeerConnectionAndDataChannel(); | 55 createPeerConnectionAndDataChannel(); |
55 gc(); | 56 gc(); |
56 }); | 57 }); |
57 }); | 58 }); |
58 | 59 |
59 window.jsTestIsAsync = true; | 60 window.jsTestIsAsync = true; |
60 </script> | 61 </script> |
61 </body> | 62 </body> |
62 </html> | 63 </html> |
OLD | NEW |