Bug 1188438 - Close the control center when the user clicks the tracking protection enable/disable button r=MattN
authorTim Taubert <ttaubert@mozilla.com>
Tue, 28 Jul 2015 18:29:12 +0200
changeset 255070 130ef92fa5a74132d9d30a20bade21c5736457f5
parent 255069 4287f97ac668b4566facbd023d61049ecddbf1d7
child 255071 1efbd6874bfb965d0ba4f469529afa5e07a36f25
child 255230 62cd40885e9362dc726f681675b64aa9577982aa
push id14294
push userttaubert@mozilla.com
push dateWed, 29 Jul 2015 13:58:09 +0000
treeherderfx-team@130ef92fa5a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1188438
milestone42.0a1
Bug 1188438 - Close the control center when the user clicks the tracking protection enable/disable button r=MattN
browser/base/content/browser-trackingprotection.js
browser/base/content/test/general/browser_trackingUI_5.js
--- a/browser/base/content/browser-trackingprotection.js
+++ b/browser/base/content/browser-trackingprotection.js
@@ -121,16 +121,19 @@ let TrackingProtection = {
     } else {
       Services.perms.add(normalizedUrl,
         "trackingprotection", Services.perms.ALLOW_ACTION);
     }
 
     // Telemetry for disable protection.
     this.eventsHistogram.add(1);
 
+    // Hide the control center.
+    document.getElementById("identity-popup").hidePopup();
+
     BrowserReload();
   },
 
   enableForCurrentPage() {
     // Remove the current host from the 'trackingprotection' consumer
     // of the permission manager. This effectively removes this host
     // from the tracking protection allowlist.
     let normalizedUrl = Services.io.newURI(
@@ -141,16 +144,19 @@ let TrackingProtection = {
       PrivateBrowsingUtils.removeFromTrackingAllowlist(normalizedUrl);
     } else {
       Services.perms.remove(normalizedUrl, "trackingprotection");
     }
 
     // Telemetry for enable protection.
     this.eventsHistogram.add(2);
 
+    // Hide the control center.
+    document.getElementById("identity-popup").hidePopup();
+
     BrowserReload();
   },
 
   showIntroPanel: Task.async(function*() {
     let mm = gBrowser.selectedBrowser.messageManager;
     let brandBundle = document.getElementById("bundle_brand");
     let brandShortName = brandBundle.getString("brandShortName");
 
--- a/browser/base/content/test/general/browser_trackingUI_5.js
+++ b/browser/base/content/test/general/browser_trackingUI_5.js
@@ -17,16 +17,21 @@ registerCleanupFunction(function() {
 
 function hidden(sel) {
   let win = browser.ownerGlobal;
   let el = win.document.querySelector(sel);
   let display = win.getComputedStyle(el).getPropertyValue("display", null);
   return display === "none";
 }
 
+function identityPopupState() {
+  let win = browser.ownerGlobal;
+  return win.document.getElementById("identity-popup").state;
+}
+
 function clickButton(sel) {
   let win = browser.ownerGlobal;
   let el = win.document.querySelector(sel);
   el.doCommand();
 }
 
 function testTrackingPage(window) {
   info("Tracking content must be blocked");
@@ -80,16 +85,18 @@ add_task(function* testExceptionAddition
   info("Load a test page containing tracking elements");
   yield promiseTabLoadEvent(tab, TRACKING_PAGE);
 
   testTrackingPage(tab.ownerDocument.defaultView);
 
   info("Disable TP for the page (which reloads the page)");
   let tabReloadPromise = promiseTabLoadEvent(tab);
   clickButton("#tracking-action-unblock");
+  is(identityPopupState(), "closed", "foobar");
+
   yield tabReloadPromise;
   testTrackingPageUnblocked();
 
   info("Test that the exception is remembered across tabs in the same private window");
   tab = browser.selectedTab = browser.addTab();
 
   info("Load a test page containing tracking elements");
   yield promiseTabLoadEvent(tab, TRACKING_PAGE);
@@ -110,13 +117,15 @@ add_task(function* testExceptionPersiste
   info("Load a test page containing tracking elements");
   yield promiseTabLoadEvent(tab, TRACKING_PAGE);
 
   testTrackingPage(tab.ownerDocument.defaultView);
 
   info("Disable TP for the page (which reloads the page)");
   let tabReloadPromise = promiseTabLoadEvent(tab);
   clickButton("#tracking-action-unblock");
+  is(identityPopupState(), "closed", "foobar");
+
   yield tabReloadPromise;
   testTrackingPageUnblocked();
 
   privateWin.close();
 });