Bug 1547020 - Locking useDownloadDir shouldn't lock file chooser. r=jaws
authorMichael Kaply <mozilla@kaply.com>
Fri, 26 Apr 2019 19:47:08 +0000
changeset 530399 e88ce46ff45d146ead9b75b223de740d3c46c8ba
parent 530398 7d383b757d50494cb68ba7b1129d6457765a3314
child 530400 d29767eb72476134b304e13e3076d0120709f69c
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1547020
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1547020 - Locking useDownloadDir shouldn't lock file chooser. r=jaws Differential Revision: https://phabricator.services.mozilla.com/D28874
browser/components/preferences/in-content/main.js
browser/components/preferences/in-content/tests/browser.ini
browser/components/preferences/in-content/tests/browser_bug1547020_lockedDownloadDir.js
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -2198,19 +2198,21 @@ var gMainPane = {
 
   /**
    * Enables/disables the folder field and Browse button based on whether a
    * default download directory is being used.
    */
   readUseDownloadDir() {
     var downloadFolder = document.getElementById("downloadFolder");
     var chooseFolder = document.getElementById("chooseFolder");
-    var preference = Preferences.get("browser.download.useDownloadDir");
-    downloadFolder.disabled = !preference.value || preference.locked;
-    chooseFolder.disabled = !preference.value || preference.locked;
+    var useDownloadDirPreference = Preferences.get("browser.download.useDownloadDir");
+    var dirPreference = Preferences.get("browser.download.dir");
+
+    downloadFolder.disabled = !useDownloadDirPreference.value || dirPreference.locked;
+    chooseFolder.disabled = !useDownloadDirPreference.value || dirPreference.locked;
 
     this.readCloudStorage().catch(Cu.reportError);
     // don't override the preference's value in UI
     return undefined;
   },
 
   /**
    * Show/Hide the cloud storage radio button with provider name as label if
--- a/browser/components/preferences/in-content/tests/browser.ini
+++ b/browser/components/preferences/in-content/tests/browser.ini
@@ -30,16 +30,17 @@ skip-if = (os == 'win' && (processor == 
 [browser_search_subdialogs_within_preferences_8.js]
 [browser_search_subdialogs_within_preferences_site_data.js]
 [browser_bug795764_cachedisabled.js]
 [browser_bug1018066_resetScrollPosition.js]
 [browser_bug1020245_openPreferences_to_paneContent.js]
 [browser_bug1184989_prevent_scrolling_when_preferences_flipped.js]
 support-files =
   browser_bug1184989_prevent_scrolling_when_preferences_flipped.xul
+[browser_bug1547020_lockedDownloadDir.js]
 [browser_cookie_exceptions_addRemove.js]
 [browser_cert_export.js]
 [browser_engines.js]
 [browser_change_app_handler.js]
 skip-if = os != "win" # Windows-specific handler application selection dialog
 [browser_checkspelling.js]
 [browser_cloud_storage.js]
 [browser_connection.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/preferences/in-content/tests/browser_bug1547020_lockedDownloadDir.js
@@ -0,0 +1,20 @@
+/* Any copyright is dedicated to the Public Domain.
+* http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function() {
+  Services.prefs.lockPref("browser.download.useDownloadDir");
+
+  await openPreferencesViaOpenPreferencesAPI("general", { leaveOpen: true });
+  let doc = gBrowser.selectedBrowser.contentDocument;
+
+  var downloadFolder = doc.getElementById("downloadFolder");
+  var chooseFolder = doc.getElementById("chooseFolder");
+  is(downloadFolder.disabled, false, "Download folder field should not be disabled.");
+  is(chooseFolder.disabled, false, "Choose folder should not be disabled.");
+
+  gBrowser.removeCurrentTab();
+
+  Services.prefs.unlockPref("browser.download.useDownloadDir");
+});