browser_shutdown_start_restart.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. 'use strict';
  5. add_task(function* () {
  6. info('Creating a service');
  7. // Create a11y service.
  8. let a11yInit = initPromise();
  9. let accService = Cc['@mozilla.org/accessibilityService;1'].getService(
  10. Ci.nsIAccessibilityService);
  11. yield a11yInit;
  12. ok(accService, 'Service initialized');
  13. info('Removing a service');
  14. // Remove the only reference to an a11y service.
  15. let a11yShutdown = shutdownPromise();
  16. accService = null;
  17. ok(!accService, 'Service is removed');
  18. // Force garbage collection that should trigger shutdown.
  19. forceGC();
  20. yield a11yShutdown;
  21. info('Recreating a service');
  22. // Re-create a11y service.
  23. a11yInit = initPromise();
  24. accService = Cc['@mozilla.org/accessibilityService;1'].getService(
  25. Ci.nsIAccessibilityService);
  26. yield a11yInit;
  27. ok(accService, 'Service initialized again');
  28. info('Removing a service again');
  29. // Remove the only reference to an a11y service again.
  30. a11yShutdown = shutdownPromise();
  31. accService = null;
  32. ok(!accService, 'Service is removed again');
  33. // Force garbage collection that should trigger shutdown.
  34. forceGC();
  35. yield a11yShutdown;
  36. });