Bug 1555226 - Part 1: Toggle the 'hasException' attribute on the protections panel after toggling the TP switch. r=nhnt11
authorTim Huang <tihuang@mozilla.com>
Fri, 28 Jun 2019 12:48:46 +0000
changeset 543770 a64eedd73f97ab3669a71835bc154ff4d812ffc9
parent 543769 9ea5e6e45f29c75f59d06477123c75b3faf08595
child 543771 8e13f45f0d266210e196c040baac7a71fe66f36b
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnhnt11
bugs1555226
milestone69.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 1555226 - Part 1: Toggle the 'hasException' attribute on the protections panel after toggling the TP switch. r=nhnt11 This patch makes the 'hasException' attribtion to be toggled right after toggling the TP switch. In order to do styling after the toggling. Differential Revision: https://phabricator.services.mozilla.com/D36015
browser/base/content/browser-siteProtections.js
--- a/browser/base/content/browser-siteProtections.js
+++ b/browser/base/content/browser-siteProtections.js
@@ -122,23 +122,25 @@ var gProtectionsHandler = {
     // We need to ensure we don't handle more clicks during the 500ms delay,
     // so we keep track of state and return early if needed.
     if (this._TPSwitchCommanding) {
       return;
     }
 
     this._TPSwitchCommanding = true;
 
-    let currentlyEnabled =
-      !this._protectionsPopup.hasAttribute("hasException");
+    // Toggling the 'hasException' on the protections panel in order to do some
+    // styling after toggling the TP switch.
+    let newExceptionState =
+      this._protectionsPopup.toggleAttribute("hasException");
+    this._protectionsPopupTPSwitch.toggleAttribute("enabled", !newExceptionState);
 
-    this._protectionsPopupTPSwitch.toggleAttribute("enabled", !currentlyEnabled);
     await new Promise((resolve) => setTimeout(resolve, 500));
 
-    if (currentlyEnabled) {
+    if (newExceptionState) {
       ContentBlocking.disableForCurrentPage();
       gIdentityHandler.recordClick("unblock");
     } else {
       ContentBlocking.enableForCurrentPage();
       gIdentityHandler.recordClick("block");
     }
 
     PanelMultiView.hidePopup(this._protectionsPopup);