Bug 1194258 - Make sure tracking protection section is hidden in Control Center when it's preffed off. r=paolo, a=sledru
authorBrian Grinstead <bgrinstead@mozilla.com>
Thu, 13 Aug 2015 11:28:07 -0700
changeset 288727 96e619dc79f07a6678a503a2ba2597d8ac0c2027
parent 288726 129a17d4e2a40252bb86af441f0cc720c14bee0f
child 288728 f4e43d7abccdd486098a2f577fd753c2d517116c
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaolo, sledru
bugs1194258
milestone42.0a2
Bug 1194258 - Make sure tracking protection section is hidden in Control Center when it's preffed off. r=paolo, a=sledru
browser/base/content/test/general/browser_trackingUI_2.js
browser/themes/shared/controlcenter/panel.inc.css
--- a/browser/base/content/test/general/browser_trackingUI_2.js
+++ b/browser/base/content/test/general/browser_trackingUI_2.js
@@ -19,60 +19,78 @@ registerCleanupFunction(function() {
   UrlClassifierTestUtils.cleanupTestTrackers();
   Services.prefs.clearUserPref(PREF);
   Services.prefs.clearUserPref(PB_PREF);
   while (gBrowser.tabs.length > 1) {
     gBrowser.removeCurrentTab();
   }
 });
 
+function hidden(el) {
+  let win = el.ownerDocument.defaultView;
+  let display = win.getComputedStyle(el).getPropertyValue("display", null);
+  let opacity = win.getComputedStyle(el).getPropertyValue("opacity", null);
+
+  return display === "none" || opacity === "0";
+}
+
 add_task(function* testNormalBrowsing() {
   yield UrlClassifierTestUtils.addTestTrackers();
 
   tabbrowser = gBrowser;
+  let {gIdentityHandler} = tabbrowser.ownerGlobal;
   let tab = tabbrowser.selectedTab = tabbrowser.addTab();
 
   TrackingProtection = tabbrowser.ownerGlobal.TrackingProtection;
   ok(TrackingProtection, "TP is attached to the browser window");
   is(TrackingProtection.enabled, Services.prefs.getBoolPref(PREF),
     "TP.enabled is based on the original pref value");
 
   Services.prefs.setBoolPref(PREF, true);
   ok(TrackingProtection.enabled, "TP is enabled after setting the pref");
 
   Services.prefs.setBoolPref(PREF, false);
   ok(!TrackingProtection.enabled, "TP is disabled after setting the pref");
 
   info("Load a test page containing tracking elements");
   yield promiseTabLoadEvent(tab, TRACKING_PAGE);
-  ok(TrackingProtection.container.hidden, "The container is hidden");
+  gIdentityHandler._identityBox.click();
+  ok(hidden(TrackingProtection.container), "The container is hidden");
+  gIdentityHandler._identityPopup.hidden = true;
 
   info("Load a test page not containing tracking elements");
   yield promiseTabLoadEvent(tab, BENIGN_PAGE);
-  ok(TrackingProtection.container.hidden, "The container is hidden");
+  gIdentityHandler._identityBox.click();
+  ok(hidden(TrackingProtection.container), "The container is hidden");
+  gIdentityHandler._identityPopup.hidden = true;
 });
 
 add_task(function* testPrivateBrowsing() {
   let privateWin = yield promiseOpenAndLoadWindow({private: true}, true);
   tabbrowser = privateWin.gBrowser;
+  let {gIdentityHandler} = tabbrowser.ownerGlobal;
   let tab = tabbrowser.selectedTab = tabbrowser.addTab();
 
   TrackingProtection = tabbrowser.ownerGlobal.TrackingProtection;
   ok(TrackingProtection, "TP is attached to the private window");
   is(TrackingProtection.enabled, Services.prefs.getBoolPref(PB_PREF),
     "TP.enabled is based on the pb pref value");
 
   Services.prefs.setBoolPref(PB_PREF, true);
   ok(TrackingProtection.enabled, "TP is enabled after setting the pref");
 
   Services.prefs.setBoolPref(PB_PREF, false);
   ok(!TrackingProtection.enabled, "TP is disabled after setting the pref");
 
   info("Load a test page containing tracking elements");
   yield promiseTabLoadEvent(tab, TRACKING_PAGE);
-  ok(TrackingProtection.container.hidden, "The container is hidden");
+  gIdentityHandler._identityBox.click();
+  ok(hidden(TrackingProtection.container), "The container is hidden");
+  gIdentityHandler._identityPopup.hidden = true;
 
   info("Load a test page not containing tracking elements");
+  gIdentityHandler._identityBox.click();
   yield promiseTabLoadEvent(tab, BENIGN_PAGE);
-  ok(TrackingProtection.container.hidden, "The container is hidden");
+  ok(hidden(TrackingProtection.container), "The container is hidden");
+  gIdentityHandler._identityPopup.hidden = true;
 
   privateWin.close();
 });
--- a/browser/themes/shared/controlcenter/panel.inc.css
+++ b/browser/themes/shared/controlcenter/panel.inc.css
@@ -30,16 +30,22 @@
 
 /* Hide 'not secure' message in subview when weak cipher or mixed content messages are shown. */
 #identity-popup-securityView-body:-moz-any([mixedcontent],[ciphers]) > description[when-connection=not-secure],
 /* Hide 'passive-loaded (only)' message when there is mixed passive content loaded and active blocked. */
 #identity-popup-securityView-body[mixedcontent~=passive-loaded][mixedcontent~=active-blocked] > description[when-mixedcontent=passive-loaded] {
   display: none;
 }
 
+/* Make sure hidden elements don't accidentally become visible from one of the
+   above selectors (see Bug 1194258) */
+#identity-popup [hidden] {
+  display: none !important;
+}
+
 #identity-popup,
 #identity-popup:not([panelopen]) .panel-viewstack[viewtype="main"]:not([transitioning]) #identity-popup-mainView {
   /* Tiny hack to ensure the panel shrinks back to its original
      size after closing a subview that is bigger than the main view. */
   max-height: 0;
 }
 
 .panel-mainview[panelid=identity-popup][viewtype=subview] > #identity-popup-mainView menulist,