Bug 1476317 - Fix identity popup display for pages with exceptions that have blocked content. r=nhnt11

The identity popup will now show that there's an exception on the site instead of being confused.

We previously didn't handle this state because I assumed it wouldn't be possible to enter.
Turns out if you open the same (tracking) site in two tabs and then add an exception in one tab,
the other tab will be in this state until reload.

MozReview-Commit-ID: GVVdNpsAm6h

--HG--
extra : rebase_source : 3ace3cd4f99094edf3c678c56a39adebdc37d1f3
This commit is contained in:
Johann Hofmann 2018-07-18 16:33:06 +02:00
Родитель 02c427558a
Коммит e4580d39d9
4 изменённых файлов: 17 добавлений и 5 удалений

Просмотреть файл

@ -209,8 +209,10 @@ var TrackingProtection = {
}
if (hasException) {
this.iconBox.setAttribute("hasException", "true");
this.content.setAttribute("hasException", "true");
} else {
this.iconBox.removeAttribute("hasException");
this.content.removeAttribute("hasException");
}

Просмотреть файл

@ -72,6 +72,7 @@ function testBenignPageWithException() {
ok(!TrackingProtection.container.hidden, "The container is visible");
ok(!TrackingProtection.content.hasAttribute("state"), "content: no state");
ok(TrackingProtection.content.hasAttribute("hasException"), "content has exception attribute");
ok(TrackingProtection.iconBox.hasAttribute("hasException"), "icon box has exception attribute");
ok(!TrackingProtection.iconBox.hasAttribute("state"), "icon box: no state");
ok(!TrackingProtection.iconBox.hasAttribute("tooltiptext"), "icon box: no tooltip");
@ -99,6 +100,8 @@ function testTrackingPage(window) {
'icon box: state="blocked-tracking-content"');
is(TrackingProtection.iconBox.getAttribute("tooltiptext"),
gNavigatorBundle.getString("trackingProtection.icon.activeTooltip"), "correct tooltip");
ok(!TrackingProtection.content.hasAttribute("hasException"), "content has no exception attribute");
ok(!TrackingProtection.iconBox.hasAttribute("hasException"), "icon box has no exception attribute");
let doc = tabbrowser.ownerGlobal.document;
ok(BrowserTestUtils.is_visible(doc.getElementById("tracking-protection-icon-box")), "icon box is visible");
@ -123,6 +126,10 @@ function testTrackingPage(window) {
function testTrackingPageUnblocked() {
info("Tracking content must be white-listed and not blocked");
is(TrackingProtection.content.hasAttribute("hasException"), TrackingProtection.enabled,
"content has exception attribute if TP is on");
is(TrackingProtection.iconBox.hasAttribute("hasException"), TrackingProtection.enabled,
"icon box has exception attribute if TP is on");
ok(!TrackingProtection.container.hidden, "The container is visible");
is(TrackingProtection.content.getAttribute("state"), "loaded-tracking-content",
'content: state="loaded-tracking-content"');

Просмотреть файл

@ -342,15 +342,15 @@ description#identity-popup-content-verifier,
#tracking-protection-content:not([state]):-moz-any([enabled="false"], :not([hasException])) > #tracking-not-detected,
#tracking-protection-content:not([state])[enabled="true"][hasException] > #tracking-not-detected-exception,
/* Blocking tracking, offer buttons to unblock (depending on PBM). */
#tracking-protection-content[state="blocked-tracking-content"] > #tracking-blocked,
#main-window:not([privatebrowsingmode]) #tracking-protection-content[state="blocked-tracking-content"] > #tracking-action-unblock,
#tracking-protection-content:not([hasException])[state="blocked-tracking-content"] > #tracking-blocked,
#main-window:not([privatebrowsingmode]) #tracking-protection-content:not([hasException])[state="blocked-tracking-content"] > #tracking-action-unblock,
#main-window[privatebrowsingmode] #tracking-protection-content[state="blocked-tracking-content"] > #tracking-action-unblock-private,
/* Enabled and no exception but trackers loaded, probably needs a reload */
#tracking-protection-content[enabled="true"]:not([hasException])[state="loaded-tracking-content"] > #tracking-reload-required,
#tracking-protection-content[enabled="true"]:not([hasException])[state="loaded-tracking-content"] > #tracking-action-reload,
/* Tracking Loaded */
#tracking-protection-content[state="loaded-tracking-content"][enabled="false"] > #tracking-loaded,
#tracking-protection-content[state="loaded-tracking-content"][enabled="true"][hasException] > #tracking-loaded-exception,
#tracking-protection-content[enabled="true"][hasException] > #tracking-loaded-exception,
/* Has an exception, offer to block the site again. */
#tracking-protection-content[enabled="true"][hasException] > #tracking-action-block {
display: -moz-box;

Просмотреть файл

@ -163,7 +163,7 @@
transition: margin-left 200ms ease-out, margin-right 200ms ease-out;
}
#tracking-protection-icon-box[state="blocked-tracking-content"][animationsenabled] > #tracking-protection-icon,
#tracking-protection-icon-box:not([hasException])[state="blocked-tracking-content"][animationsenabled] > #tracking-protection-icon,
#tracking-protection-icon-box:not([animationsenabled]) > #tracking-protection-icon-animatable-box {
display: none;
}
@ -177,7 +177,7 @@
height: 20px;
}
#tracking-protection-icon-box[state="blocked-tracking-content"] #tracking-protection-icon-animatable-image {
#tracking-protection-icon-box:not([hasException])[state="blocked-tracking-content"] #tracking-protection-icon-animatable-image {
background-image: url(chrome://browser/skin/tracking-protection-animation.svg);
transform: translateX(-1232px);
width: 1248px;
@ -206,6 +206,9 @@
list-style-image: url(chrome://browser/skin/tracking-protection.svg);
}
/* Override the blocked tracking content rule for cases when the user has added an exception
* on a different tab to signify that protection is disabled now */
#tracking-protection-icon-box[hasException][state="blocked-tracking-content"] > #tracking-protection-icon,
#tracking-protection-icon-box[state="loaded-tracking-content"] > #tracking-protection-icon {
list-style-image: url(chrome://browser/skin/tracking-protection-disabled.svg);
}