forked from mirrors/gecko-dev
This establishes a high water mark for code loaded (even after a short delay) by a background task that does nothing. Code loaded here means: 1) Chrome JSMs imported using `ChromeUtils.import`; 2) XPCOM services, generally long-lived, loaded using `do_getService` or `Services.*` or an equivalent; 3) XPCOM components defined in JavaScript and loaded via `chrome.manifest` entries. At this time background tasks do not load any of category 3. The distinction is made because they are reported separately by Gecko. This test is browser-chrome to make it easy/possible to work with packaged builds. Differential Revision: https://phabricator.services.mozilla.com/D98095
50 lines
1.6 KiB
JavaScript
50 lines
1.6 KiB
JavaScript
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
|
|
* vim: sw=4 ts=4 sts=4 et
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
add_task(async function test_manifest_with_backgroundtask() {
|
|
let bts = Cc["@mozilla.org/backgroundtasks;1"].getService(
|
|
Ci.nsIBackgroundTasks
|
|
);
|
|
|
|
Assert.equal(false, bts.isBackgroundTaskMode);
|
|
Assert.equal(null, bts.backgroundTaskName());
|
|
|
|
bts.overrideBackgroundTaskNameForTesting("test-task");
|
|
|
|
Assert.equal(true, bts.isBackgroundTaskMode);
|
|
Assert.equal("test-task", bts.backgroundTaskName());
|
|
|
|
// Load test components.
|
|
do_load_manifest("CatBackgroundTaskRegistrationComponents.manifest");
|
|
|
|
const expectedEntries = new Map([
|
|
[
|
|
"CatBackgroundTaskRegisteredComponent",
|
|
"@unit.test.com/cat-backgroundtask-registered-component;1",
|
|
],
|
|
[
|
|
"CatBackgroundTaskAlwaysRegisteredComponent",
|
|
"@unit.test.com/cat-backgroundtask-alwaysregistered-component;1",
|
|
],
|
|
]);
|
|
|
|
// Verify the correct entries are registered in the "test-cat" category.
|
|
for (let { entry, value } of Services.catMan.enumerateCategory("test-cat")) {
|
|
ok(expectedEntries.has(entry), `${entry} is expected`);
|
|
Assert.equal(
|
|
value,
|
|
expectedEntries.get(entry),
|
|
"${entry} has correct value."
|
|
);
|
|
expectedEntries.delete(entry);
|
|
}
|
|
print("Check that all of the expected entries have been deleted.");
|
|
Assert.deepEqual(
|
|
Array.from(expectedEntries.keys()),
|
|
[],
|
|
"All expected entries have been deleted."
|
|
);
|
|
});
|