test_onGarbageCollection.html 1012 B

123456789101112131415161718192021222324252627282930313233343536
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Bug 1150253 - Sanity test for the SpiderMonkey Debugger API's onGarbageCollection hook</title>
  5. <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js">
  6. </script>
  7. </head>
  8. <body xmlns="http://www.w3.org/1999/xhtml">
  9. <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1150253"
  10. target="_blank">Mozilla Bug 1150253</a>
  11. <script type="application/javascript">
  12. SimpleTest.waitForExplicitFinish();
  13. const Cu = Components.utils;
  14. Cu.import("resource://devtools/shared/Loader.jsm");
  15. const require = devtools.require;
  16. const { gc } = Cu.getJSTestingFunctions();
  17. const Debugger = require("Debugger");
  18. const dbg = new Debugger(this);
  19. dbg.memory.onGarbageCollection = function (data) {
  20. // Don't keep calling this hook after we finish.
  21. dbg.enabled = false;
  22. ok(data, "The onGarbageCollection hook was fired.");
  23. SimpleTest.finish();
  24. };
  25. gc();
  26. </script>
  27. </body>
  28. </html>