Bug 1450358 P2 Test AbortSignal for event listener related runtime leaks. r=baku

This commit is contained in:
Ben Kelly 2018-04-04 11:25:42 -07:00
parent 720c0d53fb
commit 0b6897561a
2 changed files with 45 additions and 0 deletions

View File

@ -2,6 +2,8 @@
support-files =
worker_abort_controller_fetch.js
slow.sjs
!/dom/events/test/event_leak_utils.js
[test_abort_controller.html]
[test_abort_controller_fetch.html]
[test_event_listener_leaks.html]

View File

@ -0,0 +1,43 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 1450271 - Test AbortSignal event listener leak conditions</title>
<script type="text/javascript" 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>
<p id="display"></p>
<script class="testbody" type="text/javascript">
// Manipulate AbortSignal. 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 useAbortSignal(contentWindow) {
let controller = new contentWindow.AbortController();
let signal = controller.signal;
signal.onabort = _ => {
contentWindow.abortCount += 1;
};
}
async function runTest() {
try {
await checkForEventListenerLeaks("AbortSignal", useAbortSignal);
} catch (e) {
ok(false, e);
} finally {
SimpleTest.finish();
}
}
SimpleTest.waitForExplicitFinish();
addEventListener("load", runTest, { once: true });
</script>
</pre>
</body>
</html>