dom/abort/tests/test_event_listener_leaks.html
author Rob Wood <rwood@mozilla.com>
Tue, 25 Jun 2019 08:28:58 +0000
changeset 480057 d5b60a2a9cd9ebebe089503474ace5dd2c2eaf9a
parent 469641 ba6f655fd68963530c866d0d4a48c3db3d307777
permissions -rw-r--r--
Bug 1546661 - Enable cold page loads tests for Reference Browser on Try r=perftest-reviewers,Bebe,sparky Differential Revision: https://phabricator.services.mozilla.com/D35568

<!--
  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 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">
/* import-globals-from ../../events/test/event_leak_utils.js */

// 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>