browser_shutdown_start_restart.js (1558B)
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 5 "use strict"; 6 7 add_task(async function () { 8 info("Creating a service"); 9 // Create a11y service. 10 let [a11yInitObserver, a11yInit] = initAccService(); 11 await a11yInitObserver; 12 13 let accService = Cc["@mozilla.org/accessibilityService;1"].getService( 14 Ci.nsIAccessibilityService 15 ); 16 await a11yInit; 17 ok(accService, "Service initialized"); 18 19 info("Removing a service"); 20 // Remove the only reference to an a11y service. 21 let [a11yShutdownObserver, a11yShutdown] = shutdownAccService(); 22 await a11yShutdownObserver; 23 24 accService = null; 25 ok(!accService, "Service is removed"); 26 // Force garbage collection that should trigger shutdown. 27 forceGC(); 28 await a11yShutdown; 29 30 info("Recreating a service"); 31 // Re-create a11y service. 32 [a11yInitObserver, a11yInit] = initAccService(); 33 await a11yInitObserver; 34 35 accService = Cc["@mozilla.org/accessibilityService;1"].getService( 36 Ci.nsIAccessibilityService 37 ); 38 await a11yInit; 39 ok(accService, "Service initialized again"); 40 41 info("Removing a service again"); 42 // Remove the only reference to an a11y service again. 43 [a11yShutdownObserver, a11yShutdown] = shutdownAccService(); 44 await a11yShutdownObserver; 45 46 accService = null; 47 ok(!accService, "Service is removed again"); 48 // Force garbage collection that should trigger shutdown. 49 forceGC(); 50 await a11yShutdown; 51 });