Source code

Revision control

Other Tools

Test Info:

<!--
Any copyright is dedicated to the Public Domain.
-->
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 1450271 - Test MediaQueryList event listener leak conditions</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/dom/events/test/event_leak_utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<script class="testbody" type="text/javascript">
// Manipulate MediaQueryList. Its important here that we create a
// listener callback from the DOM objects back to the frame's global
// in order to exercise the leak condition.
async function useMediaQuery(contentWindow) {
contentWindow.messageCount = 0;
let mql = contentWindow.matchMedia("(max-width: 600px)");
mql.onchange = _ => {
contentWindow.mediaCount += 1;
};
}
async function runTest() {
try {
await checkForEventListenerLeaks("MediaQueryList", useMediaQuery);
} catch (e) {
ok(false, e);
} finally {
SimpleTest.finish();
}
}
SimpleTest.waitForExplicitFinish();
addEventListener("load", runTest, { once: true });
</script>
</pre>
</body>
</html>