summaryrefslogtreecommitdiffstats
path: root/browser/base/content/browser-siteProtections.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/base/content/browser-siteProtections.js')
-rw-r--r--browser/base/content/browser-siteProtections.js278
1 files changed, 16 insertions, 262 deletions
diff --git a/browser/base/content/browser-siteProtections.js b/browser/base/content/browser-siteProtections.js
index 5364aa74cd..c44b4d3e8e 100644
--- a/browser/base/content/browser-siteProtections.js
+++ b/browser/base/content/browser-siteProtections.js
@@ -31,8 +31,6 @@ class ProtectionCategory {
* @param {Object} options - Category options.
* @param {string} options.prefEnabled - ID of pref which controls the
* category enabled state.
- * @param {string} [options.reportBreakageLabel] - Telemetry label to use when
- * users report TP breakage. Defaults to protection ID.
* @param {string} [options.l10nId] - Identifier l10n strings are keyed under
* for this category. Defaults to protection ID.
* @param {Object} flags - Flags for this category to look for in the content
@@ -51,7 +49,7 @@ class ProtectionCategory {
*/
constructor(
id,
- { prefEnabled, reportBreakageLabel, l10nId },
+ { prefEnabled, l10nId },
{
load,
block,
@@ -61,7 +59,6 @@ class ProtectionCategory {
) {
this._id = id;
this.prefEnabled = prefEnabled;
- this._reportBreakageLabel = reportBreakageLabel || id;
this._flags = { load, block, shim, allow };
@@ -112,10 +109,6 @@ class ProtectionCategory {
return this._enabled;
}
- get reportBreakageLabel() {
- return this._reportBreakageLabel;
- }
-
/**
* Get the category item associated with this protection from the main
* protections panel.
@@ -333,7 +326,6 @@ let Fingerprinting =
"fingerprinters",
{
prefEnabled: "privacy.trackingprotection.fingerprinting.enabled",
- reportBreakageLabel: "fingerprinting",
},
{
load: Ci.nsIWebProgressListener.STATE_LOADED_FINGERPRINTING_CONTENT,
@@ -411,7 +403,6 @@ let Cryptomining = new ProtectionCategory(
"cryptominers",
{
prefEnabled: "privacy.trackingprotection.cryptomining.enabled",
- reportBreakageLabel: "cryptomining",
},
{
load: Ci.nsIWebProgressListener.STATE_LOADED_CRYPTOMINING_CONTENT,
@@ -427,7 +418,6 @@ let TrackingProtection =
{
l10nId: "trackingContent",
prefEnabled: "privacy.trackingprotection.enabled",
- reportBreakageLabel: "trackingprotection",
},
{
load: null,
@@ -699,28 +689,6 @@ let ThirdPartyCookies =
);
}
- get reportBreakageLabel() {
- switch (this.behaviorPref) {
- case Ci.nsICookieService.BEHAVIOR_ACCEPT:
- return "nocookiesblocked";
- case Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN:
- return "allthirdpartycookiesblocked";
- case Ci.nsICookieService.BEHAVIOR_REJECT:
- return "allcookiesblocked";
- case Ci.nsICookieService.BEHAVIOR_LIMIT_FOREIGN:
- return "cookiesfromunvisitedsitesblocked";
- default:
- console.error(
- `Error: Unknown cookieBehavior pref observed: ${this.behaviorPref}`
- );
- // fall through
- case Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER:
- return "cookierestrictions";
- case Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN:
- return "cookierestrictionsforeignpartitioned";
- }
- }
-
isBlocking(state) {
return (
(state & Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER) !=
@@ -1099,7 +1067,6 @@ let SocialTracking =
{
l10nId: "socialMediaTrackers",
prefEnabled: "privacy.socialtracking.block_cookies.enabled",
- reportBreakageLabel: "socialtracking",
},
{
load: Ci.nsIWebProgressListener.STATE_LOADED_SOCIALTRACKING_CONTENT,
@@ -1406,7 +1373,6 @@ let cookieBannerHandling = new (class {
* Utility object to handle manipulations of the protections indicators in the UI
*/
var gProtectionsHandler = {
- PREF_REPORT_BREAKAGE_URL: "browser.contentblocking.reportBreakage.url",
PREF_CB_CATEGORY: "browser.contentblocking.category",
_protectionsPopup: null,
@@ -1456,18 +1422,6 @@ var gProtectionsHandler = {
"protections-popup-mainView-panel-header-span"
));
},
- get _protectionsPopupTPSwitchBreakageLink() {
- delete this._protectionsPopupTPSwitchBreakageLink;
- return (this._protectionsPopupTPSwitchBreakageLink =
- document.getElementById("protections-popup-tp-switch-breakage-link"));
- },
- get _protectionsPopupTPSwitchBreakageFixedLink() {
- delete this._protectionsPopupTPSwitchBreakageFixedLink;
- return (this._protectionsPopupTPSwitchBreakageFixedLink =
- document.getElementById(
- "protections-popup-tp-switch-breakage-fixed-link"
- ));
- },
get _protectionsPopupTPSwitch() {
delete this._protectionsPopupTPSwitch;
return (this._protectionsPopupTPSwitch = document.getElementById(
@@ -1524,28 +1478,6 @@ var gProtectionsHandler = {
"protections-popup-footer-protection-type-label"
));
},
- get _protectionsPopupSiteNotWorkingTPSwitch() {
- delete this._protectionsPopupSiteNotWorkingTPSwitch;
- return (this._protectionsPopupSiteNotWorkingTPSwitch =
- document.getElementById("protections-popup-siteNotWorking-tp-switch"));
- },
- get _protectionsPopupSiteNotWorkingReportError() {
- delete this._protectionsPopupSiteNotWorkingReportError;
- return (this._protectionsPopupSiteNotWorkingReportError =
- document.getElementById("protections-popup-sendReportView-report-error"));
- },
- get _protectionsPopupSendReportURL() {
- delete this._protectionsPopupSendReportURL;
- return (this._protectionsPopupSendReportURL = document.getElementById(
- "protections-popup-sendReportView-collection-url"
- ));
- },
- get _protectionsPopupSendReportButton() {
- delete this._protectionsPopupSendReportButton;
- return (this._protectionsPopupSendReportButton = document.getElementById(
- "protections-popup-sendReportView-submit"
- ));
- },
get _trackingProtectionIconTooltipLabel() {
delete this._trackingProtectionIconTooltipLabel;
return (this._trackingProtectionIconTooltipLabel = document.getElementById(
@@ -1580,13 +1512,6 @@ var gProtectionsHandler = {
));
},
- get _siteNotWorkingIssueListFonts() {
- delete this._siteNotWorkingIssueListFonts;
- return (this._siteNotWorkingIssueListFonts = document.getElementById(
- "protections-panel-site-not-working-view-issue-list-fonts"
- ));
- },
-
// A list of blockers that will be displayed in the categories list
// when blockable content is detected. A blocker must be an object
// with at least the following two properties:
@@ -1811,10 +1736,6 @@ var gProtectionsHandler = {
window.addEventListener("focus", this, true);
this._protectionsPopupTPSwitch.addEventListener("toggle", this);
- this._protectionsPopupSiteNotWorkingTPSwitch.addEventListener(
- "toggle",
- this
- );
// Insert the info message if needed. This will be shown once and then
// remain collapsed.
@@ -1834,10 +1755,6 @@ var gProtectionsHandler = {
if (event.target == this._protectionsPopup) {
window.removeEventListener("focus", this, true);
this._protectionsPopupTPSwitch.removeEventListener("toggle", this);
- this._protectionsPopupSiteNotWorkingTPSwitch.removeEventListener(
- "toggle",
- this
- );
}
},
@@ -2163,7 +2080,7 @@ var gProtectionsHandler = {
let currentlyEnabled = !this.hasException;
- this.updateProtectionsToggles(currentlyEnabled);
+ this.updateProtectionsToggle(currentlyEnabled);
this._notBlockingWhyLink.setAttribute(
"tooltip",
@@ -2172,9 +2089,6 @@ var gProtectionsHandler = {
: "protections-popup-not-blocking-why-etp-off-tooltip"
);
- // Toggle the breakage link according to the current enable state.
- this.toggleBreakageLink();
-
// Update the tooltip of the blocked tracker counter.
this.maybeUpdateEarliestRecordedDateTooltip();
@@ -2196,28 +2110,23 @@ var gProtectionsHandler = {
},
/**
- * Updates the "pressed" state and labels for both toggles in the different
- * panel subviews.
+ * Updates the "pressed" state and labels for the toggle
*
- * @param {boolean} isPressed - Whether or not the toggles should be pressed.
+ * @param {boolean} isPressed - Whether or not the toggle should be pressed.
* True if ETP is enabled for a given site.
*/
- updateProtectionsToggles(isPressed) {
+ updateProtectionsToggle(isPressed) {
let host = gIdentityHandler.getHostForDisplay();
- for (let toggle of [
- this._protectionsPopupTPSwitch,
- this._protectionsPopupSiteNotWorkingTPSwitch,
- ]) {
- toggle.toggleAttribute("pressed", isPressed);
- toggle.toggleAttribute("disabled", !!this._TPSwitchCommanding);
- document.l10n.setAttributes(
- toggle,
- isPressed
- ? "protections-panel-etp-toggle-on"
- : "protections-panel-etp-toggle-off",
- { host }
- );
- }
+ let toggle = this._protectionsPopupTPSwitch;
+ toggle.toggleAttribute("pressed", isPressed);
+ toggle.toggleAttribute("disabled", !!this._TPSwitchCommanding);
+ document.l10n.setAttributes(
+ toggle,
+ isPressed
+ ? "protections-panel-etp-toggle-on"
+ : "protections-panel-etp-toggle-off",
+ { host }
+ );
},
/*
@@ -2313,10 +2222,7 @@ var gProtectionsHandler = {
let newExceptionState =
this._protectionsPopup.toggleAttribute("hasException");
- this.updateProtectionsToggles(!newExceptionState);
-
- // Toggle the breakage link if needed.
- this.toggleBreakageLink();
+ this.updateProtectionsToggle(!newExceptionState);
// Change the tooltip of the tracking protection icon.
if (newExceptionState) {
@@ -2523,158 +2429,6 @@ var gProtectionsHandler = {
).catch(console.error);
},
- showSiteNotWorkingView() {
- // Only show the Fonts item if we are restricting font visibility
- if (this._fontVisibilityTrackingProtection >= 3) {
- this._siteNotWorkingIssueListFonts.setAttribute("hidden", "true");
- } else {
- this._siteNotWorkingIssueListFonts.removeAttribute("hidden");
- }
-
- this._protectionsPopupMultiView.showSubView(
- "protections-popup-siteNotWorkingView"
- );
- },
-
- showSendReportView() {
- // Save this URI to make sure that the user really only submits the location
- // they see in the report breakage dialog.
- this.reportURI = gBrowser.currentURI;
- let urlWithoutQuery = this.reportURI.asciiSpec.replace(
- "?" + this.reportURI.query,
- ""
- );
- let commentsTextarea = document.getElementById(
- "protections-popup-sendReportView-collection-comments"
- );
- commentsTextarea.value = "";
- this._protectionsPopupSendReportURL.value = urlWithoutQuery;
- this._protectionsPopupSiteNotWorkingReportError.hidden = true;
- this._protectionsPopupMultiView.showSubView(
- "protections-popup-sendReportView"
- );
- },
-
- toggleBreakageLink() {
- // The breakage link will only be shown if tracking protection is enabled
- // for the site and the TP toggle state is on. And we won't show the
- // link as toggling TP switch to On from Off. In order to do so, we need to
- // know the previous TP state. We check the ContentBlockingAllowList instead
- // of 'hasException' attribute of the protection popup for the previous
- // since the 'hasException' will also be toggled as well as toggling the TP
- // switch. We won't be able to know the previous TP state through the
- // 'hasException' attribute. So we fallback to check the
- // ContentBlockingAllowList here.
- this._protectionsPopupTPSwitchBreakageLink.hidden =
- ContentBlockingAllowList.includes(gBrowser.selectedBrowser) ||
- !this.anyBlocking ||
- !this._protectionsPopupTPSwitch.hasAttribute("pressed");
- // The "Site Fixed?" link behaves similarly but for the opposite state.
- this._protectionsPopupTPSwitchBreakageFixedLink.hidden =
- !ContentBlockingAllowList.includes(gBrowser.selectedBrowser) ||
- this._protectionsPopupTPSwitch.hasAttribute("pressed");
- },
-
- submitBreakageReport(uri) {
- let reportEndpoint = Services.prefs.getStringPref(
- this.PREF_REPORT_BREAKAGE_URL
- );
- if (!reportEndpoint) {
- return;
- }
-
- let commentsTextarea = document.getElementById(
- "protections-popup-sendReportView-collection-comments"
- );
-
- let formData = new FormData();
- formData.set("title", uri.host);
-
- // Leave the ? at the end of the URL to signify that this URL had its query stripped.
- let urlWithoutQuery = uri.asciiSpec.replace(uri.query, "");
- let body = `Full URL: ${urlWithoutQuery}\n`;
- body += `userAgent: ${navigator.userAgent}\n`;
-
- body += "\n**Preferences**\n";
- body += `${TrackingProtection.prefEnabled}: ${Services.prefs.getBoolPref(
- TrackingProtection.prefEnabled
- )}\n`;
- body += `${
- TrackingProtection.prefEnabledInPrivateWindows
- }: ${Services.prefs.getBoolPref(
- TrackingProtection.prefEnabledInPrivateWindows
- )}\n`;
- body += `urlclassifier.trackingTable: ${Services.prefs.getStringPref(
- "urlclassifier.trackingTable"
- )}\n`;
- body += `network.http.referer.defaultPolicy: ${Services.prefs.getIntPref(
- "network.http.referer.defaultPolicy"
- )}\n`;
- body += `network.http.referer.defaultPolicy.pbmode: ${Services.prefs.getIntPref(
- "network.http.referer.defaultPolicy.pbmode"
- )}\n`;
- body += `${ThirdPartyCookies.prefEnabled}: ${Services.prefs.getIntPref(
- ThirdPartyCookies.prefEnabled
- )}\n`;
- body += `privacy.annotate_channels.strict_list.enabled: ${Services.prefs.getBoolPref(
- "privacy.annotate_channels.strict_list.enabled"
- )}\n`;
- body += `privacy.restrict3rdpartystorage.expiration: ${Services.prefs.getIntPref(
- "privacy.restrict3rdpartystorage.expiration"
- )}\n`;
- body += `${Fingerprinting.prefEnabled}: ${Services.prefs.getBoolPref(
- Fingerprinting.prefEnabled
- )}\n`;
- body += `${Cryptomining.prefEnabled}: ${Services.prefs.getBoolPref(
- Cryptomining.prefEnabled
- )}\n`;
- body += `privacy.globalprivacycontrol.enabled: ${Services.prefs.getBoolPref(
- "privacy.globalprivacycontrol.enabled"
- )}\n`;
- body += `\nhasException: ${this.hasException}\n`;
-
- body += "\n**Comments**\n" + commentsTextarea.value;
-
- formData.set("body", body);
-
- let activatedBlockers = [];
- for (let blocker of Object.values(this.blockers)) {
- if (blocker.activated) {
- activatedBlockers.push(blocker.reportBreakageLabel);
- }
- }
-
- formData.set("labels", activatedBlockers.join(","));
-
- this._protectionsPopupSendReportButton.disabled = true;
-
- fetch(reportEndpoint, {
- method: "POST",
- credentials: "omit",
- body: formData,
- })
- .then(response => {
- this._protectionsPopupSendReportButton.disabled = false;
- if (!response.ok) {
- console.error(
- `Content Blocking report to ${reportEndpoint} failed with status ${response.status}`
- );
- this._protectionsPopupSiteNotWorkingReportError.hidden = false;
- } else {
- this._protectionsPopup.hidePopup();
- ConfirmationHint.show(
- this._trackingProtectionIconContainer,
- "confirmation-hint-breakage-report-sent"
- );
- }
- })
- .catch(console.error);
- },
-
- onSendReportClicked() {
- this.submitBreakageReport(this.reportURI);
- },
-
async maybeUpdateEarliestRecordedDateTooltip(trackerCount) {
// If we've already updated or the popup isn't in the DOM yet, don't bother
// doing this: