1
0
Fork 0
firefox/browser/extensions/newtab/test/xpcshell/test_AboutHomeStartupCacheChild.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

33 lines
1 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { AboutHomeStartupCacheChild } = ChromeUtils.importESModule(
"resource:///modules/AboutNewTabRedirector.sys.mjs"
);
/**
* Tests that AboutHomeStartupCacheChild will terminate its PromiseWorker
* on memory-pressure, and that a new PromiseWorker can then be generated on
* demand.
*/
add_task(async function test_memory_pressure() {
AboutHomeStartupCacheChild.init();
let worker = AboutHomeStartupCacheChild.getOrCreateWorker();
Assert.ok(worker, "Should have been able to get the worker.");
Assert.equal(
worker,
AboutHomeStartupCacheChild.getOrCreateWorker(),
"The worker is cached and re-usable."
);
Services.obs.notifyObservers(null, "memory-pressure", "heap-minimize");
let newWorker = AboutHomeStartupCacheChild.getOrCreateWorker();
Assert.notEqual(worker, newWorker, "Old worker should have been replaced.");
AboutHomeStartupCacheChild.uninit();
});