diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /browser/extensions/webcompat/tests/browser/browser_shims.js | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/extensions/webcompat/tests/browser/browser_shims.js')
-rw-r--r-- | browser/extensions/webcompat/tests/browser/browser_shims.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/browser/extensions/webcompat/tests/browser/browser_shims.js b/browser/extensions/webcompat/tests/browser/browser_shims.js new file mode 100644 index 0000000000..4de900a4c6 --- /dev/null +++ b/browser/extensions/webcompat/tests/browser/browser_shims.js @@ -0,0 +1,73 @@ +"use strict"; + +registerCleanupFunction(() => { + UrlClassifierTestUtils.cleanupTestTrackers(); + Services.prefs.clearUserPref(TRACKING_PREF); +}); + +add_setup(async function () { + await UrlClassifierTestUtils.addTestTrackers(); +}); + +add_task(async function test_shim_disabled_by_own_pref() { + // Test that a shim will not apply if disabled in about:config + + Services.prefs.setBoolPref(DISABLE_SHIM1_PREF, true); + Services.prefs.setBoolPref(TRACKING_PREF, true); + + await testShimDoesNotRun(); + + Services.prefs.clearUserPref(DISABLE_SHIM1_PREF); + Services.prefs.clearUserPref(TRACKING_PREF); +}); + +add_task(async function test_shim_disabled_by_global_pref() { + // Test that a shim will not apply if disabled in about:config + + Services.prefs.setBoolPref(GLOBAL_PREF, false); + Services.prefs.setBoolPref(DISABLE_SHIM1_PREF, false); + Services.prefs.setBoolPref(TRACKING_PREF, true); + + await testShimDoesNotRun(); + + Services.prefs.clearUserPref(GLOBAL_PREF); + Services.prefs.clearUserPref(DISABLE_SHIM1_PREF); + Services.prefs.clearUserPref(TRACKING_PREF); +}); + +add_task(async function test_shim_disabled_hosts_notHosts() { + Services.prefs.setBoolPref(TRACKING_PREF, true); + + await testShimDoesNotRun(false, SHIMMABLE_TEST_PAGE_3); + + Services.prefs.clearUserPref(TRACKING_PREF); +}); + +add_task(async function test_shim_disabled_overridden_by_pref() { + Services.prefs.setBoolPref(TRACKING_PREF, true); + + await testShimDoesNotRun(false, SHIMMABLE_TEST_PAGE_2); + + Services.prefs.setBoolPref(DISABLE_SHIM2_PREF, false); + + await testShimRuns(SHIMMABLE_TEST_PAGE_2); + + Services.prefs.clearUserPref(TRACKING_PREF); + Services.prefs.clearUserPref(DISABLE_SHIM2_PREF); +}); + +add_task(async function test_shim() { + // Test that a shim which only runs in strict mode works, and that it + // is permitted to opt into showing normally-blocked tracking content. + + Services.prefs.setBoolPref(TRACKING_PREF, true); + + await testShimRuns(SHIMMABLE_TEST_PAGE); + + // test that if the user opts in on one domain, they will still have to opt + // in on another domain which embeds an iframe to the first one. + + await testShimRuns(EMBEDDING_TEST_PAGE, 0, false, false); + + Services.prefs.clearUserPref(TRACKING_PREF); +}); |