Bug 1659335 - Do not disable the cookie exceptions button when accept cookies is unchecked. r=mkmelin DONTBUILD
authorLasana Murray <lasana@thunderbird.net>
Mon, 31 Aug 2020 13:50:38 +0300
changeset 30505 d44db91db09e2e8144c479051f450bf334616a99
parent 30504 174af2bfd6fd39c1820d75b0a1e8caca3c41a7f5
child 30506 05079d473898b094bab2c1f48295f16b5db43cb1
push id17908
push usermkmelin@iki.fi
push dateMon, 31 Aug 2020 10:51:51 +0000
treeherdercomm-central@d44db91db09e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1659335
Bug 1659335 - Do not disable the cookie exceptions button when accept cookies is unchecked. r=mkmelin DONTBUILD
mail/components/enterprisepolicies/tests/browser/browser_policy_cookie_settings.js
mail/components/preferences/privacy.js
mail/components/preferences/test/browser/browser_privacy.js
mail/components/preferences/test/browser/head.js
--- a/mail/components/enterprisepolicies/tests/browser/browser_policy_cookie_settings.js
+++ b/mail/components/enterprisepolicies/tests/browser/browser_policy_cookie_settings.js
@@ -131,28 +131,30 @@ async function test_cookie_settings({
 
   for (let id of ["acceptCookies", "showCookiesButton"]) {
     is(
       contentDocument.getElementById(id).disabled,
       cookieJarSettingsLocked,
       `#${id} disabled status should match expected`
     );
   }
-  for (let id of [
-    "cookieExceptions",
-    "acceptThirdPartyMenu",
-    "keepCookiesUntil",
-  ]) {
+  for (let id of ["acceptThirdPartyMenu", "keepCookiesUntil"]) {
     is(
       contentDocument.getElementById(id).disabled,
       expectControlsDisabled,
       `#${id} disabled status should match expected`
     );
   }
 
+  is(
+    contentDocument.getElementById("cookieExceptions").disabled,
+    cookieJarSettingsLocked,
+    "#cookieExceptions disabled status should matched expected"
+  );
+
   let tabmail = document.getElementById("tabmail");
   tabmail.closeTab(window.gPrefTab);
 }
 
 add_task(async function prepare_tracker_tables() {
   await UrlClassifierTestUtils.addTestTrackers();
 });
 
--- a/mail/components/preferences/privacy.js
+++ b/mail/components/preferences/privacy.js
@@ -159,17 +159,17 @@ var gPrivacyPane = {
     let acceptCookies = pref.value != 2;
     let cookieBehaviorLocked = Services.prefs.prefIsLocked(
       "network.cookie.cookieBehavior"
     );
     let cookieExpirationLocked = Services.prefs.prefIsLocked(
       "network.cookie.lifetimePolicy"
     );
 
-    exceptionsButton.disabled = !acceptCookies || cookieBehaviorLocked;
+    exceptionsButton.disabled = cookieBehaviorLocked;
     acceptThirdPartyLabel.disabled = acceptThirdPartyMenu.disabled =
       !acceptCookies || cookieBehaviorLocked;
     keepUntil.disabled = menu.disabled =
       !acceptCookies || cookieBehaviorLocked || cookieExpirationLocked;
     showCookiesButton.disabled = cookieBehaviorLocked;
 
     return acceptCookies;
   },
--- a/mail/components/preferences/test/browser/browser_privacy.js
+++ b/mail/components/preferences/test/browser/browser_privacy.js
@@ -15,16 +15,17 @@ add_task(async () => {
       checkboxID: "keepHistory",
       pref: "places.history.enabled",
     },
     {
       checkboxID: "acceptCookies",
       pref: "network.cookie.cookieBehavior",
       prefValues: [2, 0],
       enabledElements: ["#acceptThirdPartyMenu", "#keepCookiesUntil"],
+      unaffectedElements: ["#cookieExceptions"],
     },
     {
       checkboxID: "privacyDoNotTrackCheckbox",
       pref: "privacy.donottrackheader.enabled",
     }
   );
 });
 
--- a/mail/components/preferences/test/browser/head.js
+++ b/mail/components/preferences/test/browser/head.js
@@ -100,16 +100,18 @@ async function closePrefsTab() {
  *
  * Each of the tests arguments is an object describing a test, containing:
  *   checkboxID - the ID of the checkbox to test
  *   pref - the name of a preference,
  *   prefValues - an array of two values: pref value when not checked, pref value when checked
  *                (optional, defaults to [false, true])
  *   enabledElements - an array of CSS selectors (optional)
  *   enabledInverted - if the elements should be disabled when the checkbox is checked (optional)
+ *   unaffectedElements - array of CSS selectors that should not be affected by
+ *                        the toggling of the checkbox.
  */
 async function testCheckboxes(paneID, scrollPaneTo, ...tests) {
   for (let initiallyChecked of [true, false]) {
     info(`Opening ${paneID} with prefs set to ${initiallyChecked}`);
 
     for (let test of tests) {
       let wantedValue = initiallyChecked;
       if (test.prefValues) {
@@ -170,28 +172,42 @@ async function testCheckboxes(paneID, sc
               !disabled,
               "Element " + (disabled ? "isn't" : "is") + " disabled"
             );
           }
         }
       }
     };
 
+    let testUnaffected = function(ids, states) {
+      ids.forEach((sel, index) => {
+        let isOk = prefsDocument.querySelector(sel).disabled === states[index];
+        is(isOk, true, `Element "${sel}" is unaffected`);
+      });
+    };
+
     for (let test of tests) {
       info(`Checking ${test.checkboxID}`);
 
+      let unaffectedSelectors = test.unaffectedElements || [];
+      let unaffectedStates = unaffectedSelectors.map(
+        sel => prefsDocument.querySelector(sel).disabled
+      );
+
       let checkbox = prefsDocument.getElementById(test.checkboxID);
       checkbox.scrollIntoView(false);
       testUIState(test, initiallyChecked);
 
       EventUtils.synthesizeMouseAtCenter(checkbox, {}, prefsWindow);
       testUIState(test, !initiallyChecked);
+      testUnaffected(unaffectedSelectors, unaffectedStates);
 
       EventUtils.synthesizeMouseAtCenter(checkbox, {}, prefsWindow);
       testUIState(test, initiallyChecked);
+      testUnaffected(unaffectedSelectors, unaffectedStates);
     }
 
     await closePrefsTab();
   }
 }
 
 /**
  * Tests a set of radio buttons is in the right state when the preferences tab opens, and when