fune/browser/components/newtab/test/xpcshell/test_AboutHomeStartupCacheChild.js
Iulian Moraru 3c09fc13df Backed out 3 changesets (bug 1780074, bug 1780347) for causing multiple failures. CLOSED TREE
Backed out changeset ee4c4d34816c (bug 1780347)
Backed out changeset a13d3939b98a (bug 1780074)
Backed out changeset 3bc739f7de43 (bug 1780074)
2022-07-20 14:57:48 +03:00

33 lines
1,009 B
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { AboutHomeStartupCacheChild } = ChromeUtils.import(
"resource:///modules/AboutNewTabService.jsm"
);
/**
* 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();
});