Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test runs only with pattern: os != 'android'
- Manifest: browser/components/tests/unit/xpcshell.toml
/* Any copyright is dedicated to the Public Domain.
/**
* Tests that distribution customizations can be applied *after* distribution
* bookmarks have been applied, which is the ordering used by startup
*/
const { TestUtils } = ChromeUtils.importESModule(
);
const { DistributionManagement } = ChromeUtils.importESModule(
"resource:///modules/distribution.sys.mjs"
);
const TOPIC_CUSTOMIZATION_COMPLETE = "distribution-customization-complete";
const PREF_BMPROCESSED = "distribution.disttest.bookmarksProcessed";
registerCleanupFunction(async function () {
let folderPath = PathUtils.join(PathUtils.profileDir, "distribution");
await IOUtils.remove(folderPath, { ignoreAbsent: true, recursive: true });
Services.prefs.clearUserPref("distribution.testing.loadFromProfile");
});
add_setup(async function setup() {
// Set special pref to load distribution.ini from the profile folder.
Services.prefs.setBoolPref("distribution.testing.loadFromProfile", true);
// Copy distribution.ini file to the profile dir.
let distroDir = gProfD.clone();
distroDir.leafName = "distribution";
let iniFile = distroDir.clone();
iniFile.append("distribution.ini");
if (iniFile.exists()) {
iniFile.remove(false);
print("distribution.ini already exists, did some test forget to cleanup?");
}
let testDistributionFile = do_get_cwd().clone();
testDistributionFile.append("distribution.ini");
testDistributionFile.copyTo(distroDir, "distribution.ini");
Assert.ok(testDistributionFile.exists());
});
add_task(async function test_customizations_after_bookmarks() {
// Startup migration applies the distribution bookmarks first, and waits for
// them to be done, before "final-ui-startup" triggers applyCustomizations().
await DistributionManagement.applyBookmarks();
Assert.ok(
Services.prefs.getBoolPref(PREF_BMPROCESSED, false),
"Distribution bookmarks applied."
);
let customizationComplete = TestUtils.topicObserved(
TOPIC_CUSTOMIZATION_COMPLETE
);
DistributionManagement.applyCustomizations();
await customizationComplete;
let defaultBranch = Services.prefs.getDefaultBranch(null);
Assert.equal(
defaultBranch.getCharPref("distribution.id"),
"disttest",
"Distribution preferences were still applied"
);
Assert.equal(
defaultBranch.getCharPref("distribution.test.locale"),
"en-US",
"Localizable distribution preferences were still applied"
);
});