| <title>HTMLMediaElement GC</title> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script src="../../resources/gc.js"></script> |
| async function createMediaElement(setToNull) |
| const video = document.createElement('video'); |
| stream = await navigator.mediaDevices.getUserMedia({audio:true}); |
| video.srcObject = stream; |
| video.onclick = () => { }; |
| await video.play().then(() => { }, () => { }); |
| await new Promise(resolve => setTimeout(resolve, 0)); |
| promise_test(async (test) => { |
| await createMediaElement(false); |
| assert_equals(internals.mediaElementCount, 1); |
| }, "Keep alive a video element with a live srcObject"); |
| promise_test(async (test) => { |
| await createMediaElement(true); |
| while (++counter < 100 && internals.mediaElementCount !== 1) { |
| await new Promise(resolve => setTimeout(resolve, 50)); |
| assert_true(counter < 100); |
| }, "GC a video element with a live srcObject, then srcObject set to null"); |