Bug 1917375 - Add tests verifying background tasks inherit and override prefs from Firefox and Gecko correctly. r=nalexander

Differential Revision: https://phabricator.services.mozilla.com/D221277
This commit is contained in:
Nicholas Rishel 2024-09-10 19:29:30 +00:00
Родитель be19170b78
Коммит 4bd881078b
6 изменённых файлов: 93 добавлений и 0 удалений

Просмотреть файл

@ -203,6 +203,13 @@ pref("app.update.langpack.enabled", true);
// The amount of time, in seconds, before background tasks time out and exit.
// Tasks can override this default (10 minutes).
pref("toolkit.backgroundtasks.defaultTimeoutSec", 600);
#if defined(ENABLE_TESTS)
// Test prefs to verify background tasks inheret and override browser prefs
// correctly.
pref("toolkit.backgroundtasks.tests.browserPrefsInherited", 15);
pref("toolkit.backgroundtasks.tests.browserPrefsOverriden", 16);
#endif
#endif
// Symmetric (can be overridden by individual extensions) update preferences.

Просмотреть файл

@ -4187,3 +4187,10 @@ pref("extensions.webcompat.useScriptingAPI", true);
pref("privacy.fingerprintingProtection.WebCompatService.logLevel", "Error");
// To test strip on share site specific parameters by enabling a different list to be used
pref("privacy.query_stripping.strip_on_share.enableTestMode", false);
#if defined(MOZ_BACKGROUNDTASKS) && defined(ENABLE_TESTS)
// Test prefs to verify background tasks inheret and override gecko prefs
// correctly.
pref("toolkit.backgroundtasks.tests.geckoPrefsInherited", 17);
pref("toolkit.backgroundtasks.tests.geckoPrefsOverriden", 18);
#endif

Просмотреть файл

@ -54,3 +54,8 @@ pref("app.update.background.automaticRestartEnabled", true);
#else
pref("app.update.background.automaticRestartEnabled", false);
#endif
#if defined(ENABLE_TESTS)
// Test prefs to verify background tasks override gecko prefs correctly.
pref("toolkit.backgroundtasks.tests.geckoPrefsOverriden", 28);
#endif

Просмотреть файл

@ -45,3 +45,8 @@ pref("app.normandy.run_interval_seconds", 0);
// Use a separate Nimbus application ID from regular Firefox Desktop.
// This prevents enrolling in regular desktop experiments.
pref("nimbus.appId", "firefox-desktop-background-task");
#if defined(ENABLE_TESTS)
// Test prefs to verify background tasks override browser prefs correctly.
pref("toolkit.backgroundtasks.tests.browserPrefsOverriden", 26);
#endif

Просмотреть файл

@ -3,6 +3,7 @@ skip-if = ["os == 'android'"]
head = "head.js"
["browser_backgroundtask_specific_pref.js"]
run-if = ["appname == 'firefox'"] # Prefs are Firefox specific, e.g. not Thunderbird
["browser_xpcom_graph_wait.js"]
skip-if = ["tsan"] # TSan times out on pretty much all profiler-consuming tests.

Просмотреть файл

@ -21,3 +21,71 @@ add_task(async function test_backgroundtask_specific_pref() {
});
Assert.equal(79, exitCode);
});
add_task(async function test_backgroundtask_browser_pref_inherited() {
// First, verify this pref is set in Firefox.
Assert.equal(
15,
Services.prefs.getIntPref(
"toolkit.backgroundtasks.tests.browserPrefsInherited",
-1
)
);
// Second, verify that this pref is set in background tasks.
let exitCode = await do_backgroundtask("backgroundtask_specific_pref", {
extraArgs: ["toolkit.backgroundtasks.tests.browserPrefsInherited"],
});
Assert.equal(15, exitCode);
});
add_task(async function test_backgroundtask_gecko_pref_overridden() {
// First, verify this pref is set in Firefox.
Assert.equal(
16,
Services.prefs.getIntPref(
"toolkit.backgroundtasks.tests.browserPrefsOverriden",
-1
)
);
// Second, verify that this pref is overridden in background tasks.
let exitCode = await do_backgroundtask("backgroundtask_specific_pref", {
extraArgs: ["toolkit.backgroundtasks.tests.browserPrefsOverriden"],
});
Assert.equal(26, exitCode);
});
add_task(async function test_backgroundtask_gecko_pref_inherited() {
// First, verify this pref is set in Gecko.
Assert.equal(
17,
Services.prefs.getIntPref(
"toolkit.backgroundtasks.tests.geckoPrefsInherited",
-1
)
);
// Second, verify that this pref is set in background tasks.
let exitCode = await do_backgroundtask("backgroundtask_specific_pref", {
extraArgs: ["toolkit.backgroundtasks.tests.geckoPrefsInherited"],
});
Assert.equal(17, exitCode);
});
add_task(async function test_backgroundtask_gecko_pref_overridden() {
// First, verify this pref is set in Gecko.
Assert.equal(
18,
Services.prefs.getIntPref(
"toolkit.backgroundtasks.tests.geckoPrefsOverriden",
-1
)
);
// Second, verify that this pref is overridden in background tasks.
let exitCode = await do_backgroundtask("backgroundtask_specific_pref", {
extraArgs: ["toolkit.backgroundtasks.tests.geckoPrefsOverriden"],
});
Assert.equal(28, exitCode);
});