test_AboutHomeStartupCacheChild.js (1024B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const { AboutHomeStartupCacheChild } = ChromeUtils.importESModule( 7 "resource:///modules/AboutNewTabRedirector.sys.mjs" 8 ); 9 10 /** 11 * Tests that AboutHomeStartupCacheChild will terminate its PromiseWorker 12 * on memory-pressure, and that a new PromiseWorker can then be generated on 13 * demand. 14 */ 15 add_task(async function test_memory_pressure() { 16 AboutHomeStartupCacheChild.init(); 17 18 let worker = AboutHomeStartupCacheChild.getOrCreateWorker(); 19 Assert.ok(worker, "Should have been able to get the worker."); 20 21 Assert.equal( 22 worker, 23 AboutHomeStartupCacheChild.getOrCreateWorker(), 24 "The worker is cached and re-usable." 25 ); 26 27 Services.obs.notifyObservers(null, "memory-pressure", "heap-minimize"); 28 29 let newWorker = AboutHomeStartupCacheChild.getOrCreateWorker(); 30 Assert.notEqual(worker, newWorker, "Old worker should have been replaced."); 31 32 AboutHomeStartupCacheChild.uninit(); 33 });