diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /browser/components/preferences/tests/browser_bug795764_cachedisabled.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/preferences/tests/browser_bug795764_cachedisabled.js')
-rw-r--r-- | browser/components/preferences/tests/browser_bug795764_cachedisabled.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/browser/components/preferences/tests/browser_bug795764_cachedisabled.js b/browser/components/preferences/tests/browser_bug795764_cachedisabled.js new file mode 100644 index 0000000000..c454454df6 --- /dev/null +++ b/browser/components/preferences/tests/browser_bug795764_cachedisabled.js @@ -0,0 +1,66 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +const httpsOnlyVisible = SpecialPowers.getBoolPref( + "browser.preferences.exposeHTTPSOnly" +); + +function test() { + waitForExplicitFinish(); + + // Adding one fake site so that the SiteDataManager would run. + // Otherwise, without any site then it would just return so we would end up in not testing SiteDataManager. + let principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin( + "https://www.foo.com" + ); + Services.perms.addFromPrincipal( + principal, + "persistent-storage", + Ci.nsIPermissionManager.ALLOW_ACTION + ); + registerCleanupFunction(function() { + Services.perms.removeFromPrincipal(principal, "persistent-storage"); + }); + + SpecialPowers.pushPrefEnv({ + set: [["privacy.userContext.ui.enabled", true]], + }).then(() => open_preferences(runTest)); +} + +async function runTest(win) { + is(gBrowser.currentURI.spec, "about:preferences", "about:preferences loaded"); + + let tab = win.document; + let elements = tab.getElementById("mainPrefPane").children; + + // Test if privacy pane is opened correctly + await win.gotoPref("panePrivacy"); + for (let element of elements) { + let attributeValue = element.getAttribute("data-category"); + if (attributeValue == "panePrivacy") { + // HTTPS-Only Mode is exposed depending on the preference. + if (element.id == "httpsOnlyBox") { + if (httpsOnlyVisible) { + is_element_visible(element, "HTTPSOnly should be visible"); + } else { + is_element_hidden(element, "HTTPSOnly should not be visible"); + } + continue; + } + + is_element_visible( + element, + `Privacy element of id=${element.id} should be visible` + ); + } else { + is_element_hidden( + element, + `Non-Privacy element of id=${element.id} should be hidden` + ); + } + } + + gBrowser.removeCurrentTab(); + win.close(); + finish(); +} |