Bug 1496557 - Expose Report Breakage for Cookie Restrictions on Release. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D7856

--HG--
extra : rebase_source : d7db4dd38de02f7ec143656e025658a748314550
This commit is contained in:
Johann Hofmann 2018-10-05 11:27:55 +02:00
Родитель 13398a497d
Коммит 0a8f8bf044
3 изменённых файлов: 34 добавлений и 10 удалений

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

@ -1522,6 +1522,9 @@ pref("browser.contentblocking.reportBreakage.enabled", true);
#else
pref("browser.contentblocking.reportBreakage.enabled", false);
#endif
// Show report breakage for tracking cookies in all channels.
pref("browser.contentblocking.rejecttrackers.reportBreakage.enabled", true);
pref("browser.contentblocking.reportBreakage.url", "https://tracking-protection-issues.herokuapp.com/new");
// Content Blocking has a separate pref for the intro count, since the former TP intro

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

@ -143,6 +143,7 @@ var TrackingProtection = {
var ThirdPartyCookies = {
reportBreakageLabel: "cookierestrictions",
PREF_ENABLED: "network.cookie.cookieBehavior",
PREF_REPORT_BREAKAGE_ENABLED: "browser.contentblocking.rejecttrackers.reportBreakage.enabled",
PREF_ENABLED_VALUES: [
// These values match the ones exposed under the Content Blocking section
// of the Preferences UI.
@ -161,6 +162,8 @@ var ThirdPartyCookies = {
XPCOMUtils.defineLazyPreferenceGetter(this, "behaviorPref", this.PREF_ENABLED,
Ci.nsICookieService.BEHAVIOR_ACCEPT);
XPCOMUtils.defineLazyPreferenceGetter(this, "visible", this.PREF_UI_ENABLED, false);
XPCOMUtils.defineLazyPreferenceGetter(this, "reportBreakageEnabled",
this.PREF_REPORT_BREAKAGE_ENABLED, false);
},
get enabled() {
return this.PREF_ENABLED_VALUES.includes(this.behaviorPref);
@ -287,14 +290,6 @@ var ContentBlocking = {
Services.prefs.addObserver(this.PREF_GLOBAL_TOGGLE, this.updateGlobalToggleVisibility);
this.updateReportBreakageUI = () => {
this.reportBreakageButton.hidden = !Services.prefs.getBoolPref(this.PREF_REPORT_BREAKAGE_ENABLED);
};
this.updateReportBreakageUI();
Services.prefs.addObserver(this.PREF_REPORT_BREAKAGE_ENABLED, this.updateReportBreakageUI);
this.updateAnimationsEnabled = () => {
this.iconBox.toggleAttribute("animationsenabled",
Services.prefs.getBoolPref(this.PREF_ANIMATIONS_ENABLED, false));
@ -312,6 +307,8 @@ var ContentBlocking = {
XPCOMUtils.defineLazyPreferenceGetter(this, "contentBlockingEnabled", this.PREF_ENABLED, false,
this.updateEnabled.bind(this));
XPCOMUtils.defineLazyPreferenceGetter(this, "reportBreakageEnabled",
this.PREF_REPORT_BREAKAGE_ENABLED, false);
XPCOMUtils.defineLazyPreferenceGetter(this, "contentBlockingUIEnabled", this.PREF_UI_ENABLED, false,
this.updateUIEnabled.bind(this));
@ -332,7 +329,6 @@ var ContentBlocking = {
}
Services.prefs.removeObserver(this.PREF_ANIMATIONS_ENABLED, this.updateAnimationsEnabled);
Services.prefs.removeObserver(this.PREF_REPORT_BREAKAGE_ENABLED, this.updateReportBreakageUI);
Services.prefs.removeObserver(this.PREF_GLOBAL_TOGGLE, this.updateGlobalToggleVisibility);
},
@ -518,6 +514,18 @@ var ContentBlocking = {
this.iconBox.toggleAttribute("active", active);
this.iconBox.toggleAttribute("hasException", this.enabled && hasException);
// For release (due to the large volume) we only want to receive reports
// for breakage that is directly related to third party cookie blocking.
if (this.reportBreakageEnabled ||
(ThirdPartyCookies.reportBreakageEnabled &&
ThirdPartyCookies.activated &&
!FastBlock.activated &&
!TrackingProtection.activated)) {
this.reportBreakageButton.removeAttribute("hidden");
} else {
this.reportBreakageButton.setAttribute("hidden", "true");
}
if (isSimulated) {
this.iconBox.removeAttribute("animate");
} else if (active && webProgress.isTopLevel) {

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

@ -5,6 +5,7 @@
const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/benignPage.html";
const COOKIE_PAGE = "http://not-tracking.example.com/browser/browser/base/content/test/trackingUI/cookiePage.html";
const CB_PREF = "browser.contentblocking.enabled";
const CB_UI_PREF = "browser.contentblocking.ui.enabled";
@ -78,11 +79,23 @@ add_task(async function testReportBreakageVisibility() {
},
buttonVisible: false,
},
{
url: COOKIE_PAGE,
prefs: {
"browser.contentblocking.enabled": true,
"browser.fastblock.enabled": false,
"privacy.trackingprotection.enabled": false,
"network.cookie.cookieBehavior": Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER,
"browser.contentblocking.reportBreakage.enabled": false,
"browser.contentblocking.rejecttrackers.reportBreakage.enabled": true,
},
buttonVisible: true,
},
];
for (let scenario of scenarios) {
for (let pref in scenario.prefs) {
Services.prefs.setBoolPref(pref, scenario.prefs[pref]);
Preferences.set(pref, scenario.prefs[pref]);
}
let uri = Services.io.newURI(scenario.url);