Commit 1e222b2b authored by Michael Kaply's avatar Michael Kaply
Browse files

Bug 1558499 - DownloadDirectory policy should prevent selecting "ask every time" r=jaws

Differential Revision: https://phabricator.services.mozilla.com/D34585

--HG--
extra : moz-landing-system : lando
parent f1e14435
......@@ -512,6 +512,9 @@ var Policies = {
setAndLockPref("browser.download.dir", replacePathVariables(param));
// If a custom download directory is being used, just lock folder list to 2.
setAndLockPref("browser.download.folderList", 2);
// Per Chrome spec, user can't choose to download every time
// if this is set.
setAndLockPref("browser.download.useDownloadDir", true);
},
},
......
......@@ -6,7 +6,7 @@
ChromeUtils.defineModuleGetter(this, "FileUtils",
"resource://gre/modules/FileUtils.jsm");
add_task(async function test_notice_in_aboutprefences() {
add_task(async function test_defaultdownload() {
await setupPolicyEngineWithJson({
"policies": {
"DefaultDownloadDirectory": "${home}/Downloads",
......@@ -24,3 +24,23 @@ add_task(async function test_notice_in_aboutprefences() {
is(Services.prefs.prefIsLocked("browser.download.useDownloadDir"), true, "browser.download.useDownloadDir should be locked.");
});
});
add_task(async function test_download() {
await setupPolicyEngineWithJson({
"policies": {
"DownloadDirectory": "${home}/Documents",
},
});
await BrowserTestUtils.withNewTab("about:preferences", async browser => {
is(browser.contentDocument.getElementById("alwaysAsk").disabled, true, "alwaysAsk should be disabled.");
is(browser.contentDocument.getElementById("saveTo").selected, true, "saveTo should be selected.");
is(browser.contentDocument.getElementById("saveTo").disabled, true, "saveTo should be disabled.");
is(browser.contentDocument.getElementById("downloadFolder").disabled, true, "downloadFolder should be disabled.");
is(browser.contentDocument.getElementById("chooseFolder").disabled, true, "chooseFolder should be disabled.");
let home = FileUtils.getFile("Home", []).path;
is(Services.prefs.getStringPref("browser.download.dir"), home + "/Documents", "browser.download.dir should be ${home}/Documents.");
is(Services.prefs.getBoolPref("browser.download.useDownloadDir"), true, "browser.download.useDownloadDir should be true.");
is(Services.prefs.prefIsLocked("browser.download.useDownloadDir"), true, "browser.download.useDownloadDir should be locked.");
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment