<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/test-only-api.js"></script>
<script src="/battery-status/resources/battery-status-helpers.js"></script>
</head>
<body>
<script>
battery_status_test(async (t, mockBatteryMonitor) => {
mockBatteryMonitor.setBatteryStatus(false, 10, 20, 0.5);
let battery = await navigator.getBattery();
const newLevel = 0.6;
const levelChange =
new Promise(resolve => battery.addEventListener('levelchange', resolve));
battery = null;
gc();
mockBatteryMonitor.setBatteryStatus(false, 10, 20, newLevel);
await levelChange;
}, 'BatteryManager object is not garbage-collected with listeners attached');
</script>
</body>
</html>