mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +00:00
Bug 1572377 - Updating the protection panel only when the panel is opened or already opened. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D68534
This commit is contained in:
parent
6f51057451
commit
2a182eb39d
@ -1312,10 +1312,6 @@ var gProtectionsHandler = {
|
||||
));
|
||||
},
|
||||
|
||||
get hasException() {
|
||||
return this._protectionsPopup.hasAttribute("hasException");
|
||||
},
|
||||
|
||||
strings: {
|
||||
get activeTooltipText() {
|
||||
delete this.activeTooltipText;
|
||||
@ -1637,12 +1633,12 @@ var gProtectionsHandler = {
|
||||
this._trackingProtectionIconContainer.hidden = false;
|
||||
|
||||
// Check whether the user has added an exception for this site.
|
||||
let hasException = ContentBlockingAllowList.includes(
|
||||
this.hasException = ContentBlockingAllowList.includes(
|
||||
gBrowser.selectedBrowser
|
||||
);
|
||||
|
||||
this._protectionsPopup.toggleAttribute("hasException", hasException);
|
||||
this.iconBox.toggleAttribute("hasException", hasException);
|
||||
this._protectionsPopup.toggleAttribute("hasException", this.hasException);
|
||||
this.iconBox.toggleAttribute("hasException", this.hasException);
|
||||
|
||||
// Add to telemetry per page load as a baseline measurement.
|
||||
this.fingerprintersHistogramAdd("pageLoad");
|
||||
@ -1697,7 +1693,8 @@ var gProtectionsHandler = {
|
||||
}
|
||||
|
||||
this.anyDetected = false;
|
||||
let anyBlocking = false;
|
||||
this.anyBlocking = false;
|
||||
|
||||
this.noTrackersDetectedDescription.hidden = false;
|
||||
|
||||
for (let blocker of this.blockers) {
|
||||
@ -1712,22 +1709,22 @@ var gProtectionsHandler = {
|
||||
let detected = blocker.isDetected(event);
|
||||
blocker.categoryItem.classList.toggle("notFound", !detected);
|
||||
this.anyDetected = this.anyDetected || detected;
|
||||
anyBlocking = anyBlocking || blocker.activated;
|
||||
this.anyBlocking = this.anyBlocking || blocker.activated;
|
||||
}
|
||||
|
||||
// Check whether the user has added an exception for this site.
|
||||
let hasException = ContentBlockingAllowList.includes(
|
||||
this.hasException = ContentBlockingAllowList.includes(
|
||||
gBrowser.selectedBrowser
|
||||
);
|
||||
|
||||
// Reset the animation in case the user is switching tabs or if no blockers were detected
|
||||
// (this is most likely happening because the user navigated on to a different site). This
|
||||
// allows us to play it from the start without choppiness next time.
|
||||
if (isSimulated || !anyBlocking) {
|
||||
if (isSimulated || !this.anyBlocking) {
|
||||
this.iconBox.removeAttribute("animate");
|
||||
// Only play the animation when the shield is not already shown on the page (the visibility
|
||||
// of the shield based on this onSecurityChange be determined afterwards).
|
||||
} else if (anyBlocking && !this.iconBox.hasAttribute("active")) {
|
||||
} else if (this.anyBlocking && !this.iconBox.hasAttribute("active")) {
|
||||
this.iconBox.setAttribute("animate", "true");
|
||||
}
|
||||
|
||||
@ -1735,16 +1732,21 @@ var gProtectionsHandler = {
|
||||
// occurs on the page. Note that merely allowing the loading of content that
|
||||
// we could have blocked does not trigger the appearance of the shield.
|
||||
// This state will be overriden later if there's an exception set for this site.
|
||||
this._protectionsPopup.toggleAttribute("detected", this.anyDetected);
|
||||
this._protectionsPopup.toggleAttribute("blocking", anyBlocking);
|
||||
this._protectionsPopup.toggleAttribute("hasException", hasException);
|
||||
let isPanelOpen = ["showing", "open"].includes(
|
||||
this._protectionsPopup.state
|
||||
);
|
||||
if (isPanelOpen) {
|
||||
this._protectionsPopup.toggleAttribute("detected", this.anyDetected);
|
||||
this._protectionsPopup.toggleAttribute("blocking", this.anyBlocking);
|
||||
this._protectionsPopup.toggleAttribute("hasException", this.hasException);
|
||||
}
|
||||
|
||||
this._categoryItemOrderInvalidated = true;
|
||||
|
||||
if (this.anyDetected) {
|
||||
this.noTrackersDetectedDescription.hidden = true;
|
||||
|
||||
if (["showing", "open"].includes(this._protectionsPopup.state)) {
|
||||
if (isPanelOpen) {
|
||||
this.reorderCategoryItems();
|
||||
|
||||
// Until we encounter a site that triggers them, category elements might
|
||||
@ -1757,16 +1759,16 @@ var gProtectionsHandler = {
|
||||
}
|
||||
}
|
||||
|
||||
this.iconBox.toggleAttribute("active", anyBlocking);
|
||||
this.iconBox.toggleAttribute("hasException", hasException);
|
||||
this.iconBox.toggleAttribute("active", this.anyBlocking);
|
||||
this.iconBox.toggleAttribute("hasException", this.hasException);
|
||||
|
||||
if (hasException) {
|
||||
if (this.hasException) {
|
||||
this.showDisabledTooltipForTPIcon();
|
||||
if (!this.hadShieldState && !isSimulated) {
|
||||
this.hadShieldState = true;
|
||||
this.shieldHistogramAdd(1);
|
||||
}
|
||||
} else if (anyBlocking) {
|
||||
} else if (this.anyBlocking) {
|
||||
this.showActiveTooltipForTPIcon();
|
||||
if (!this.hadShieldState && !isSimulated) {
|
||||
this.hadShieldState = true;
|
||||
@ -1846,7 +1848,7 @@ var gProtectionsHandler = {
|
||||
[host]
|
||||
);
|
||||
|
||||
let currentlyEnabled = !this._protectionsPopup.hasAttribute("hasException");
|
||||
let currentlyEnabled = !this.hasException;
|
||||
|
||||
for (let tpSwitch of [
|
||||
this._protectionsPopupTPSwitch,
|
||||
@ -1905,6 +1907,10 @@ var gProtectionsHandler = {
|
||||
} else {
|
||||
this._protectionsPopup.removeAttribute("milestone");
|
||||
}
|
||||
|
||||
this._protectionsPopup.toggleAttribute("detected", this.anyDetected);
|
||||
this._protectionsPopup.toggleAttribute("blocking", this.anyBlocking);
|
||||
this._protectionsPopup.toggleAttribute("hasException", this.hasException);
|
||||
},
|
||||
|
||||
/*
|
||||
@ -2238,7 +2244,7 @@ var gProtectionsHandler = {
|
||||
// ContentBlockingAllowList here.
|
||||
this._protectionsPopupTPSwitchBreakageLink.hidden =
|
||||
ContentBlockingAllowList.includes(gBrowser.selectedBrowser) ||
|
||||
!this._protectionsPopup.hasAttribute("blocking") ||
|
||||
!this.anyBlocking ||
|
||||
!this._protectionsPopupTPSwitch.hasAttribute("enabled");
|
||||
// The "Site Fixed?" link behaves similarly but for the opposite state.
|
||||
this._protectionsPopupTPSwitchBreakageFixedLink.hidden =
|
||||
|
@ -48,11 +48,12 @@ add_task(async function testToggleSwitch() {
|
||||
TRACKING_PAGE
|
||||
);
|
||||
|
||||
await openProtectionsPanel();
|
||||
|
||||
await TestUtils.waitForCondition(() => {
|
||||
return gProtectionsHandler._protectionsPopup.hasAttribute("blocking");
|
||||
});
|
||||
|
||||
await openProtectionsPanel();
|
||||
let events = Services.telemetry.snapshotEvents(
|
||||
Ci.nsITelemetry.DATASET_PRERELEASE_CHANNELS
|
||||
).parent;
|
||||
|
@ -51,6 +51,8 @@ async function testIdentityState(hasException) {
|
||||
await loaded;
|
||||
}
|
||||
|
||||
await openProtectionsPanel();
|
||||
|
||||
ok(
|
||||
!gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"cryptominers are not detected"
|
||||
|
@ -52,6 +52,8 @@ async function testIdentityState(hasException) {
|
||||
await loaded;
|
||||
}
|
||||
|
||||
await openProtectionsPanel();
|
||||
|
||||
ok(
|
||||
!gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"fingerprinters are not detected"
|
||||
|
@ -37,16 +37,10 @@ function clickButton(sel) {
|
||||
el.doCommand();
|
||||
}
|
||||
|
||||
function testTrackingPage(window) {
|
||||
function testTrackingPage() {
|
||||
info("Tracking content must be blocked");
|
||||
ok(
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"trackers are detected"
|
||||
);
|
||||
ok(
|
||||
!gProtectionsHandler._protectionsPopup.hasAttribute("hasException"),
|
||||
"content shows no exception"
|
||||
);
|
||||
ok(gProtectionsHandler.anyDetected, "trackers are detected");
|
||||
ok(!gProtectionsHandler.hasException, "content shows no exception");
|
||||
|
||||
ok(
|
||||
BrowserTestUtils.is_visible(gProtectionsHandler.iconBox),
|
||||
@ -65,15 +59,9 @@ function testTrackingPage(window) {
|
||||
}
|
||||
|
||||
function testTrackingPageUnblocked() {
|
||||
info("Tracking content must be white-listed and not blocked");
|
||||
ok(
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"trackers are detected"
|
||||
);
|
||||
ok(
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("hasException"),
|
||||
"content shows exception"
|
||||
);
|
||||
info("Tracking content must be allowlisted and not blocked");
|
||||
ok(gProtectionsHandler.anyDetected, "trackers are detected");
|
||||
ok(gProtectionsHandler.hasException, "content shows exception");
|
||||
|
||||
ok(!gProtectionsHandler.iconBox.hasAttribute("active"), "shield is active");
|
||||
ok(
|
||||
|
@ -60,14 +60,8 @@ function notFound(id) {
|
||||
|
||||
function testBenignPage() {
|
||||
info("Non-tracking content must not be blocked");
|
||||
ok(
|
||||
!gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"no trackers are detected"
|
||||
);
|
||||
ok(
|
||||
!gProtectionsHandler._protectionsPopup.hasAttribute("hasException"),
|
||||
"content shows no exception"
|
||||
);
|
||||
ok(!gProtectionsHandler.anyDetected, "no trackers are detected");
|
||||
ok(!gProtectionsHandler.hasException, "content shows no exception");
|
||||
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("active"),
|
||||
@ -98,14 +92,8 @@ function testBenignPage() {
|
||||
|
||||
function testBenignPageWithException() {
|
||||
info("Non-tracking content must not be blocked");
|
||||
ok(
|
||||
!gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"no trackers are detected"
|
||||
);
|
||||
ok(
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("hasException"),
|
||||
"content shows exception"
|
||||
);
|
||||
ok(!gProtectionsHandler.anyDetected, "no trackers are detected");
|
||||
ok(gProtectionsHandler.hasException, "content shows exception");
|
||||
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("active"),
|
||||
@ -149,14 +137,8 @@ function areTrackersBlocked(isPrivateBrowsing) {
|
||||
|
||||
function testTrackingPage(window) {
|
||||
info("Tracking content must be blocked");
|
||||
ok(
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"trackers are detected"
|
||||
);
|
||||
ok(
|
||||
!gProtectionsHandler._protectionsPopup.hasAttribute("hasException"),
|
||||
"content shows no exception"
|
||||
);
|
||||
ok(gProtectionsHandler.anyDetected, "trackers are detected");
|
||||
ok(!gProtectionsHandler.hasException, "content shows no exception");
|
||||
|
||||
let isWindowPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
|
||||
let blockedByTP = areTrackersBlocked(isWindowPrivate);
|
||||
@ -198,14 +180,8 @@ function testTrackingPage(window) {
|
||||
|
||||
function testTrackingPageUnblocked(blockedByTP, window) {
|
||||
info("Tracking content must be white-listed and not blocked");
|
||||
ok(
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"trackers are detected"
|
||||
);
|
||||
ok(
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("hasException"),
|
||||
"content shows exception"
|
||||
);
|
||||
ok(gProtectionsHandler.anyDetected, "trackers are detected");
|
||||
ok(gProtectionsHandler.hasException, "content shows exception");
|
||||
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("active"),
|
||||
|
Loading…
Reference in New Issue
Block a user