dom/media/webaudio/test/test_event_listener_leaks.html
author ui.dev <deniskisavi@gmail.com>
Sat, 25 Mar 2023 22:34:18 +0000
changeset 657948 735b73193dc663078843621b2eeccbc2d4abe328
parent 469641 ba6f655fd68963530c866d0d4a48c3db3d307777
permissions -rw-r--r--
Bug 1823719 - Convert toolkit/components/remotebrowserutils to ES modules. r=Standard8. Differential Revision: https://phabricator.services.mozilla.com/D173631

<!--
  Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<head>
  <title>Bug 1450358 - Test AudioContext 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 AudioContext objects in the frame's context.
// 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 useAudioContext(contentWindow) {
  let ctx = new contentWindow.AudioContext();
  ctx.onstatechange = e => {
    contentWindow.stateChangeCount += 1;
  };

  let osc = ctx.createOscillator();
  osc.type = "sine";
  osc.frequency.value = 440;
  osc.start();
}

async function runTest() {
  try {
    await checkForEventListenerLeaks("AudioContext", useAudioContext);
  } catch (e) {
    ok(false, e);
  } finally {
    SimpleTest.finish();
  }
}

SimpleTest.waitForExplicitFinish();
addEventListener("load", runTest, { once: true });
</script>
</pre>
</body>
</html>