Commit fb1ff44e authored by Harald Alvestrand's avatar Harald Alvestrand Committed by Commit Bot

Correct RTCPeerConnection garbage collection test to use async GC

The old test did not check that RTCPeerConnections were garbage collected,
due to an inverted condition, so failed to detect that synchronous GC
did not work. The new test uses asynchronous garbage collection.

Bug: 825576
Change-Id: I4a4b35c3731007153365d8b22e03fb323ea9b55c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1831807
Commit-Queue: Harald Alvestrand <hta@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701493}
parent f3137fd6
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<head> <head>
<script src="../../resources/testharness.js"></script> <script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script> <script src="../../resources/testharnessreport.js"></script>
<script src="../../resources/gc.js"></script>
</head> </head>
<body> <body>
<script> <script>
...@@ -19,16 +20,16 @@ function allocatePeerConnection() { ...@@ -19,16 +20,16 @@ function allocatePeerConnection() {
peerConnections.push(new RTCPeerConnection()); peerConnections.push(new RTCPeerConnection());
} }
function cleanUpPeerConnectionsAndGarbageCollect() { async function cleanUpPeerConnectionsAndGarbageCollect() {
// Close all peer connections so that they may be garbage collected. // Close all peer connections so that they may be garbage collected.
peerConnections.forEach(pc => { peerConnections.forEach(pc => {
pc.close(); pc.close();
}); });
peerConnections = []; peerConnections = [];
gc(); await asyncGC();
} }
test(function() { promise_test(async function() {
try { try {
// These many peer connections should be OK to allocate. // These many peer connections should be OK to allocate.
while (internals.peerConnectionCount() < while (internals.peerConnectionCount() <
...@@ -45,13 +46,13 @@ test(function() { ...@@ -45,13 +46,13 @@ test(function() {
// this test regardless of test result or unrelated tests may fail. // this test regardless of test result or unrelated tests may fail.
let totalAllocatedPeerConnections = internals.peerConnectionCount(); let totalAllocatedPeerConnections = internals.peerConnectionCount();
let peerConnectionsAllocatedByTest = peerConnections.length; let peerConnectionsAllocatedByTest = peerConnections.length;
cleanUpPeerConnectionsAndGarbageCollect(); await cleanUpPeerConnectionsAndGarbageCollect();
// We cannot assert there are no peer connections since other swarming tests // We cannot assert there are no peer connections since other swarming tests
// could have left peer connections in a non-closed state, but we can assert // could have left peer connections in a non-closed state, but we can assert
// that at least all |peerConnectionsAllocatedByTest| have been collected. // that at least all |peerConnectionsAllocatedByTest| have been collected.
assert_less_than_equal( assert_less_than_equal(
totalAllocatedPeerConnections - peerConnectionsAllocatedByTest, internals.peerConnectionCount(),
internals.peerConnectionCount()); totalAllocatedPeerConnections - peerConnectionsAllocatedByTest);
} }
}, 'Create and garbage collect many RTCPeerConnections'); }, 'Create and garbage collect many RTCPeerConnections');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment