Backed out 2 changesets (bug 1501992) for browser_trackingUI_state.js perma fails a=backout

Backed out changeset 6cb8a465440a (bug 1501992)
Backed out changeset b54b117c15e9 (bug 1501992)
This commit is contained in:
Ciure Andrei 2018-12-02 13:53:33 +02:00
Родитель 2edebf41a2
Коммит e0bdf73546
20 изменённых файлов: 286 добавлений и 753 удалений

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

@ -7,6 +7,7 @@ var TrackingProtection = {
telemetryIdentifier: "tp",
PREF_ENABLED_GLOBALLY: "privacy.trackingprotection.enabled",
PREF_ENABLED_IN_PRIVATE_WINDOWS: "privacy.trackingprotection.pbmode.enabled",
PREF_UI_ENABLED: "browser.contentblocking.trackingprotection.control-center.ui.enabled",
PREF_TRACKING_TABLE: "urlclassifier.trackingTable",
PREF_TRACKING_ANNOTATION_TABLE: "urlclassifier.trackingAnnotationTable",
enabledGlobally: false,
@ -18,12 +19,6 @@ var TrackingProtection = {
document.getElementById("identity-popup-content-blocking-category-tracking-protection");
},
get categoryLabel() {
delete this.categoryLabel;
return this.categoryLabel =
document.getElementById("identity-popup-content-blocking-tracking-protection-state-label");
},
get subViewList() {
delete this.subViewList;
return this.subViewList = document.getElementById("identity-popup-trackersView-list");
@ -34,20 +29,13 @@ var TrackingProtection = {
return this.strictInfo = document.getElementById("identity-popup-trackersView-strict-info");
},
strings: {
get subViewBlocked() {
delete this.subViewBlocked;
return this.subViewBlocked =
gNavigatorBundle.getString("contentBlocking.trackersView.blocked.label");
},
},
init() {
this.updateEnabled();
Services.prefs.addObserver(this.PREF_ENABLED_GLOBALLY, this);
Services.prefs.addObserver(this.PREF_ENABLED_IN_PRIVATE_WINDOWS, this);
XPCOMUtils.defineLazyPreferenceGetter(this, "visible", this.PREF_UI_ENABLED, false);
XPCOMUtils.defineLazyPreferenceGetter(this, "trackingTable", this.PREF_TRACKING_TABLE, false);
XPCOMUtils.defineLazyPreferenceGetter(this, "trackingAnnotationTable", this.PREF_TRACKING_ANNOTATION_TABLE, false);
},
@ -72,29 +60,14 @@ var TrackingProtection = {
Services.prefs.getBoolPref(this.PREF_ENABLED_GLOBALLY);
this.enabledInPrivateWindows =
Services.prefs.getBoolPref(this.PREF_ENABLED_IN_PRIVATE_WINDOWS);
this.updateCategoryLabel();
},
updateCategoryLabel() {
let label;
if (this.enabled) {
label = "contentBlocking.trackers.blocked.label";
} else {
label = "contentBlocking.trackers.allowed.label";
}
this.categoryLabel.textContent = gNavigatorBundle.getString(label);
},
isBlocking(state) {
return (state & Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT) != 0;
isBlockerActivated(state) {
return state & Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT;
},
isAllowing(state) {
return (state & Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT) != 0;
},
isDetected(state) {
return this.isBlocking(state) || this.isAllowing(state);
return state & Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT;
},
async updateSubView() {
@ -141,7 +114,7 @@ var TrackingProtection = {
let isAllowed = false;
for (let [state] of actions) {
isAllowed = isAllowed || this.isAllowing(state);
isDetected = isDetected || isAllowed || this.isBlocking(state);
isDetected = isDetected || isAllowed || this.isBlockerActivated(state);
}
if (!isDetected) {
@ -159,30 +132,17 @@ var TrackingProtection = {
}
let listItem = document.createXULElement("hbox");
listItem.className = "identity-popup-content-blocking-list-item";
listItem.className = "identity-popup-trackersView-list-item";
listItem.classList.toggle("allowed", isAllowed);
// Repeat the host in the tooltip in case it's too long
// and overflows in our panel.
listItem.tooltipText = uri.host;
let image = document.createXULElement("image");
image.className = "identity-popup-trackersView-icon";
image.classList.toggle("allowed", isAllowed);
listItem.append(image);
let label = document.createXULElement("label");
label.value = uri.host;
label.className = "identity-popup-content-blocking-list-host-label";
label.setAttribute("crop", "end");
listItem.append(label);
if (!isAllowed) {
let stateLabel = document.createXULElement("label");
stateLabel.value = this.strings.subViewBlocked;
stateLabel.className = "identity-popup-content-blocking-list-state-label";
listItem.append(stateLabel);
}
return listItem;
},
};
@ -197,36 +157,12 @@ var ThirdPartyCookies = {
Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN, // Block all third-party cookies
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER, // Block third-party cookies from trackers
],
PREF_UI_ENABLED: "browser.contentblocking.rejecttrackers.control-center.ui.enabled",
get categoryItem() {
delete this.categoryItem;
return this.categoryItem =
document.getElementById("identity-popup-content-blocking-category-cookies");
},
get categoryLabel() {
delete this.categoryLabel;
return this.categoryLabel =
document.getElementById("identity-popup-content-blocking-cookies-state-label");
},
get subViewList() {
delete this.subViewList;
return this.subViewList = document.getElementById("identity-popup-cookiesView-list");
},
strings: {
get subViewAllowed() {
delete this.subViewAllowed;
return this.subViewAllowed =
gNavigatorBundle.getString("contentBlocking.cookiesView.allowed.label");
},
get subViewBlocked() {
delete this.subViewBlocked;
return this.subViewBlocked =
gNavigatorBundle.getString("contentBlocking.cookiesView.blocked.label");
},
document.getElementById("identity-popup-content-blocking-category-3rdpartycookies");
},
get reportBreakageLabel() {
@ -247,236 +183,40 @@ var ThirdPartyCookies = {
}
},
get categoryLabelDefault() {
delete this.categoryLabelDefault;
return this.categoryLabelDefault =
document.getElementById("identity-popup-content-blocking-category-label-default");
},
get categoryLabelTrackers() {
delete this.categoryLabelTrackers;
return this.categoryLabelTrackers =
document.getElementById("identity-popup-content-blocking-category-label-trackers");
},
updateCategoryLabel() {
let label;
switch (this.behaviorPref) {
case Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN:
label = "contentBlocking.cookies.3rdPartyBlocked.label";
break;
case Ci.nsICookieService.BEHAVIOR_REJECT:
label = "contentBlocking.cookies.allBlocked.label";
break;
case Ci.nsICookieService.BEHAVIOR_LIMIT_FOREIGN:
label = "contentBlocking.cookies.unvisitedBlocked.label";
break;
case Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER:
label = "contentBlocking.cookies.trackersBlocked.label";
break;
default:
Cu.reportError(`Error: Unknown cookieBehavior pref observed: ${this.behaviorPref}`);
// fall through
case Ci.nsICookieService.BEHAVIOR_ACCEPT:
label = "contentBlocking.cookies.allowed.label";
break;
}
this.categoryLabel.textContent = gNavigatorBundle.getString(label);
let rejectTrackers = this.behaviorPref == Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER;
this.categoryLabelDefault.hidden = rejectTrackers;
this.categoryLabelTrackers.hidden = !rejectTrackers;
},
init() {
XPCOMUtils.defineLazyPreferenceGetter(this, "behaviorPref", this.PREF_ENABLED,
Ci.nsICookieService.BEHAVIOR_ACCEPT, this.updateCategoryLabel.bind(this));
XPCOMUtils.defineLazyPreferenceGetter(this, "visible", this.PREF_UI_ENABLED, false);
XPCOMUtils.defineLazyPreferenceGetter(this, "reportBreakageEnabled",
this.PREF_REPORT_BREAKAGE_ENABLED, false);
this.updateCategoryLabel();
},
get enabled() {
return this.PREF_ENABLED_VALUES.includes(this.behaviorPref);
},
isBlocking(state) {
isBlockerActivated(state) {
return (state & Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER) != 0 ||
(state & Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_ALL) != 0 ||
(state & Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_BY_PERMISSION) != 0 ||
(state & Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_FOREIGN) != 0;
},
isDetected(state) {
return (state & Ci.nsIWebProgressListener.STATE_COOKIES_LOADED) != 0;
},
async updateSubView() {
let contentBlockingLogJSON = await gBrowser.selectedBrowser.getContentBlockingLog();
let contentBlockingLog = JSON.parse(contentBlockingLogJSON);
let categories = this._processContentBlockingLog(contentBlockingLog);
this.subViewList.textContent = "";
for (let category of ["firstParty", "trackers", "thirdParty"]) {
if (categories[category].length) {
let box = document.createXULElement("vbox");
let label = document.createXULElement("label");
label.className = "identity-popup-cookiesView-list-header";
label.textContent = gNavigatorBundle.getString(`contentBlocking.cookiesView.${category}.label`);
box.appendChild(label);
for (let info of categories[category]) {
box.appendChild(this._createListItem(info));
}
this.subViewList.appendChild(box);
}
}
},
_hasException(origin) {
for (let perm of Services.perms.getAllForPrincipal(gBrowser.contentPrincipal)) {
if (perm.type == "3rdPartyStorage^" + origin || perm.type.startsWith("3rdPartyStorage^" + origin + "^")) {
return true;
}
}
let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(origin);
// Cookie exceptions get "inherited" from parent- to sub-domain, so we need to
// make sure to include parent domains in the permission check for "cookies".
return Services.perms.testPermissionFromPrincipal(principal, "cookie") != Services.perms.UNKNOWN_ACTION;
},
_clearException(origin) {
for (let perm of Services.perms.getAllForPrincipal(gBrowser.contentPrincipal)) {
if (perm.type == "3rdPartyStorage^" + origin || perm.type.startsWith("3rdPartyStorage^" + origin + "^")) {
Services.perms.removePermission(perm);
}
}
// OAs don't matter here, so we can just use the hostname.
let host = Services.io.newURI(origin).host;
// Cookie exceptions get "inherited" from parent- to sub-domain, so we need to
// clear any cookie permissions from parent domains as well.
for (let perm of Services.perms.enumerator) {
if (perm.type == "cookie" &&
Services.eTLD.hasRootDomain(host, perm.principal.URI.host)) {
Services.perms.removePermission(perm);
}
}
},
// Transforms and filters cookie entries in the content blocking log
// so that we can categorize and display them in the UI.
_processContentBlockingLog(log) {
let newLog = {
firstParty: [],
trackers: [],
thirdParty: [],
};
let firstPartyDomain = null;
try {
firstPartyDomain = Services.eTLD.getBaseDomain(gBrowser.currentURI);
} catch (e) {
// There are nasty edge cases here where someone is trying to set a cookie
// on a public suffix or an IP address. Just categorize those as third party...
if (e.result != Cr.NS_ERROR_HOST_IS_IP_ADDRESS &&
e.result != Cr.NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS) {
throw e;
}
}
for (let [origin, actions] of Object.entries(log)) {
if (!origin.startsWith("http")) {
continue;
}
let info = {origin, isAllowed: true, hasException: this._hasException(origin)};
let hasCookie = false;
let isTracker = false;
// Extract information from the states entries in the content blocking log.
// Each state will contain a single state flag from nsIWebProgressListener.
// Note that we are using the same helper functions that are applied to the
// bit map passed to onSecurityChange (which contains multiple states), thus
// not checking exact equality, just presence of bits.
for (let [state, blocked] of actions) {
if (this.isDetected(state)) {
hasCookie = true;
}
if (TrackingProtection.isAllowing(state)) {
isTracker = true;
}
// blocked tells us whether the resource was actually blocked
// (which it may not be in case of an exception).
if (this.isBlocking(state) && blocked) {
info.isAllowed = false;
}
}
if (!hasCookie) {
continue;
}
let isFirstParty = false;
try {
let uri = Services.io.newURI(origin);
isFirstParty = Services.eTLD.getBaseDomain(uri) == firstPartyDomain;
} catch (e) {
if (e.result != Cr.NS_ERROR_HOST_IS_IP_ADDRESS &&
e.result != Cr.NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS) {
throw e;
}
}
if (isFirstParty) {
newLog.firstParty.push(info);
} else if (isTracker) {
newLog.trackers.push(info);
} else {
newLog.thirdParty.push(info);
}
}
return newLog;
},
_createListItem({origin, isAllowed, hasException}) {
let listItem = document.createXULElement("hbox");
listItem.className = "identity-popup-content-blocking-list-item";
listItem.classList.toggle("allowed", isAllowed);
// Repeat the origin in the tooltip in case it's too long
// and overflows in our panel.
listItem.tooltipText = origin;
let image = document.createXULElement("image");
image.className = "identity-popup-cookiesView-icon";
image.classList.toggle("allowed", isAllowed);
listItem.append(image);
let label = document.createXULElement("label");
label.value = origin;
label.className = "identity-popup-content-blocking-list-host-label";
label.setAttribute("crop", "end");
listItem.append(label);
let stateLabel;
if (isAllowed && hasException) {
stateLabel = document.createXULElement("label");
stateLabel.value = this.strings.subViewAllowed;
stateLabel.className = "identity-popup-content-blocking-list-state-label";
listItem.append(stateLabel);
} else if (!isAllowed) {
stateLabel = document.createXULElement("label");
stateLabel.value = this.strings.subViewBlocked;
stateLabel.className = "identity-popup-content-blocking-list-state-label";
listItem.append(stateLabel);
}
if (hasException) {
let removeException = document.createXULElement("button");
removeException.className = "identity-popup-permission-remove-button";
removeException.tooltipText = gNavigatorBundle.getFormattedString(
"contentBlocking.cookiesView.removeButton.tooltip", [origin]);
removeException.addEventListener("click", () => {
this._clearException(origin);
// Just flip the display based on what state we had previously.
stateLabel.value = isAllowed ? this.strings.subViewBlocked : this.strings.subViewAllowed;
listItem.classList.toggle("allowed", !isAllowed);
image.classList.toggle("allowed", !isAllowed);
removeException.hidden = true;
});
listItem.append(removeException);
}
return listItem;
},
};
@ -657,9 +397,11 @@ var ContentBlocking = {
body += "\n**Preferences**\n";
body += `${TrackingProtection.PREF_ENABLED_GLOBALLY}: ${Services.prefs.getBoolPref(TrackingProtection.PREF_ENABLED_GLOBALLY)}\n`;
body += `${TrackingProtection.PREF_ENABLED_IN_PRIVATE_WINDOWS}: ${Services.prefs.getBoolPref(TrackingProtection.PREF_ENABLED_IN_PRIVATE_WINDOWS)}\n`;
body += `${TrackingProtection.PREF_UI_ENABLED}: ${Services.prefs.getBoolPref(TrackingProtection.PREF_UI_ENABLED)}\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.PREF_UI_ENABLED}: ${Services.prefs.getBoolPref(ThirdPartyCookies.PREF_UI_ENABLED)}\n`;
body += `${ThirdPartyCookies.PREF_ENABLED}: ${Services.prefs.getIntPref(ThirdPartyCookies.PREF_ENABLED)}\n`;
body += `network.cookie.lifetimePolicy: ${Services.prefs.getIntPref("network.cookie.lifetimePolicy")}\n`;
body += `privacy.restrict3rdpartystorage.expiration: ${Services.prefs.getIntPref("privacy.restrict3rdpartystorage.expiration")}\n`;
@ -705,11 +447,6 @@ var ContentBlocking = {
this.identityPopupMultiView.showSubView("identity-popup-trackersView");
},
async showCookiesSubview() {
await ThirdPartyCookies.updateSubView();
this.identityPopupMultiView.showSubView("identity-popup-cookiesView");
},
shieldHistogramAdd(value) {
if (PrivateBrowsingUtils.isWindowPrivate(window)) {
return;
@ -736,22 +473,27 @@ var ContentBlocking = {
this.iconBox.removeAttribute("animate");
}
let anyDetected = false;
let anyBlocking = false;
let anyBlockerActivated = false;
for (let blocker of this.blockers) {
// Store data on whether the blocker is activated in the current document for
// reporting it using the "report breakage" dialog. Under normal circumstances this
// dialog should only be able to open in the currently selected tab and onSecurityChange
// runs on tab switch, so we can avoid associating the data with the document directly.
blocker.activated = blocker.isBlocking(state);
blocker.activated = blocker.isBlockerActivated(state);
blocker.categoryItem.classList.toggle("blocked", blocker.enabled);
let detected = blocker.isDetected(state);
blocker.categoryItem.hidden = !detected;
anyDetected = anyDetected || detected;
anyBlocking = anyBlocking || blocker.activated;
blocker.categoryItem.hidden = !blocker.visible;
anyBlockerActivated = anyBlockerActivated || blocker.activated;
}
// We consider the shield state "active" when some kind of blocking activity
// 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.
let active = anyBlockerActivated;
let isAllowing = state & Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT;
let detected = anyBlockerActivated || isAllowing;
let isBrowserPrivate = PrivateBrowsingUtils.isBrowserPrivate(gBrowser.selectedBrowser);
// Check whether the user has added an exception for this site.
@ -759,15 +501,11 @@ var ContentBlocking = {
let hasException = Services.perms.testExactPermission(baseURI, type) ==
Services.perms.ALLOW_ACTION;
// We consider the shield state "active" when some kind of blocking activity
// 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.content.toggleAttribute("detected", anyDetected);
this.content.toggleAttribute("blocking", anyBlocking);
this.content.toggleAttribute("detected", detected);
this.content.toggleAttribute("hasException", hasException);
this.content.toggleAttribute("active", active);
this.iconBox.toggleAttribute("active", anyBlocking);
this.iconBox.toggleAttribute("active", active);
this.iconBox.toggleAttribute("hasException", hasException);
// For release (due to the large volume) we only want to receive reports
@ -783,7 +521,7 @@ var ContentBlocking = {
if (isSimulated) {
this.iconBox.removeAttribute("animate");
} else if (anyBlocking && webProgress.isTopLevel) {
} else if (active && webProgress.isTopLevel) {
this.iconBox.setAttribute("animate", "true");
if (!isBrowserPrivate) {
@ -799,7 +537,7 @@ var ContentBlocking = {
if (hasException) {
this.iconBox.setAttribute("tooltiptext", this.disabledTooltipText);
this.shieldHistogramAdd(1);
} else if (anyBlocking) {
} else if (active) {
this.iconBox.setAttribute("tooltiptext", this.activeTooltipText);
this.shieldHistogramAdd(2);
} else {

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

@ -7,12 +7,6 @@
<meta charset="utf8">
</head>
<body>
<!--TODO: We used to have an iframe here, to double-check that benign-->
<!--iframes may be included in pages. However, the cookie restrictions-->
<!--project introduced a change that declared blockable content to be-->
<!--found on any page that embeds iframes, rendering this unusable for-->
<!--our purposes. That's not ideal and we intend to restore this iframe.-->
<!--(See bug 1511303 for a more detailed technical explanation.)-->
<!--<iframe src="http://not-tracking.example.com/"></iframe>-->
<iframe src="http://not-tracking.example.com/"></iframe>
</body>
</html>

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

@ -13,7 +13,6 @@ support-files =
[browser_trackingUI_animation_2.js]
[browser_trackingUI_appMenu.js]
[browser_trackingUI_categories.js]
[browser_trackingUI_cookies_subview.js]
[browser_trackingUI_fetch.js]
support-files =
file_trackingUI_fetch.html

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

@ -16,7 +16,9 @@ registerCleanupFunction(function() {
add_task(async function testCategoryLabelsInControlPanel() {
await BrowserTestUtils.withNewTab("http://www.example.com", async function() {
await openIdentityPopup();
let promisePanelOpen = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "popupshown");
gIdentityHandler._identityBox.click();
await promisePanelOpen;
let preferencesButton = document.getElementById("tracking-protection-preferences-button");
ok(preferencesButton.label, "The preferencesButton label exists");
@ -68,55 +70,3 @@ add_task(async function testCategoryLabelsInAppMenu() {
"The appMenuCategory label has been changed to custom");
});
});
add_task(async function testSubcategoryLabels() {
await BrowserTestUtils.withNewTab("http://www.example.com", async function() {
let categoryLabel =
document.getElementById("identity-popup-content-blocking-tracking-protection-state-label");
Services.prefs.setBoolPref(TP_PREF, true);
await TestUtils.waitForCondition(() => categoryLabel.textContent ==
gNavigatorBundle.getString("contentBlocking.trackers.blocked.label"),
"The category label has updated correctly");
is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.trackers.blocked.label"));
Services.prefs.setBoolPref(TP_PREF, false);
await TestUtils.waitForCondition(() => categoryLabel.textContent ==
gNavigatorBundle.getString("contentBlocking.trackers.allowed.label"),
"The category label has updated correctly");
is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.trackers.allowed.label"));
categoryLabel =
document.getElementById("identity-popup-content-blocking-cookies-state-label");
Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_ACCEPT);
await TestUtils.waitForCondition(() => categoryLabel.textContent ==
gNavigatorBundle.getString("contentBlocking.cookies.allowed.label"),
"The category label has updated correctly");
is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.cookies.allowed.label"));
Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_REJECT);
await TestUtils.waitForCondition(() => categoryLabel.textContent ==
gNavigatorBundle.getString("contentBlocking.cookies.allBlocked.label"),
"The category label has updated correctly");
is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.cookies.allBlocked.label"));
Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN);
await TestUtils.waitForCondition(() => categoryLabel.textContent ==
gNavigatorBundle.getString("contentBlocking.cookies.3rdPartyBlocked.label"),
"The category label has updated correctly");
is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.cookies.3rdPartyBlocked.label"));
Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER);
await TestUtils.waitForCondition(() => categoryLabel.textContent ==
gNavigatorBundle.getString("contentBlocking.cookies.trackersBlocked.label"),
"The category label has updated correctly");
is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.cookies.trackersBlocked.label"));
Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_LIMIT_FOREIGN);
await TestUtils.waitForCondition(() => categoryLabel.textContent ==
gNavigatorBundle.getString("contentBlocking.cookies.unvisitedBlocked.label"),
"The category label has updated correctly");
is(categoryLabel.textContent, gNavigatorBundle.getString("contentBlocking.cookies.unvisitedBlocked.label"));
});
});

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

@ -1,190 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable mozilla/no-arbitrary-setTimeout */
"use strict";
const COOKIE_PAGE = "http://not-tracking.example.com/browser/browser/base/content/test/trackingUI/cookiePage.html";
const TPC_PREF = "network.cookie.cookieBehavior";
add_task(async function setup() {
// Avoid the content blocking tour interfering with our tests by popping up.
await SpecialPowers.pushPrefEnv({set: [[ContentBlocking.prefIntroCount, ContentBlocking.MAX_INTROS]]});
await UrlClassifierTestUtils.addTestTrackers();
registerCleanupFunction(() => {
UrlClassifierTestUtils.cleanupTestTrackers();
});
});
async function assertSitesListed(trackersBlocked, thirdPartyBlocked, firstPartyBlocked) {
await BrowserTestUtils.withNewTab(COOKIE_PAGE, async function(browser) {
await openIdentityPopup();
let categoryItem =
document.getElementById("identity-popup-content-blocking-category-cookies");
ok(BrowserTestUtils.is_visible(categoryItem), "TP category item is visible");
let cookiesView = document.getElementById("identity-popup-cookiesView");
let viewShown = BrowserTestUtils.waitForEvent(cookiesView, "ViewShown");
categoryItem.click();
await viewShown;
ok(true, "Cookies view was shown");
let listHeaders = cookiesView.querySelectorAll(".identity-popup-cookiesView-list-header");
is(listHeaders.length, 1, "We have 1 list header");
is(listHeaders[0].textContent,
gNavigatorBundle.getString(`contentBlocking.cookiesView.trackers.label`),
"The list header is for tracking cookies.");
let listItems = cookiesView.querySelectorAll(".identity-popup-content-blocking-list-item");
is(listItems.length, 1, "We have 1 cookie in the list");
let listItem = listItems[0];
let label = listItem.querySelector(".identity-popup-content-blocking-list-host-label");
is(label.value, "http://trackertest.org", "Has an item for trackertest.org");
ok(BrowserTestUtils.is_visible(listItem), "List item is visible");
is(listItem.classList.contains("allowed"), !trackersBlocked,
"Indicates whether the cookie was blocked or allowed");
let mainView = document.getElementById("identity-popup-mainView");
viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
let backButton = cookiesView.querySelector(".subviewbutton-back");
backButton.click();
await viewShown;
ok(true, "Main view was shown");
let change = waitForSecurityChange();
let timeoutPromise = new Promise(resolve => setTimeout(resolve, 1000));
await ContentTask.spawn(browser, {}, function() {
content.postMessage("third-party-cookie", "*");
});
let result = await Promise.race([change, timeoutPromise]);
is(result, undefined, "No securityChange events should be received");
viewShown = BrowserTestUtils.waitForEvent(cookiesView, "ViewShown");
categoryItem.click();
await viewShown;
ok(true, "Cookies view was shown");
listHeaders = cookiesView.querySelectorAll(".identity-popup-cookiesView-list-header");
is(listHeaders.length, 2, "We now have 2 list headers");
is(listHeaders[1].textContent,
gNavigatorBundle.getString(`contentBlocking.cookiesView.thirdParty.label`),
"The new list header is for third party cookies.");
listItems = cookiesView.querySelectorAll(".identity-popup-content-blocking-list-item");
is(listItems.length, 2, "We have 2 cookies in the list");
listItem = listItems[1];
label = listItem.querySelector(".identity-popup-content-blocking-list-host-label");
is(label.value, "https://test1.example.org", "Has an item for test1.example.org");
ok(BrowserTestUtils.is_visible(listItem), "List item is visible");
is(listItem.classList.contains("allowed"), !thirdPartyBlocked,
"Indicates whether the cookie was blocked or allowed");
viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
backButton.click();
await viewShown;
ok(true, "Main view was shown");
change = waitForSecurityChange();
timeoutPromise = new Promise(resolve => setTimeout(resolve, 1000));
await ContentTask.spawn(browser, {}, function() {
content.postMessage("first-party-cookie", "*");
});
result = await Promise.race([change, timeoutPromise]);
is(result, undefined, "No securityChange events should be received");
viewShown = BrowserTestUtils.waitForEvent(cookiesView, "ViewShown");
categoryItem.click();
await viewShown;
ok(true, "Cookies view was shown");
listHeaders = cookiesView.querySelectorAll(".identity-popup-cookiesView-list-header");
is(listHeaders.length, 3, "We now have 3 list headers");
is(listHeaders[0].textContent,
gNavigatorBundle.getString(`contentBlocking.cookiesView.firstParty.label`),
"The new list header is for first party cookies.");
listItems = cookiesView.querySelectorAll(".identity-popup-content-blocking-list-item");
is(listItems.length, 3, "We have 2 cookies in the list");
listItem = listItems[0];
label = listItem.querySelector(".identity-popup-content-blocking-list-host-label");
is(label.value, "http://not-tracking.example.com", "Has an item for the first party");
ok(BrowserTestUtils.is_visible(listItem), "List item is visible");
is(listItem.classList.contains("allowed"), !firstPartyBlocked,
"Indicates whether the cookie was blocked or allowed");
});
}
add_task(async function testCookiesSubView() {
info("Testing cookies subview with reject tracking cookies.");
Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER);
await assertSitesListed(true, false, false);
info("Testing cookies subview with reject third party cookies.");
Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN);
await assertSitesListed(true, true, false);
info("Testing cookies subview with reject all cookies.");
Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_REJECT);
await assertSitesListed(true, true, true);
info("Testing cookies subview with accept all cookies.");
Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_ACCEPT);
await assertSitesListed(false, false, false);
Services.prefs.clearUserPref(TPC_PREF);
});
add_task(async function testCookiesSubViewAllowed() {
Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER);
let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin("http://trackertest.org/");
Services.perms.addFromPrincipal(principal, "cookie", Services.perms.ALLOW_ACTION);
await BrowserTestUtils.withNewTab(COOKIE_PAGE, async function(browser) {
await openIdentityPopup();
let categoryItem =
document.getElementById("identity-popup-content-blocking-category-cookies");
ok(BrowserTestUtils.is_visible(categoryItem), "TP category item is visible");
let cookiesView = document.getElementById("identity-popup-cookiesView");
let viewShown = BrowserTestUtils.waitForEvent(cookiesView, "ViewShown");
categoryItem.click();
await viewShown;
ok(true, "Cookies view was shown");
let listHeaders = cookiesView.querySelectorAll(".identity-popup-cookiesView-list-header");
is(listHeaders.length, 1, "We have 1 list header");
is(listHeaders[0].textContent,
gNavigatorBundle.getString(`contentBlocking.cookiesView.trackers.label`),
"The list header is for tracking cookies.");
let listItems = cookiesView.querySelectorAll(".identity-popup-content-blocking-list-item");
is(listItems.length, 1, "We have 1 cookie in the list");
let listItem = listItems[0];
let label = listItem.querySelector(".identity-popup-content-blocking-list-host-label");
is(label.value, "http://trackertest.org", "Has an item for trackertest.org");
ok(BrowserTestUtils.is_visible(listItem), "List item is visible");
ok(listItem.classList.contains("allowed"), "Indicates whether the cookie was blocked or allowed");
let button = listItem.querySelector(".identity-popup-permission-remove-button");
ok(BrowserTestUtils.is_visible(button), "Permission remove button is visible");
button.click();
is(Services.perms.testExactPermissionFromPrincipal(principal, "cookie"), Services.perms.UNKNOWN_ACTION, "Button click should remove cookie pref.");
ok(!listItem.classList.contains("allowed"), "Has removed the allowed class");
});
Services.prefs.clearUserPref(TPC_PREF);
});

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

@ -1,5 +1,22 @@
const URL = "http://mochi.test:8888/browser/browser/base/content/test/trackingUI/file_trackingUI_fetch.html";
function waitForSecurityChange(numChanges = 1) {
return new Promise(resolve => {
let n = 0;
let listener = {
onSecurityChange() {
n = n + 1;
info("Received onSecurityChange event " + n + " of " + numChanges);
if (n >= numChanges) {
gBrowser.removeProgressListener(listener);
resolve();
}
},
};
gBrowser.addProgressListener(listener);
});
}
add_task(async function test_fetch() {
await SpecialPowers.pushPrefEnv({ set: [
["privacy.trackingprotection.enabled", true],

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

@ -5,6 +5,8 @@
const TP_PREF = "privacy.trackingprotection.enabled";
const TPC_PREF = "network.cookie.cookieBehavior";
const TP_UI_PREF = "browser.contentblocking.trackingprotection.control-center.ui.enabled";
const RT_UI_PREF = "browser.contentblocking.rejecttrackers.control-center.ui.enabled";
const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
async function waitAndAssertPreferencesShown() {
@ -64,6 +66,8 @@ add_task(async function testOpenPreferencesFromAddBlockingButtons() {
SpecialPowers.pushPrefEnv({set: [
[TP_PREF, false],
[TPC_PREF, Ci.nsICookieService.BEHAVIOR_ACCEPT],
[TP_UI_PREF, true],
[RT_UI_PREF, true],
]});
await BrowserTestUtils.withNewTab(TRACKING_PAGE, async function() {

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

@ -57,6 +57,12 @@ function testTrackingPage(window) {
ok(hidden("#identity-popup-content-blocking-not-detected"), "blocking not detected label is hidden");
ok(!hidden("#identity-popup-content-blocking-detected"), "blocking detected label is visible");
ok(!hidden("#identity-popup-content-blocking-category-list"), "category list is visible");
ok(hidden("#identity-popup-content-blocking-category-tracking-protection > #identity-popup-content-blocking-tracking-protection-label-allowed"),
"TP category item is not showing the allowed label");
ok(!hidden("#identity-popup-content-blocking-category-tracking-protection > #identity-popup-content-blocking-tracking-protection-label-blocked"),
"TP category item is set to blocked");
}
function testTrackingPageUnblocked() {
@ -75,6 +81,12 @@ function testTrackingPageUnblocked() {
ok(hidden("#identity-popup-content-blocking-not-detected"), "blocking not detected label is hidden");
ok(!hidden("#identity-popup-content-blocking-detected"), "blocking detected label is visible");
ok(!hidden("#identity-popup-content-blocking-category-list"), "category list is visible");
ok(!hidden("#identity-popup-content-blocking-category-tracking-protection > #identity-popup-content-blocking-tracking-protection-label-allowed"),
"TP category item is showing the allowed label");
ok(hidden("#identity-popup-content-blocking-category-tracking-protection > #identity-popup-content-blocking-tracking-protection-label-blocked"),
"TP category item is not set to blocked");
}
add_task(async function testExceptionAddition() {

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

@ -26,6 +26,13 @@ add_task(async function setup() {
});
});
function openIdentityPopup() {
let mainView = document.getElementById("identity-popup-mainView");
let viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
gIdentityHandler._identityBox.click();
return viewShown;
}
add_task(async function testReportBreakageVisibility() {
let scenarios = [
{
@ -179,9 +186,11 @@ add_task(async function testReportBreakage() {
let prefs = [
"privacy.trackingprotection.enabled",
"privacy.trackingprotection.pbmode.enabled",
"browser.contentblocking.trackingprotection.control-center.ui.enabled",
"urlclassifier.trackingTable",
"network.http.referer.defaultPolicy",
"network.http.referer.defaultPolicy.pbmode",
"browser.contentblocking.rejecttrackers.control-center.ui.enabled",
"network.cookie.cookieBehavior",
"network.cookie.lifetimePolicy",
"privacy.restrict3rdpartystorage.expiration",

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

@ -56,6 +56,7 @@ function testBenignPage() {
info("Non-tracking content must not be blocked");
ok(!ContentBlocking.content.hasAttribute("detected"), "no trackers are detected");
ok(!ContentBlocking.content.hasAttribute("hasException"), "content shows no exception");
ok(!ContentBlocking.content.hasAttribute("active"), "content is not active");
ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is not active");
ok(!ContentBlocking.iconBox.hasAttribute("hasException"), "icon box shows no exception");
@ -67,16 +68,14 @@ function testBenignPage() {
ok(!hidden("#identity-popup-content-blocking-not-detected"), "blocking not detected label is visible");
ok(hidden("#identity-popup-content-blocking-detected"), "blocking detected label is hidden");
ok(hidden("#identity-popup-content-blocking-category-cookies"),
"Not showing cookie restrictions category");
ok(hidden("#identity-popup-content-blocking-category-tracking-protection"),
"Not showing trackers category");
ok(hidden("#identity-popup-content-blocking-category-list"), "category list is hidden");
}
function testBenignPageWithException() {
info("Non-tracking content must not be blocked");
ok(!ContentBlocking.content.hasAttribute("detected"), "no trackers are detected");
ok(ContentBlocking.content.hasAttribute("hasException"), "content shows exception");
ok(!ContentBlocking.content.hasAttribute("active"), "content is not active");
ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is not active");
ok(ContentBlocking.iconBox.hasAttribute("hasException"), "shield shows exception");
@ -89,10 +88,7 @@ function testBenignPageWithException() {
ok(!hidden("#identity-popup-content-blocking-not-detected"), "blocking not detected label is visible");
ok(hidden("#identity-popup-content-blocking-detected"), "blocking detected label is hidden");
ok(hidden("#identity-popup-content-blocking-category-cookies"),
"Not showing cookie restrictions category");
ok(hidden("#identity-popup-content-blocking-category-tracking-protection"),
"Not showing trackers category");
ok(hidden("#identity-popup-content-blocking-category-list"), "category list is hidden");
}
function areTrackersBlocked(isPrivateBrowsing) {
@ -110,6 +106,8 @@ function testTrackingPage(window) {
let blockedByTP = areTrackersBlocked(isPrivateBrowsing);
is(BrowserTestUtils.is_visible(ContentBlocking.iconBox), blockedByTP,
"icon box is" + (blockedByTP ? "" : " not") + " visible");
is(ContentBlocking.content.hasAttribute("active"), blockedByTP,
"content is" + (blockedByTP ? "" : " not") + " active");
is(ContentBlocking.iconBox.hasAttribute("active"), blockedByTP,
"shield is" + (blockedByTP ? "" : " not") + " active");
ok(!ContentBlocking.iconBox.hasAttribute("hasException"), "icon box shows no exception");
@ -133,10 +131,32 @@ function testTrackingPage(window) {
ok(hidden("#identity-popup-content-blocking-not-detected"), "blocking not detected label is hidden");
ok(!hidden("#identity-popup-content-blocking-detected"), "blocking detected label is visible");
ok(!hidden("#identity-popup-content-blocking-category-tracking-protection"),
"Showing trackers category");
ok(!hidden("#identity-popup-content-blocking-category-cookies"),
"Showing cookie restrictions category");
ok(!hidden("#identity-popup-content-blocking-category-list"), "category list is visible");
let cookiesBlocked = Services.prefs.getIntPref(TPC_PREF) == Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER;
if (cookiesBlocked) {
let category = "#identity-popup-content-blocking-category-3rdpartycookies";
is(hidden(category + " > .identity-popup-content-blocking-category-add-blocking"), blockedByTP,
"Category item is" + (blockedByTP ? " not" : "") + " showing add blocking");
is(hidden(category + " > .identity-popup-content-blocking-category-state-label"), !blockedByTP,
"Category item is" + (blockedByTP ? "" : " not") + " set to blocked");
ok(hidden("#identity-popup-content-blocking-category-label-default"),
"Not showing default cookie restrictions label.");
ok(!hidden("#identity-popup-content-blocking-category-label-trackers"),
"Showing trackers cookie restrictions label.");
} else {
let category = "#identity-popup-content-blocking-category-tracking-protection";
is(hidden(category + " > #identity-popup-content-blocking-tracking-protection-label-allowed"), blockedByTP,
"Category item is" + (blockedByTP ? " not" : "") + " showing the allowed label");
is(!hidden(category + " > #identity-popup-content-blocking-tracking-protection-label-blocked"), blockedByTP,
"Category item is" + (blockedByTP ? "" : " not") + " set to blocked");
ok(hidden("#identity-popup-content-blocking-category-label-trackers"),
"Not showing trackers cookie restrictions label.");
ok(!hidden("#identity-popup-content-blocking-category-label-default"),
"Showing default cookie restrictions label.");
}
}
function testTrackingPageUnblocked(blockedByTP, window) {
@ -144,6 +164,7 @@ function testTrackingPageUnblocked(blockedByTP, window) {
ok(ContentBlocking.content.hasAttribute("detected"), "trackers are detected");
ok(ContentBlocking.content.hasAttribute("hasException"), "content shows exception");
ok(!ContentBlocking.content.hasAttribute("active"), "content is not active");
ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is not active");
ok(ContentBlocking.iconBox.hasAttribute("hasException"), "shield shows exception");
is(ContentBlocking.iconBox.getAttribute("tooltiptext"),
@ -156,10 +177,23 @@ function testTrackingPageUnblocked(blockedByTP, window) {
ok(hidden("#identity-popup-content-blocking-not-detected"), "blocking not detected label is hidden");
ok(!hidden("#identity-popup-content-blocking-detected"), "blocking detected label is visible");
ok(!hidden("#identity-popup-content-blocking-category-tracking-protection"),
"Showing trackers category");
ok(!hidden("#identity-popup-content-blocking-category-cookies"),
"Showing cookie restrictions category");
ok(!hidden("#identity-popup-content-blocking-category-list"), "category list is visible");
let cookiesBlocked = Services.prefs.getIntPref(TPC_PREF) == Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER;
if (cookiesBlocked) {
let category = "#identity-popup-content-blocking-category-3rdpartycookies";
is(hidden(category + " > .identity-popup-content-blocking-category-add-blocking"), blockedByTP,
"Category item is" + (blockedByTP ? " not" : "") + " showing add blocking");
ok(!hidden("#identity-popup-content-blocking-category-tracking-protection > #identity-popup-content-blocking-tracking-protection-label-allowed"),
"TP category item is showing the allowed label");
} else {
let category = "#identity-popup-content-blocking-category-tracking-protection";
// If there's an exception we always show the "Allowed" label.
ok(!hidden(category + " > #identity-popup-content-blocking-tracking-protection-label-allowed"),
"Category item is showing the allowed label");
ok(hidden(category + " > #identity-popup-content-blocking-tracking-protection-label-blocked"),
"Category item is not set to blocked");
}
}
async function testContentBlocking(tab) {

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

@ -50,7 +50,7 @@ add_task(async function testShieldHistogram() {
getShieldHistogram().clear();
await promiseTabLoadEvent(tab, BENIGN_PAGE);
is(getShieldCounts()[0], 1, "Page loads without tracking");
is(getShieldCounts()[0], 2, "Page loads without tracking");
await promiseTabLoadEvent(tab, TRACKING_PAGE);
// Note that right now the shield histogram is not measuring what
@ -86,7 +86,10 @@ add_task(async function testIdentityPopupEvents() {
Services.telemetry.clearEvents();
await openIdentityPopup();
let { gIdentityHandler } = gBrowser.ownerGlobal;
let promisePanelOpen = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "popupshown");
gIdentityHandler._identityBox.click();
await promisePanelOpen;
let events = Services.telemetry.snapshotEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true).parent;
let openEvents = events.filter(
@ -96,7 +99,9 @@ add_task(async function testIdentityPopupEvents() {
await promiseTabLoadEvent(tab, TRACKING_PAGE);
await openIdentityPopup();
promisePanelOpen = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "popupshown");
gIdentityHandler._identityBox.click();
await promisePanelOpen;
events = Services.telemetry.snapshotEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true).parent;
openEvents = events.filter(

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

@ -9,15 +9,36 @@ const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/
const TP_PREF = "privacy.trackingprotection.enabled";
add_task(async function setup() {
// Avoid the content blocking tour interfering with our tests by popping up.
await SpecialPowers.pushPrefEnv({set: [[ContentBlocking.prefIntroCount, ContentBlocking.MAX_INTROS]]});
await UrlClassifierTestUtils.addTestTrackers();
registerCleanupFunction(() => {
UrlClassifierTestUtils.cleanupTestTrackers();
});
});
function openIdentityPopup() {
let mainView = document.getElementById("identity-popup-mainView");
let viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
gIdentityHandler._identityBox.click();
return viewShown;
}
function waitForSecurityChange(counter) {
return new Promise(resolve => {
let webProgressListener = {
onStateChange: () => {},
onStatusChange: () => {},
onLocationChange: () => {},
onSecurityChange: (webProgress, request, oldState, state) => {
if (--counter == 0) {
gBrowser.removeProgressListener(webProgressListener);
resolve(counter);
}
},
onProgressChange: () => {},
QueryInterface: ChromeUtils.generateQI([Ci.nsIWebProgressListener]),
};
gBrowser.addProgressListener(webProgressListener);
});
}
async function assertSitesListed(blocked) {
await BrowserTestUtils.withNewTab(TRACKING_PAGE, async function(browser) {
await openIdentityPopup();
@ -32,7 +53,7 @@ async function assertSitesListed(blocked) {
ok(true, "Trackers view was shown");
let listItems = trackersView.querySelectorAll(".identity-popup-content-blocking-list-item");
let listItems = document.querySelectorAll(".identity-popup-trackersView-list-item");
is(listItems.length, 1, "We have 1 tracker in the list");
let strictInfo = document.getElementById("identity-popup-trackersView-strict-info");
@ -63,7 +84,7 @@ async function assertSitesListed(blocked) {
ok(true, "Trackers view was shown");
listItems = Array.from(trackersView.querySelectorAll(".identity-popup-content-blocking-list-item"));
listItems = Array.from(document.querySelectorAll(".identity-popup-trackersView-list-item"));
is(listItems.length, 2, "We have 2 trackers in the list");
let listItem = listItems.find(item => item.querySelector("label").value == "trackertest.org");
@ -81,19 +102,19 @@ async function assertSitesListed(blocked) {
}
add_task(async function testTrackersSubView() {
info("Testing trackers subview with TP disabled.");
Services.prefs.setBoolPref(TP_PREF, false);
await assertSitesListed(false);
info("Testing trackers subview with TP enabled.");
Services.prefs.setBoolPref(TP_PREF, true);
await assertSitesListed(true);
info("Testing trackers subview with TP enabled and a CB exception.");
let uri = Services.io.newURI("https://tracking.example.org");
Services.perms.add(uri, "trackingprotection", Services.perms.ALLOW_ACTION);
await assertSitesListed(false);
info("Testing trackers subview with TP enabled and a CB exception removed.");
Services.perms.remove(uri, "trackingprotection");
await assertSitesListed(true);
Services.prefs.clearUserPref(TP_PREF);
});
add_task(function cleanup() {
Services.prefs.clearUserPref(TP_PREF);
UrlClassifierTestUtils.cleanupTestTrackers();
});

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

@ -32,27 +32,3 @@ function promiseTabLoadEvent(tab, url) {
return loaded;
}
function openIdentityPopup() {
let mainView = document.getElementById("identity-popup-mainView");
let viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
gIdentityHandler._identityBox.click();
return viewShown;
}
function waitForSecurityChange(numChanges = 1) {
return new Promise(resolve => {
let n = 0;
let listener = {
onSecurityChange() {
n = n + 1;
info("Received onSecurityChange event " + n + " of " + numChanges);
if (n >= numChanges) {
gBrowser.removeProgressListener(listener);
resolve(n);
}
},
};
gBrowser.addProgressListener(listener);
});
}

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

@ -18,20 +18,5 @@ onmessage = event => {
document.body.appendChild(ifr);
}
break;
case "first-party-cookie": {
// Since the content blocking log doesn't seem to get updated for
// top-level cookies right now, we just create an iframe with the
// first party domain...
let ifr = document.createElement("iframe");
ifr.src = "http://not-tracking.example.com/browser/browser/base/content/test/trackingUI/cookieServer.sjs";
document.body.appendChild(ifr);
}
break;
case "third-party-cookie": {
let ifr = document.createElement("iframe");
ifr.src = "https://test1.example.org/browser/browser/base/content/test/trackingUI/cookieServer.sjs";
document.body.appendChild(ifr);
}
break;
}
};

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

@ -74,20 +74,27 @@
<vbox id="identity-popup-content-blocking-category-list">
<toolbarbutton id="identity-popup-content-blocking-category-tracking-protection"
onclick="ContentBlocking.showTrackersSubview()"
class="identity-popup-content-blocking-category" align="center">
onclick="ContentBlocking.showTrackersSubview()"
class="identity-popup-content-blocking-category" align="center">
<image class="identity-popup-content-blocking-category-icon tracking-protection-icon"/>
<label flex="1" class="identity-popup-content-blocking-category-label">&contentBlocking.trackingProtection3.label;</label>
<label flex="1" id="identity-popup-content-blocking-tracking-protection-state-label" class="identity-popup-content-blocking-category-state-label"/>
<label flex="1" id="identity-popup-content-blocking-tracking-protection-label-allowed"
class="identity-popup-content-blocking-category-state-label">&contentBlocking.trackingProtection.allowed.label;</label>
<label flex="1" id="identity-popup-content-blocking-tracking-protection-label-blocked"
class="identity-popup-content-blocking-category-state-label">&contentBlocking.trackingProtection.blocked.label;</label>
</toolbarbutton>
<toolbarbutton id="identity-popup-content-blocking-category-cookies"
onclick="ContentBlocking.showCookiesSubview()"
class="identity-popup-content-blocking-category" align="center">
<hbox id="identity-popup-content-blocking-category-3rdpartycookies"
class="identity-popup-content-blocking-category" align="center" role="group">
<image class="identity-popup-content-blocking-category-icon thirdpartycookies-icon"/>
<label flex="1" id="identity-popup-content-blocking-category-label-default"
class="identity-popup-content-blocking-category-label">&contentBlocking.cookies.label;</label>
<label flex="1" id="identity-popup-content-blocking-cookies-state-label" class="identity-popup-content-blocking-category-state-label"/>
</toolbarbutton>
class="identity-popup-content-blocking-category-label">&contentBlocking.3rdPartyCookies.label;</label>
<label flex="1" id="identity-popup-content-blocking-category-label-trackers"
hidden="true" class="identity-popup-content-blocking-category-label">&contentBlocking.3rdPartyCookies.trackers.label;</label>
<label flex="1" class="identity-popup-content-blocking-category-state-label">&contentBlocking.3rdPartyCookies.blocking.label;</label>
<label flex="1" class="identity-popup-content-blocking-category-add-blocking text-link"
id="identity-popup-3rdpartycookies-add-blocking"
onclick="ContentBlocking.openPreferences('identityPopup-CB-3rdpartycookies'); gIdentityHandler.recordClick('cookies_add_blocking');">&contentBlocking.3rdPartyCookies.add.label;</label>
</hbox>
</vbox>
<button id="tracking-action-unblock"
@ -239,7 +246,7 @@
role="document"
title="&contentBlocking.trackersView.label;"
descriptionheightworkaround="true">
<vbox id="identity-popup-trackersView-list" class="identity-popup-content-blocking-list">
<vbox id="identity-popup-trackersView-list">
</vbox>
<hbox id="identity-popup-trackersView-strict-info">
<image/>
@ -253,21 +260,6 @@
</vbox>
</panelview>
<!-- Cookies SubView -->
<panelview id="identity-popup-cookiesView"
role="document"
title="&contentBlocking.cookiesView.label;"
descriptionheightworkaround="true">
<vbox id="identity-popup-cookiesView-list" class="identity-popup-content-blocking-list">
</vbox>
<vbox class="identity-popup-footer">
<button id="identity-popup-cookiesView-settings-button"
label="&contentBlocking.manageSettings.label;"
accesskey="&contentBlocking.manageSettings.accesskey;"
oncommand="ContentBlocking.openPreferences();"/>
</vbox>
</panelview>
<!-- Report Breakage SubView -->
<panelview id="identity-popup-breakageReportView"
title="&contentBlocking.breakageReportView.label;"

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

@ -9,7 +9,7 @@ support-files =
[browser_UrlbarInput_formatValue.js]
[browser_UrlbarInput_overflow.js]
[browser_UrlbarInput_tooltip.js]
skip-if = os == "win" || asan # Bug 1511655 and bug 1504985
skip-if = asan # Bug 1504985
[browser_UrlbarInput_trimURLs.js]
subsuite = clipboard
[browser_UrlbarInput_unit.js]

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

@ -969,6 +969,37 @@ you can use these alternative items. Otherwise, their values should be empty. -
<!ENTITY contentBlocking.notDetected "No blockable content detected on this page.">
<!ENTITY contentBlocking.trackingProtection3.label "Trackers">
<!-- LOCALIZATION NOTE (contentBlocking.trackingProtection.allowed.label):
This label signals that this type of content blocking is turned
OFF and is not blocking tracker content, so this is not
a positive thing. It forms the end of the (imaginary) sentence
"Trackers [are] Allowed"-->
<!ENTITY contentBlocking.trackingProtection.allowed.label "Allowed">
<!-- LOCALIZATION NOTE (contentBlocking.trackingProtection.blocked.label):
This label signals that this type of content blocking is turned
ON and is successfully blocking tracker content, so this is
a positive thing. It forms the end of the (imaginary) sentence
"Trackers [are] Blocked"-->
<!ENTITY contentBlocking.trackingProtection.blocked.label "Blocked">
<!ENTITY contentBlocking.3rdPartyCookies.label "Third-Party Cookies">
<!ENTITY contentBlocking.3rdPartyCookies.trackers.label "Tracking Cookies">
<!-- LOCALIZATION NOTE (contentBlocking.3rdPartyCookies.blocked.label):
This label signals that this type of content blocking is turned
ON and is successfully blocking third-party cookies, so this is
a positive thing. It forms the end of the (imaginary) sentence
"Third-Party Cookies [are] Blocked"-->
<!ENTITY contentBlocking.3rdPartyCookies.blocked.label "Blocked">
<!-- LOCALIZATION NOTE (contentBlocking.tranckingProtection.blocking.label):
This label signals that this type of content blocking is turned
ON, so this is a positive thing. It forms the verb in the (imaginary) sentence
"Firefox is blocking Third-Party Cookies"-->
<!ENTITY contentBlocking.3rdPartyCookies.blocking.label "Blocking">
<!-- LOCALIZATION NOTE (contentBlocking.3rdPartyCookies.add.label):
This is displayed as a link to preferences, where the user can add
this specific type of content blocking. When this text is shown
the type of content blocking is currently not enabled. -->
<!ENTITY contentBlocking.3rdPartyCookies.add.label "Add Blocking…">
<!ENTITY contentBlocking.manageSettings.label "Manage Content Blocking">
<!ENTITY contentBlocking.manageSettings.accesskey "M">
@ -976,9 +1007,6 @@ you can use these alternative items. Otherwise, their values should be empty. -
<!ENTITY contentBlocking.trackersView.label "Trackers">
<!ENTITY contentBlocking.trackersView.strictInfo.label "To block all trackers, set content blocking to “Strict”.">
<!ENTITY contentBlocking.cookies.label "Cookies">
<!ENTITY contentBlocking.cookiesView.label "Cookies and Site Data">
<!ENTITY contentBlocking.openBreakageReportView2.label "Report a problem">
<!ENTITY contentBlocking.breakageReportView.label "Report Problems">
<!ENTITY contentBlocking.breakageReportView2.description "Content blocking can cause problems with some websites. When you report problems, youll help make &brandShortName; better for everyone. (This will send a URL as well as information about your browser settings to Mozilla.)">

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

@ -489,49 +489,6 @@ contentBlocking.category.standard=Standard
contentBlocking.category.strict=Strict
contentBlocking.category.custom=Custom
# LOCALIZATION NOTE (contentBlocking.trackers.allowed.label):
# This label signals that this type of content blocking is turned
# OFF and is not blocking tracker content, so this is not
# a positive thing. It forms the end of the (imaginary) sentence
# "Trackers [are] Allowed"
contentBlocking.trackers.allowed.label=Allowed
# LOCALIZATION NOTE (contentBlocking.trackers.blocked.label):
# This label signals that this type of content blocking is turned
# ON and is successfully blocking tracker content, so this is
# a positive thing. It forms the end of the (imaginary) sentence
# "Trackers [are] Blocked"
contentBlocking.trackers.blocked.label=Blocked
# LOCALIZATION NOTE (contentBlocking.trackersView.blocked.label):
# This label is shown next to a tracker in the trackers subview.
# It forms the end of the (imaginary) sentence "www.example.com [was] Blocked"
contentBlocking.trackersView.blocked.label=Blocked
# LOCALIZATION NOTE (contentBlocking.cookies.allowed.label):
# This label signals that this type of content blocking is turned
# OFF and is not blocking tracker content, so this is not
# a positive thing. It forms the end of the (imaginary) sentence
# "Cookies [are] Allowed"
contentBlocking.cookies.allowed.label=Allowed
contentBlocking.cookies.trackersBlocked.label=Tracking Cookies Blocked
contentBlocking.cookies.3rdPartyBlocked.label=Third-Party Cookies Blocked
contentBlocking.cookies.unvisitedBlocked.label=Unvisited Site Cookies Blocked
contentBlocking.cookies.allBlocked.label=All Cookies Blocked
contentBlocking.cookiesView.firstParty.label=From This Site
contentBlocking.cookiesView.trackers.label=Tracking Cookies
contentBlocking.cookiesView.thirdParty.label=Third-Party Cookies
# LOCALIZATION NOTE (contentBlocking.cookiesView.allowed.label):
# This label is shown next to a cookie origin in the cookies subview.
# It forms the end of the (imaginary) sentence "www.example.com [was] Allowed"
contentBlocking.cookiesView.allowed.label=Allowed
# LOCALIZATION NOTE (contentBlocking.cookiesView.blocked.label):
# This label is shown next to a cookie origin in the cookies subview.
# It forms the end of the (imaginary) sentence "www.example.com [was] Blocked"
contentBlocking.cookiesView.blocked.label=Blocked
# LOCALIZATION NOTE (contentBlocking.cookiesView.removeButton.tooltip): %S is the domain of the site.
contentBlocking.cookiesView.removeButton.tooltip=Clear cookie exception for %S
# LOCALIZATION NOTE (contentBlocking.intro.title): %S is brandShortName.
contentBlocking.intro.title=New in %S: Content Blocking
# LOCALIZATION NOTE (contentBlocking.v1.intro.description): %S is brandShortName.

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

@ -165,8 +165,7 @@
.identity-popup-footer,
.tracking-protection-button,
#identity-popup-trackersView-strict-info > label,
.identity-popup-cookiesView-list-header,
.identity-popup-content-blocking-list-item > label,
.identity-popup-trackersView-list-item > label,
#identity-popup-mainView-panel-header > label,
#identity-popup-trackersView > .panel-header,
#identity-popup-securityView > .panel-header,
@ -404,95 +403,66 @@ description#identity-popup-content-verifier,
background-image: url("chrome://browser/skin/controlcenter/tracking-protection.svg");
}
.identity-popup-content-blocking-category {
#identity-popup-content-blocking-category-tracking-protection {
/* Overwrite toolbarbutton styles */
-moz-appearance: none;
margin: 0;
padding-inline-start: 0;
}
.identity-popup-content-blocking-category:-moz-focusring,
.identity-popup-content-blocking-category:hover {
#identity-popup-content-blocking-category-tracking-protection:-moz-focusring,
#identity-popup-content-blocking-category-tracking-protection:hover {
border-radius: 2px;
background-color: var(--arrowpanel-dimmed);
}
.identity-popup-content-blocking-category:hover:active {
background-color: var(--arrowpanel-dimmed-further);
}
.identity-popup-content-blocking-category::after {
#identity-popup-content-blocking-category-tracking-protection:hover:active {
background-color: var(--arrowpanel-dimmed-even-further);
}
#identity-popup-content-blocking-category-tracking-protection::after {
content: url(chrome://browser/skin/back-12.svg);
-moz-context-properties: fill, fill-opacity;
transform: scaleX(-1) translateY(1px);
float: right;
}
.identity-popup-content-blocking-category:-moz-locale-dir(rtl)::after {
#identity-popup-content-blocking-category-tracking-protection:-moz-locale-dir(rtl)::after {
transform: scaleX(1) translateY(1px);
}
/* This subview could get filled with a lot of trackers, set a maximum size
* and allow it to scroll vertically.*/
#identity-popup-cookiesView,
#identity-popup-trackersView {
max-height: 600px;
}
.identity-popup-cookiesView-list-header {
color: var(--panel-disabled-color);
margin: 5px 0;
}
.identity-popup-content-blocking-list {
#identity-popup-trackersView-list {
padding: 5px 20px;
-moz-box-flex: 1;
overflow: auto;
}
.identity-popup-content-blocking-list-item {
.identity-popup-trackersView-list-item {
margin: 5px 0;
overflow: hidden;
-moz-box-align: center;
}
.identity-popup-content-blocking-list-item:not(.allowed) {
color: var(--panel-disabled-color);
.identity-popup-trackersView-list-item > label {
/* Limit to full width - container padding - icon width - icon margin */
max-width: calc(var(--identity-popup-width) - 40px - 16px - 10px);
}
.identity-popup-content-blocking-list-host-label {
-moz-box-flex: 1;
}
.identity-popup-content-blocking-list-state-label {
-moz-box-flex: 1;
text-align: end;
margin-inline-start: 5px;
margin-inline-end: 2px;
}
.identity-popup-trackersView-icon,
.identity-popup-cookiesView-icon {
.identity-popup-trackersView-list-item > image {
list-style-image: url(chrome://browser/skin/controlcenter/trackers-disabled.svg);
margin-inline-end: 10px;
-moz-context-properties: fill, fill-opacity;
}
.identity-popup-trackersView-icon {
list-style-image: url(chrome://browser/skin/controlcenter/trackers-disabled.svg);
}
.identity-popup-trackersView-icon.allowed {
.identity-popup-trackersView-list-item.allowed > image {
list-style-image: url(chrome://browser/skin/controlcenter/trackers.svg);
}
.identity-popup-cookiesView-icon {
list-style-image: url(chrome://browser/skin/controlcenter/3rdpartycookies-disabled.svg);
}
.identity-popup-cookiesView-icon.allowed {
list-style-image: url(chrome://browser/skin/controlcenter/3rdpartycookies.svg);
}
#identity-popup-trackersView-strict-info {
min-height: 40px;
/* Limit to full width - margin */
@ -527,20 +497,51 @@ description#identity-popup-content-verifier,
margin-top: 10px;
}
/* Don't show the categories when no trackers were detected. */
#identity-popup-content-blocking-content:not([detected]) > #identity-popup-content-blocking-category-list {
display: none;
}
/* Show the "detected"/"not detected" message depending on the content state. */
#identity-popup-content-blocking-content:not([detected]) > #identity-popup-content-blocking-detected,
#identity-popup-content-blocking-content[detected] > #identity-popup-content-blocking-not-detected {
display: none;
}
.identity-popup-content-blocking-category-state-label {
display: none;
}
/* TODO: This will be cleaned up by bug 1501992 */
/* Hide the state label unless we blocked something only for third party cookies */
#identity-popup-content-blocking-content:not([hasException]) #identity-popup-content-blocking-category-3rdpartycookies.blocked .identity-popup-content-blocking-category-state-label,
/* For trackers, either show a "blocked" or "allowed" label depending on the state. */
#identity-popup-content-blocking-content:not([hasException]) #identity-popup-content-blocking-category-tracking-protection.blocked > #identity-popup-content-blocking-tracking-protection-label-blocked,
#identity-popup-content-blocking-category-tracking-protection:not(.blocked) > #identity-popup-content-blocking-tracking-protection-label-allowed,
#identity-popup-content-blocking-content[hasException] #identity-popup-content-blocking-tracking-protection-label-allowed {
display: -moz-box;
}
.identity-popup-content-blocking-category.blocked .identity-popup-content-blocking-category-add-blocking {
display: none;
}
.tracking-protection-icon {
list-style-image: url(chrome://browser/skin/controlcenter/trackers.svg);
}
#identity-popup-content-blocking-category-tracking-protection.blocked > .tracking-protection-icon {
list-style-image: url(chrome://browser/skin/controlcenter/trackers-disabled.svg);
}
.thirdpartycookies-icon {
list-style-image: url(chrome://browser/skin/controlcenter/3rdpartycookies.svg);
}
#identity-popup-content-blocking-category-3rdpartycookies.blocked > .thirdpartycookies-icon {
list-style-image: url(chrome://browser/skin/controlcenter/3rdpartycookies-disabled.svg);
}
/* Content Blocking action button */
.tracking-protection-button {
@ -597,15 +598,15 @@ description#identity-popup-content-verifier,
/* Hide the "report breakage" button if we have not detected any trackers
* (except if the user added an exception, in which case they might still
* (especially!) want to report the breakage). */
#identity-popup-content-blocking-content:not([blocking]):not([hasException]) #identity-popup-content-blocking-report-breakage {
#identity-popup-content-blocking-content:not([active]):not([hasException]) #identity-popup-content-blocking-report-breakage {
display: none;
}
/* Show the right action buttons depending on content state */
/* Offer to temporarily add an exception in private mode. */
#main-window:not([privatebrowsingmode]) #identity-popup-content-blocking-content[blocking]:not([hasException]) > #tracking-action-unblock,
#main-window:not([privatebrowsingmode]) #identity-popup-content-blocking-content[active]:not([hasException]) > #tracking-action-unblock,
/* Offer to permanently add an exception in normal mode. */
#main-window[privatebrowsingmode] #identity-popup-content-blocking-content[blocking]:not([hasException]) > #tracking-action-unblock-private,
#main-window[privatebrowsingmode] #identity-popup-content-blocking-content[active]:not([hasException]) > #tracking-action-unblock-private,
/* If there's an exception just offer to remove the exception again. */
#identity-popup-content-blocking-content[hasException] > #tracking-action-block {
display: -moz-box;
@ -717,7 +718,6 @@ description#identity-popup-content-verifier,
background-color: transparent;
color: inherit;
opacity: 0.6;
margin-inline-start: 2px;
}
.identity-popup-permission-remove-button > .button-box {

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

@ -628,6 +628,8 @@ security.ui.identitypopup:
- firefox
click:
objects: [
"tp_add_blocking",
"cookies_add_blocking",
"cb_prefs_button",
"clear_sitedata",
"unblock",