зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1562575 - Part 3 - Test updates for content blocking section in browser-siteProtections.js. r=ewright
Differential Revision: https://phabricator.services.mozilla.com/D37557 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
0d0bc26e56
Коммит
70071d243e
|
@ -3,6 +3,12 @@
|
|||
|
||||
/* Basic UI tests for the protections panel */
|
||||
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"ContentBlockingAllowList",
|
||||
"resource://gre/modules/ContentBlockingAllowList.jsm"
|
||||
);
|
||||
|
||||
add_task(async function setup() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
|
@ -54,43 +60,7 @@ add_task(async function testToggleSwitch() {
|
|||
!gProtectionsHandler._protectionsPopupTPSwitch.hasAttribute("enabled"),
|
||||
"TP Switch should be disabled"
|
||||
);
|
||||
Services.perms.remove(
|
||||
ContentBlocking._baseURIForChannelClassifier,
|
||||
"trackingprotection"
|
||||
);
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
add_task(async function testSiteNotWorking() {
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(
|
||||
gBrowser,
|
||||
"https://example.com"
|
||||
);
|
||||
await openProtectionsPanel();
|
||||
let viewShownPromise = BrowserTestUtils.waitForEvent(
|
||||
gProtectionsHandler._protectionsPopupMultiView,
|
||||
"ViewShown"
|
||||
);
|
||||
document.getElementById("protections-popup-tp-switch-breakage-link").click();
|
||||
let event = await viewShownPromise;
|
||||
is(
|
||||
event.originalTarget.id,
|
||||
"protections-popup-siteNotWorkingView",
|
||||
"Site Not Working? view should be shown"
|
||||
);
|
||||
viewShownPromise = BrowserTestUtils.waitForEvent(
|
||||
gProtectionsHandler._protectionsPopupMultiView,
|
||||
"ViewShown"
|
||||
);
|
||||
document
|
||||
.getElementById("protections-popup-siteNotWorkingView-sendReport")
|
||||
.click();
|
||||
event = await viewShownPromise;
|
||||
is(
|
||||
event.originalTarget.id,
|
||||
"protections-popup-sendReportView",
|
||||
"Send Report view should be shown"
|
||||
);
|
||||
ContentBlockingAllowList.remove(tab.linkedBrowser);
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
|
@ -284,9 +254,6 @@ add_task(async function testToggleSwitchFlow() {
|
|||
await popuphiddenPromise;
|
||||
|
||||
// Clean up the TP state.
|
||||
Services.perms.remove(
|
||||
ContentBlocking._baseURIForChannelClassifier,
|
||||
"trackingprotection"
|
||||
);
|
||||
ContentBlockingAllowList.remove(tab.linkedBrowser);
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
|
|
@ -34,10 +34,13 @@ async function testTrackingProtectionAnimation(tabbrowser) {
|
|||
tabbrowser,
|
||||
BENIGN_PAGE
|
||||
);
|
||||
let ContentBlocking = tabbrowser.ownerGlobal.ContentBlocking;
|
||||
let gProtectionsHandler = tabbrowser.ownerGlobal.gProtectionsHandler;
|
||||
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("active"), "iconBox not active");
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("animate"), "iconBox not animating");
|
||||
ok(!gProtectionsHandler.iconBox.hasAttribute("active"), "iconBox not active");
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("animate"),
|
||||
"iconBox not animating"
|
||||
);
|
||||
|
||||
info("Load a test page containing tracking elements");
|
||||
let trackingTab = await BrowserTestUtils.openNewForegroundTab(
|
||||
|
@ -45,10 +48,10 @@ async function testTrackingProtectionAnimation(tabbrowser) {
|
|||
TRACKING_PAGE
|
||||
);
|
||||
|
||||
ok(ContentBlocking.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(ContentBlocking.iconBox.hasAttribute("animate"), "iconBox animating");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("animate"), "iconBox animating");
|
||||
await BrowserTestUtils.waitForEvent(
|
||||
ContentBlocking.animatedIcon,
|
||||
gProtectionsHandler.animatedIcon,
|
||||
"animationend"
|
||||
);
|
||||
|
||||
|
@ -58,10 +61,10 @@ async function testTrackingProtectionAnimation(tabbrowser) {
|
|||
COOKIE_PAGE
|
||||
);
|
||||
|
||||
ok(ContentBlocking.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(ContentBlocking.iconBox.hasAttribute("animate"), "iconBox animating");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("animate"), "iconBox animating");
|
||||
await BrowserTestUtils.waitForEvent(
|
||||
ContentBlocking.animatedIcon,
|
||||
gProtectionsHandler.animatedIcon,
|
||||
"animationend"
|
||||
);
|
||||
|
||||
|
@ -70,24 +73,33 @@ async function testTrackingProtectionAnimation(tabbrowser) {
|
|||
tabbrowser.selectedTab = benignTab;
|
||||
await securityChanged;
|
||||
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("active"), "iconBox not active");
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("animate"), "iconBox not animating");
|
||||
ok(!gProtectionsHandler.iconBox.hasAttribute("active"), "iconBox not active");
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("animate"),
|
||||
"iconBox not animating"
|
||||
);
|
||||
|
||||
info("Switch from benign -> tracking tab");
|
||||
securityChanged = waitForSecurityChange(1, tabbrowser.ownerGlobal);
|
||||
tabbrowser.selectedTab = trackingTab;
|
||||
await securityChanged;
|
||||
|
||||
ok(ContentBlocking.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("animate"), "iconBox not animating");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("animate"),
|
||||
"iconBox not animating"
|
||||
);
|
||||
|
||||
info("Switch from tracking -> tracking cookies tab");
|
||||
securityChanged = waitForSecurityChange(1, tabbrowser.ownerGlobal);
|
||||
tabbrowser.selectedTab = trackingCookiesTab;
|
||||
await securityChanged;
|
||||
|
||||
ok(ContentBlocking.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("animate"), "iconBox not animating");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("animate"),
|
||||
"iconBox not animating"
|
||||
);
|
||||
|
||||
info("Reload tracking cookies tab");
|
||||
securityChanged = waitForSecurityChange(1, tabbrowser.ownerGlobal);
|
||||
|
@ -98,10 +110,10 @@ async function testTrackingProtectionAnimation(tabbrowser) {
|
|||
tabbrowser.reload();
|
||||
await Promise.all([securityChanged, contentBlockingEvent]);
|
||||
|
||||
ok(ContentBlocking.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(ContentBlocking.iconBox.hasAttribute("animate"), "iconBox animating");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("animate"), "iconBox animating");
|
||||
await BrowserTestUtils.waitForEvent(
|
||||
ContentBlocking.animatedIcon,
|
||||
gProtectionsHandler.animatedIcon,
|
||||
"animationend"
|
||||
);
|
||||
|
||||
|
@ -112,10 +124,10 @@ async function testTrackingProtectionAnimation(tabbrowser) {
|
|||
tabbrowser.reload();
|
||||
await Promise.all([securityChanged, contentBlockingEvent]);
|
||||
|
||||
ok(ContentBlocking.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(ContentBlocking.iconBox.hasAttribute("animate"), "iconBox animating");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("animate"), "iconBox animating");
|
||||
await BrowserTestUtils.waitForEvent(
|
||||
ContentBlocking.animatedIcon,
|
||||
gProtectionsHandler.animatedIcon,
|
||||
"animationend"
|
||||
);
|
||||
|
||||
|
@ -128,8 +140,11 @@ async function testTrackingProtectionAnimation(tabbrowser) {
|
|||
let result = await Promise.race([securityChanged, timeoutPromise]);
|
||||
is(result, undefined, "No securityChange events should be received");
|
||||
|
||||
ok(ContentBlocking.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("animate"), "iconBox not animating");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("animate"),
|
||||
"iconBox not animating"
|
||||
);
|
||||
|
||||
info("Inject tracking element inside tracking tab");
|
||||
securityChanged = waitForSecurityChange(1, tabbrowser.ownerGlobal);
|
||||
|
@ -140,8 +155,11 @@ async function testTrackingProtectionAnimation(tabbrowser) {
|
|||
result = await Promise.race([securityChanged, timeoutPromise]);
|
||||
is(result, undefined, "No securityChange events should be received");
|
||||
|
||||
ok(ContentBlocking.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("animate"), "iconBox not animating");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("animate"),
|
||||
"iconBox not animating"
|
||||
);
|
||||
|
||||
tabbrowser.selectedTab = trackingCookiesTab;
|
||||
|
||||
|
@ -154,8 +172,11 @@ async function testTrackingProtectionAnimation(tabbrowser) {
|
|||
result = await Promise.race([securityChanged, timeoutPromise]);
|
||||
is(result, undefined, "No securityChange events should be received");
|
||||
|
||||
ok(ContentBlocking.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("animate"), "iconBox not animating");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("animate"),
|
||||
"iconBox not animating"
|
||||
);
|
||||
|
||||
info("Inject tracking element inside tracking cookies tab");
|
||||
securityChanged = waitForSecurityChange(1, tabbrowser.ownerGlobal);
|
||||
|
@ -166,8 +187,11 @@ async function testTrackingProtectionAnimation(tabbrowser) {
|
|||
result = await Promise.race([securityChanged, timeoutPromise]);
|
||||
is(result, undefined, "No securityChange events should be received");
|
||||
|
||||
ok(ContentBlocking.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("animate"), "iconBox not animating");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("active"), "iconBox active");
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("animate"),
|
||||
"iconBox not animating"
|
||||
);
|
||||
|
||||
while (tabbrowser.tabs.length > 1) {
|
||||
tabbrowser.removeCurrentTab();
|
||||
|
@ -177,8 +201,11 @@ async function testTrackingProtectionAnimation(tabbrowser) {
|
|||
add_task(async function testNormalBrowsing() {
|
||||
await UrlClassifierTestUtils.addTestTrackers();
|
||||
|
||||
let ContentBlocking = gBrowser.ownerGlobal.ContentBlocking;
|
||||
ok(ContentBlocking, "CB is attached to the browser window");
|
||||
let gProtectionsHandler = gBrowser.ownerGlobal.gProtectionsHandler;
|
||||
ok(
|
||||
gProtectionsHandler,
|
||||
"gProtectionsHandler is attached to the browser window"
|
||||
);
|
||||
let TrackingProtection = gBrowser.ownerGlobal.TrackingProtection;
|
||||
ok(TrackingProtection, "TP is attached to the browser window");
|
||||
let ThirdPartyCookies = gBrowser.ownerGlobal.ThirdPartyCookies;
|
||||
|
@ -204,8 +231,11 @@ add_task(async function testPrivateBrowsing() {
|
|||
});
|
||||
let tabbrowser = privateWin.gBrowser;
|
||||
|
||||
let ContentBlocking = tabbrowser.ownerGlobal.ContentBlocking;
|
||||
ok(ContentBlocking, "CB is attached to the private window");
|
||||
let gProtectionsHandler = tabbrowser.ownerGlobal.gProtectionsHandler;
|
||||
ok(
|
||||
gProtectionsHandler,
|
||||
"gProtectionsHandler is attached to the private window"
|
||||
);
|
||||
let TrackingProtection = tabbrowser.ownerGlobal.TrackingProtection;
|
||||
ok(TrackingProtection, "TP is attached to the private window");
|
||||
let ThirdPartyCookies = tabbrowser.ownerGlobal.ThirdPartyCookies;
|
||||
|
|
|
@ -46,7 +46,10 @@ add_task(async function testBackgroundTabs() {
|
|||
"Foreground tab has the correct content blocking event."
|
||||
);
|
||||
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is not active");
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("active"),
|
||||
"shield is not active"
|
||||
);
|
||||
|
||||
await BrowserTestUtils.switchTab(gBrowser, backgroundTab);
|
||||
|
||||
|
@ -62,7 +65,7 @@ add_task(async function testBackgroundTabs() {
|
|||
"Foreground tab still has the correct content blocking event."
|
||||
);
|
||||
|
||||
ok(ContentBlocking.iconBox.hasAttribute("active"), "shield is active");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("active"), "shield is active");
|
||||
|
||||
gBrowser.removeTab(backgroundTab);
|
||||
gBrowser.removeTab(tab);
|
||||
|
|
|
@ -44,7 +44,7 @@ async function assertSitesListed(
|
|||
let [tab] = await Promise.all([promise, waitForContentBlockingEvent(count)]);
|
||||
let browser = tab.linkedBrowser;
|
||||
|
||||
await openIdentityPopup();
|
||||
await openProtectionsPopup();
|
||||
|
||||
let categoryItem = document.getElementById(
|
||||
"identity-popup-content-blocking-category-cookies"
|
||||
|
@ -112,7 +112,7 @@ async function assertSitesListed(
|
|||
);
|
||||
}
|
||||
|
||||
let mainView = document.getElementById("identity-popup-mainView");
|
||||
let mainView = document.getElementById("protections-popup-mainView");
|
||||
viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
|
||||
let backButton = cookiesView.querySelector(".subviewbutton-back");
|
||||
backButton.click();
|
||||
|
@ -284,7 +284,7 @@ add_task(async function testCookiesSubViewAllowed() {
|
|||
});
|
||||
let [tab] = await Promise.all([promise, waitForContentBlockingEvent(3)]);
|
||||
|
||||
await openIdentityPopup();
|
||||
await openProtectionsPopup();
|
||||
|
||||
let categoryItem = document.getElementById(
|
||||
"identity-popup-content-blocking-category-cookies"
|
||||
|
@ -400,7 +400,7 @@ add_task(async function testCookiesSubViewAllowedHeuristic() {
|
|||
await new Promise(resolve => waitForFocus(resolve, popup));
|
||||
await new Promise(resolve => waitForFocus(resolve, window));
|
||||
|
||||
await openIdentityPopup();
|
||||
await openProtectionsPopup();
|
||||
|
||||
let categoryItem = document.getElementById(
|
||||
"identity-popup-content-blocking-category-cookies"
|
||||
|
@ -483,7 +483,7 @@ add_task(async function testCookiesSubViewBlockedDoublyNested() {
|
|||
});
|
||||
let [tab] = await Promise.all([promise, waitForContentBlockingEvent(3)]);
|
||||
|
||||
await openIdentityPopup();
|
||||
await openProtectionsPopup();
|
||||
|
||||
let categoryItem = document.getElementById(
|
||||
"identity-popup-content-blocking-category-cookies"
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* eslint-disable mozilla/no-arbitrary-setTimeout */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
|
@ -50,22 +49,22 @@ async function testIdentityState(hasException) {
|
|||
false,
|
||||
TRACKING_PAGE
|
||||
);
|
||||
ContentBlocking.disableForCurrentPage();
|
||||
gProtectionsHandler.disableForCurrentPage();
|
||||
await loaded;
|
||||
}
|
||||
|
||||
ok(
|
||||
!ContentBlocking.content.hasAttribute("detected"),
|
||||
!gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"cryptominers are not detected"
|
||||
);
|
||||
if (hasException) {
|
||||
ok(
|
||||
!BrowserTestUtils.is_hidden(ContentBlocking.iconBox),
|
||||
BrowserTestUtils.is_visible(gProtectionsHandler.iconBox),
|
||||
"icon box is visible to indicate the exception"
|
||||
);
|
||||
} else {
|
||||
ok(
|
||||
BrowserTestUtils.is_hidden(ContentBlocking.iconBox),
|
||||
BrowserTestUtils.is_hidden(gProtectionsHandler.iconBox),
|
||||
"icon box is not visible"
|
||||
);
|
||||
}
|
||||
|
@ -78,13 +77,16 @@ async function testIdentityState(hasException) {
|
|||
|
||||
await promise;
|
||||
|
||||
ok(ContentBlocking.content.hasAttribute("detected"), "trackers are detected");
|
||||
ok(
|
||||
BrowserTestUtils.is_visible(ContentBlocking.iconBox),
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"trackers are detected"
|
||||
);
|
||||
ok(
|
||||
BrowserTestUtils.is_visible(gProtectionsHandler.iconBox),
|
||||
"icon box is visible"
|
||||
);
|
||||
is(
|
||||
ContentBlocking.iconBox.hasAttribute("hasException"),
|
||||
gProtectionsHandler.iconBox.hasAttribute("hasException"),
|
||||
hasException,
|
||||
"Shows an exception when appropriate"
|
||||
);
|
||||
|
@ -95,7 +97,7 @@ async function testIdentityState(hasException) {
|
|||
false,
|
||||
TRACKING_PAGE
|
||||
);
|
||||
ContentBlocking.enableForCurrentPage();
|
||||
gProtectionsHandler.enableForCurrentPage();
|
||||
await loaded;
|
||||
}
|
||||
|
||||
|
@ -119,7 +121,7 @@ async function testSubview(hasException) {
|
|||
false,
|
||||
TRACKING_PAGE
|
||||
);
|
||||
ContentBlocking.disableForCurrentPage();
|
||||
gProtectionsHandler.disableForCurrentPage();
|
||||
await loaded;
|
||||
}
|
||||
|
||||
|
@ -129,7 +131,7 @@ async function testSubview(hasException) {
|
|||
});
|
||||
await promise;
|
||||
|
||||
await openIdentityPopup();
|
||||
await openProtectionsPopup();
|
||||
|
||||
let categoryItem = document.getElementById(
|
||||
"identity-popup-content-blocking-category-cryptominers"
|
||||
|
@ -157,7 +159,7 @@ async function testSubview(hasException) {
|
|||
"Indicates the miner was blocked or allowed"
|
||||
);
|
||||
|
||||
let mainView = document.getElementById("identity-popup-mainView");
|
||||
let mainView = document.getElementById("protections-popup-mainView");
|
||||
viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
|
||||
let backButton = subview.querySelector(".subviewbutton-back");
|
||||
backButton.click();
|
||||
|
@ -171,7 +173,7 @@ async function testSubview(hasException) {
|
|||
false,
|
||||
TRACKING_PAGE
|
||||
);
|
||||
ContentBlocking.enableForCurrentPage();
|
||||
gProtectionsHandler.enableForCurrentPage();
|
||||
await loaded;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,16 +18,19 @@ add_task(async function test_fetch() {
|
|||
});
|
||||
await contentBlockingEvent;
|
||||
|
||||
let ContentBlocking = newTabBrowser.ownerGlobal.ContentBlocking;
|
||||
ok(ContentBlocking, "got CB object");
|
||||
let gProtectionsHandler = newTabBrowser.ownerGlobal.gProtectionsHandler;
|
||||
ok(gProtectionsHandler, "got CB object");
|
||||
|
||||
ok(
|
||||
ContentBlocking.content.hasAttribute("detected"),
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"has detected content blocking"
|
||||
);
|
||||
ok(ContentBlocking.iconBox.hasAttribute("active"), "icon box is active");
|
||||
ok(
|
||||
gProtectionsHandler.iconBox.hasAttribute("active"),
|
||||
"icon box is active"
|
||||
);
|
||||
is(
|
||||
ContentBlocking.iconBox.getAttribute("tooltiptext"),
|
||||
gProtectionsHandler.iconBox.getAttribute("tooltiptext"),
|
||||
gNavigatorBundle.getString("trackingProtection.icon.activeTooltip"),
|
||||
"correct tooltip"
|
||||
);
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* eslint-disable mozilla/no-arbitrary-setTimeout */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
|
@ -50,22 +49,22 @@ async function testIdentityState(hasException) {
|
|||
false,
|
||||
TRACKING_PAGE
|
||||
);
|
||||
ContentBlocking.disableForCurrentPage();
|
||||
gProtectionsHandler.disableForCurrentPage();
|
||||
await loaded;
|
||||
}
|
||||
|
||||
ok(
|
||||
!ContentBlocking.content.hasAttribute("detected"),
|
||||
!gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"fingerprinters are not detected"
|
||||
);
|
||||
if (hasException) {
|
||||
ok(
|
||||
!BrowserTestUtils.is_hidden(ContentBlocking.iconBox),
|
||||
!BrowserTestUtils.is_hidden(gProtectionsHandler.iconBox),
|
||||
"icon box is visible to indicate the exception"
|
||||
);
|
||||
} else {
|
||||
ok(
|
||||
BrowserTestUtils.is_hidden(ContentBlocking.iconBox),
|
||||
BrowserTestUtils.is_hidden(gProtectionsHandler.iconBox),
|
||||
"icon box is not visible"
|
||||
);
|
||||
}
|
||||
|
@ -78,13 +77,16 @@ async function testIdentityState(hasException) {
|
|||
|
||||
await promise;
|
||||
|
||||
ok(ContentBlocking.content.hasAttribute("detected"), "trackers are detected");
|
||||
ok(
|
||||
BrowserTestUtils.is_visible(ContentBlocking.iconBox),
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"trackers are detected"
|
||||
);
|
||||
ok(
|
||||
BrowserTestUtils.is_visible(gProtectionsHandler.iconBox),
|
||||
"icon box is visible"
|
||||
);
|
||||
is(
|
||||
ContentBlocking.iconBox.hasAttribute("hasException"),
|
||||
gProtectionsHandler.iconBox.hasAttribute("hasException"),
|
||||
hasException,
|
||||
"Shows an exception when appropriate"
|
||||
);
|
||||
|
@ -95,7 +97,7 @@ async function testIdentityState(hasException) {
|
|||
false,
|
||||
TRACKING_PAGE
|
||||
);
|
||||
ContentBlocking.enableForCurrentPage();
|
||||
gProtectionsHandler.enableForCurrentPage();
|
||||
await loaded;
|
||||
}
|
||||
|
||||
|
@ -119,7 +121,7 @@ async function testSubview(hasException) {
|
|||
false,
|
||||
TRACKING_PAGE
|
||||
);
|
||||
ContentBlocking.disableForCurrentPage();
|
||||
gProtectionsHandler.disableForCurrentPage();
|
||||
await loaded;
|
||||
}
|
||||
|
||||
|
@ -129,7 +131,7 @@ async function testSubview(hasException) {
|
|||
});
|
||||
await promise;
|
||||
|
||||
await openIdentityPopup();
|
||||
await openProtectionsPopup();
|
||||
|
||||
let categoryItem = document.getElementById(
|
||||
"identity-popup-content-blocking-category-fingerprinters"
|
||||
|
@ -157,7 +159,7 @@ async function testSubview(hasException) {
|
|||
"Indicates the fingerprinter was blocked or allowed"
|
||||
);
|
||||
|
||||
let mainView = document.getElementById("identity-popup-mainView");
|
||||
let mainView = document.getElementById("protections-popup-mainView");
|
||||
viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
|
||||
let backButton = subview.querySelector(".subviewbutton-back");
|
||||
backButton.click();
|
||||
|
@ -171,7 +173,7 @@ async function testSubview(hasException) {
|
|||
false,
|
||||
TRACKING_PAGE
|
||||
);
|
||||
ContentBlocking.enableForCurrentPage();
|
||||
gProtectionsHandler.enableForCurrentPage();
|
||||
await loaded;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,11 @@ const TPC_PREF = "network.cookie.cookieBehavior";
|
|||
const TRACKING_PAGE =
|
||||
"http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
|
||||
|
||||
async function waitAndAssertPreferencesShown(_spotlight) {
|
||||
async function waitAndAssertPreferencesShown(_spotlight, identityPopup) {
|
||||
await BrowserTestUtils.waitForEvent(
|
||||
gIdentityHandler._identityPopup,
|
||||
identityPopup
|
||||
? gIdentityHandler._identityPopup
|
||||
: gProtectionsHandler._protectionsPopup,
|
||||
"popuphidden"
|
||||
);
|
||||
await TestUtils.waitForCondition(
|
||||
|
@ -49,16 +51,11 @@ add_task(async function setup() {
|
|||
});
|
||||
});
|
||||
|
||||
// Tests that pressing the content blocking preferences icon in the identity popup
|
||||
// Tests that pressing the content blocking preferences icon in the protections popup
|
||||
// links to about:preferences
|
||||
add_task(async function testOpenPreferencesFromCBPrefsButton() {
|
||||
await BrowserTestUtils.withNewTab("https://example.com", async function() {
|
||||
let promisePanelOpen = BrowserTestUtils.waitForEvent(
|
||||
gIdentityHandler._identityPopup,
|
||||
"popupshown"
|
||||
);
|
||||
gIdentityHandler._identityBox.click();
|
||||
await promisePanelOpen;
|
||||
await openProtectionsPopup();
|
||||
|
||||
let preferencesButton = document.getElementById(
|
||||
"tracking-protection-preferences-button"
|
||||
|
@ -79,12 +76,7 @@ add_task(async function testOpenPreferencesFromCBPrefsButton() {
|
|||
// links to about:preferences
|
||||
add_task(async function testOpenPreferencesFromPermissionsPrefsButton() {
|
||||
await BrowserTestUtils.withNewTab("https://example.com", async function() {
|
||||
let promisePanelOpen = BrowserTestUtils.waitForEvent(
|
||||
gIdentityHandler._identityPopup,
|
||||
"popupshown"
|
||||
);
|
||||
gIdentityHandler._identityBox.click();
|
||||
await promisePanelOpen;
|
||||
await openIdentityPopup();
|
||||
|
||||
let preferencesButton = document.getElementById(
|
||||
"identity-popup-permission-preferences-button"
|
||||
|
@ -97,7 +89,7 @@ add_task(async function testOpenPreferencesFromPermissionsPrefsButton() {
|
|||
|
||||
Services.telemetry.clearEvents();
|
||||
|
||||
let shown = waitAndAssertPreferencesShown("permissions");
|
||||
let shown = waitAndAssertPreferencesShown("permissions", true);
|
||||
preferencesButton.click();
|
||||
await shown;
|
||||
|
||||
|
@ -121,12 +113,7 @@ add_task(async function testOpenPreferencesFromTrackersSubview() {
|
|||
Services.prefs.setBoolPref(TP_PREF, true);
|
||||
|
||||
await BrowserTestUtils.withNewTab(TRACKING_PAGE, async function() {
|
||||
let promisePanelOpen = BrowserTestUtils.waitForEvent(
|
||||
gIdentityHandler._identityPopup,
|
||||
"popupshown"
|
||||
);
|
||||
gIdentityHandler._identityBox.click();
|
||||
await promisePanelOpen;
|
||||
await openProtectionsPopup();
|
||||
|
||||
let categoryItem = document.getElementById(
|
||||
"identity-popup-content-blocking-category-tracking-protection"
|
||||
|
@ -168,12 +155,7 @@ add_task(async function testOpenPreferencesFromCookiesSubview() {
|
|||
);
|
||||
|
||||
await BrowserTestUtils.withNewTab(TRACKING_PAGE, async function() {
|
||||
let promisePanelOpen = BrowserTestUtils.waitForEvent(
|
||||
gIdentityHandler._identityPopup,
|
||||
"popupshown"
|
||||
);
|
||||
gIdentityHandler._identityBox.click();
|
||||
await promisePanelOpen;
|
||||
await openProtectionsPopup();
|
||||
|
||||
let categoryItem = document.getElementById(
|
||||
"identity-popup-content-blocking-category-cookies"
|
||||
|
|
|
@ -9,13 +9,13 @@ const TRACKING_PAGE =
|
|||
"http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
|
||||
const DTSCBN_PREF = "dom.testing.sync-content-blocking-notifications";
|
||||
var TrackingProtection = null;
|
||||
var ContentBlocking = null;
|
||||
var gProtectionsHandler = null;
|
||||
var browser = null;
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref(TP_PB_PREF);
|
||||
Services.prefs.clearUserPref(DTSCBN_PREF);
|
||||
ContentBlocking = TrackingProtection = browser = null;
|
||||
gProtectionsHandler = TrackingProtection = browser = null;
|
||||
UrlClassifierTestUtils.cleanupTestTrackers();
|
||||
});
|
||||
|
||||
|
@ -26,9 +26,9 @@ function hidden(sel) {
|
|||
return display === "none";
|
||||
}
|
||||
|
||||
function identityPopupState() {
|
||||
function protectionsPopupState() {
|
||||
let win = browser.ownerGlobal;
|
||||
return win.document.getElementById("identity-popup").state;
|
||||
return win.document.getElementById("protections-popup").state;
|
||||
}
|
||||
|
||||
function clickButton(sel) {
|
||||
|
@ -39,43 +39,30 @@ function clickButton(sel) {
|
|||
|
||||
function testTrackingPage(window) {
|
||||
info("Tracking content must be blocked");
|
||||
ok(ContentBlocking.content.hasAttribute("detected"), "trackers are detected");
|
||||
ok(
|
||||
!ContentBlocking.content.hasAttribute("hasException"),
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"trackers are detected"
|
||||
);
|
||||
ok(
|
||||
!gProtectionsHandler._protectionsPopup.hasAttribute("hasException"),
|
||||
"content shows no exception"
|
||||
);
|
||||
|
||||
ok(
|
||||
BrowserTestUtils.is_visible(ContentBlocking.iconBox),
|
||||
BrowserTestUtils.is_visible(gProtectionsHandler.iconBox),
|
||||
"icon box is visible"
|
||||
);
|
||||
ok(ContentBlocking.iconBox.hasAttribute("active"), "shield is active");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("active"), "shield is active");
|
||||
ok(
|
||||
!ContentBlocking.iconBox.hasAttribute("hasException"),
|
||||
!gProtectionsHandler.iconBox.hasAttribute("hasException"),
|
||||
"icon box shows no exception"
|
||||
);
|
||||
is(
|
||||
ContentBlocking.iconBox.getAttribute("tooltiptext"),
|
||||
gProtectionsHandler.iconBox.getAttribute("tooltiptext"),
|
||||
gNavigatorBundle.getString("trackingProtection.icon.activeTooltip"),
|
||||
"correct tooltip"
|
||||
);
|
||||
|
||||
ok(hidden("#tracking-action-block"), "blockButton is hidden");
|
||||
|
||||
if (PrivateBrowsingUtils.isWindowPrivate(window)) {
|
||||
ok(hidden("#tracking-action-unblock"), "unblockButton is hidden");
|
||||
ok(
|
||||
!hidden("#tracking-action-unblock-private"),
|
||||
"unblockButtonPrivate is visible"
|
||||
);
|
||||
} else {
|
||||
ok(!hidden("#tracking-action-unblock"), "unblockButton is visible");
|
||||
ok(
|
||||
hidden("#tracking-action-unblock-private"),
|
||||
"unblockButtonPrivate is hidden"
|
||||
);
|
||||
}
|
||||
|
||||
ok(
|
||||
hidden("#identity-popup-content-blocking-not-detected"),
|
||||
"blocking not detected label is hidden"
|
||||
|
@ -88,29 +75,30 @@ function testTrackingPage(window) {
|
|||
|
||||
function testTrackingPageUnblocked() {
|
||||
info("Tracking content must be white-listed and not blocked");
|
||||
ok(ContentBlocking.content.hasAttribute("detected"), "trackers are detected");
|
||||
ok(
|
||||
ContentBlocking.content.hasAttribute("hasException"),
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"trackers are detected"
|
||||
);
|
||||
ok(
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("hasException"),
|
||||
"content shows exception"
|
||||
);
|
||||
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is active");
|
||||
ok(!gProtectionsHandler.iconBox.hasAttribute("active"), "shield is active");
|
||||
ok(
|
||||
ContentBlocking.iconBox.hasAttribute("hasException"),
|
||||
gProtectionsHandler.iconBox.hasAttribute("hasException"),
|
||||
"shield shows exception"
|
||||
);
|
||||
is(
|
||||
ContentBlocking.iconBox.getAttribute("tooltiptext"),
|
||||
gProtectionsHandler.iconBox.getAttribute("tooltiptext"),
|
||||
gNavigatorBundle.getString("trackingProtection.icon.disabledTooltip"),
|
||||
"correct tooltip"
|
||||
);
|
||||
|
||||
ok(
|
||||
BrowserTestUtils.is_visible(ContentBlocking.iconBox),
|
||||
BrowserTestUtils.is_visible(gProtectionsHandler.iconBox),
|
||||
"icon box is visible"
|
||||
);
|
||||
ok(!hidden("#tracking-action-block"), "blockButton is visible");
|
||||
ok(hidden("#tracking-action-unblock"), "unblockButton is hidden");
|
||||
|
||||
ok(
|
||||
hidden("#identity-popup-content-blocking-not-detected"),
|
||||
|
@ -135,8 +123,8 @@ add_task(async function testExceptionAddition() {
|
|||
waitForStateStop: true,
|
||||
});
|
||||
|
||||
ContentBlocking = browser.ownerGlobal.ContentBlocking;
|
||||
ok(ContentBlocking, "CB is attached to the private window");
|
||||
gProtectionsHandler = browser.ownerGlobal.gProtectionsHandler;
|
||||
ok(gProtectionsHandler, "CB is attached to the private window");
|
||||
TrackingProtection = browser.ownerGlobal.TrackingProtection;
|
||||
ok(TrackingProtection, "TP is attached to the private window");
|
||||
|
||||
|
@ -153,8 +141,8 @@ add_task(async function testExceptionAddition() {
|
|||
|
||||
info("Disable TP for the page (which reloads the page)");
|
||||
let tabReloadPromise = promiseTabLoadEvent(tab);
|
||||
clickButton("#tracking-action-unblock");
|
||||
is(identityPopupState(), "closed", "Identity popup is closed");
|
||||
gProtectionsHandler.disableForCurrentPage();
|
||||
is(protectionsPopupState(), "closed", "protections popup is closed");
|
||||
|
||||
await tabReloadPromise;
|
||||
testTrackingPageUnblocked();
|
||||
|
@ -183,8 +171,8 @@ add_task(async function testExceptionPersistence() {
|
|||
waitForStateStop: true,
|
||||
});
|
||||
|
||||
ContentBlocking = browser.ownerGlobal.ContentBlocking;
|
||||
ok(ContentBlocking, "CB is attached to the private window");
|
||||
gProtectionsHandler = browser.ownerGlobal.gProtectionsHandler;
|
||||
ok(gProtectionsHandler, "CB is attached to the private window");
|
||||
TrackingProtection = browser.ownerGlobal.TrackingProtection;
|
||||
ok(TrackingProtection, "TP is attached to the private window");
|
||||
|
||||
|
@ -200,8 +188,8 @@ add_task(async function testExceptionPersistence() {
|
|||
|
||||
info("Disable TP for the page (which reloads the page)");
|
||||
let tabReloadPromise = promiseTabLoadEvent(tab);
|
||||
clickButton("#tracking-action-unblock");
|
||||
is(identityPopupState(), "closed", "Identity popup is closed");
|
||||
gProtectionsHandler.disableForCurrentPage();
|
||||
is(protectionsPopupState(), "closed", "protections popup is closed");
|
||||
|
||||
await Promise.all([
|
||||
tabReloadPromise,
|
||||
|
|
|
@ -28,12 +28,7 @@ let { Preferences } = ChromeUtils.import(
|
|||
add_task(async function setup() {
|
||||
await UrlClassifierTestUtils.addTestTrackers();
|
||||
|
||||
let oldCanRecord = Services.telemetry.canRecordExtended;
|
||||
Services.telemetry.canRecordExtended = true;
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
Services.telemetry.canRecordExtended = oldCanRecord;
|
||||
|
||||
// Clear prefs that are touched in this test again for sanity.
|
||||
Services.prefs.clearUserPref(TP_PREF);
|
||||
Services.prefs.clearUserPref(CB_PREF);
|
||||
|
@ -132,10 +127,10 @@ add_task(async function testReportBreakageVisibility() {
|
|||
}
|
||||
|
||||
await BrowserTestUtils.withNewTab(scenario.url, async function() {
|
||||
await openIdentityPopup();
|
||||
await openProtectionsPopup();
|
||||
|
||||
let reportBreakageButton = document.getElementById(
|
||||
"identity-popup-content-blocking-report-breakage"
|
||||
"protections-popup-tp-switch-breakage-link"
|
||||
);
|
||||
await TestUtils.waitForCondition(
|
||||
() =>
|
||||
|
@ -158,44 +153,40 @@ add_task(async function testReportBreakageCancel() {
|
|||
Services.prefs.setBoolPref(PREF_REPORT_BREAKAGE_ENABLED, true);
|
||||
|
||||
await BrowserTestUtils.withNewTab(TRACKING_PAGE, async function() {
|
||||
await openIdentityPopup();
|
||||
await openProtectionsPopup();
|
||||
|
||||
Services.telemetry.clearEvents();
|
||||
|
||||
let reportBreakageButton = document.getElementById(
|
||||
"identity-popup-content-blocking-report-breakage"
|
||||
let siteNotWorkingButton = document.getElementById(
|
||||
"protections-popup-tp-switch-breakage-link"
|
||||
);
|
||||
ok(
|
||||
BrowserTestUtils.is_visible(reportBreakageButton),
|
||||
"report breakage button is visible"
|
||||
BrowserTestUtils.is_visible(siteNotWorkingButton),
|
||||
"site not working button is visible"
|
||||
);
|
||||
let reportBreakageView = document.getElementById(
|
||||
"identity-popup-breakageReportView"
|
||||
let siteNotWorkingView = document.getElementById(
|
||||
"protections-popup-siteNotWorkingView"
|
||||
);
|
||||
let viewShown = BrowserTestUtils.waitForEvent(
|
||||
reportBreakageView,
|
||||
siteNotWorkingView,
|
||||
"ViewShown"
|
||||
);
|
||||
reportBreakageButton.click();
|
||||
siteNotWorkingButton.click();
|
||||
await viewShown;
|
||||
|
||||
let events = Services.telemetry.snapshotEvents(
|
||||
Ci.nsITelemetry.DATASET_PRERELEASE_CHANNELS
|
||||
).parent;
|
||||
let clickEvents = events.filter(
|
||||
e =>
|
||||
e[1] == "security.ui.identitypopup" &&
|
||||
e[2] == "click" &&
|
||||
e[3] == "report_breakage"
|
||||
let sendReportButton = document.getElementById(
|
||||
"protections-popup-siteNotWorkingView-sendReport"
|
||||
);
|
||||
is(clickEvents.length, 1, "recorded telemetry for the click");
|
||||
let sendReportView = document.getElementById(
|
||||
"protections-popup-sendReportView"
|
||||
);
|
||||
viewShown = BrowserTestUtils.waitForEvent(sendReportView, "ViewShown");
|
||||
sendReportButton.click();
|
||||
await viewShown;
|
||||
|
||||
ok(true, "Report breakage view was shown");
|
||||
|
||||
let mainView = document.getElementById("identity-popup-mainView");
|
||||
viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
|
||||
viewShown = BrowserTestUtils.waitForEvent(siteNotWorkingView, "ViewShown");
|
||||
let cancelButton = document.getElementById(
|
||||
"identity-popup-breakageReportView-cancel"
|
||||
"protections-popup-sendReportView-cancel"
|
||||
);
|
||||
cancelButton.click();
|
||||
await viewShown;
|
||||
|
@ -277,42 +268,54 @@ async function testReportBreakage(url, tags) {
|
|||
Services.prefs.setBoolPref(PREF_REPORT_BREAKAGE_ENABLED, true);
|
||||
Services.prefs.setStringPref(PREF_REPORT_BREAKAGE_URL, path);
|
||||
|
||||
await openIdentityPopup();
|
||||
await openProtectionsPopup();
|
||||
|
||||
let siteNotWorkingButton = document.getElementById(
|
||||
"protections-popup-tp-switch-breakage-link"
|
||||
);
|
||||
await TestUtils.waitForCondition(
|
||||
() => BrowserTestUtils.is_visible(siteNotWorkingButton),
|
||||
"site not working button is visible"
|
||||
);
|
||||
let siteNotWorkingView = document.getElementById(
|
||||
"protections-popup-siteNotWorkingView"
|
||||
);
|
||||
let viewShown = BrowserTestUtils.waitForEvent(
|
||||
siteNotWorkingView,
|
||||
"ViewShown"
|
||||
);
|
||||
siteNotWorkingButton.click();
|
||||
await viewShown;
|
||||
|
||||
let sendReportButton = document.getElementById(
|
||||
"protections-popup-siteNotWorkingView-sendReport"
|
||||
);
|
||||
let sendReportView = document.getElementById(
|
||||
"protections-popup-sendReportView"
|
||||
);
|
||||
viewShown = BrowserTestUtils.waitForEvent(sendReportView, "ViewShown");
|
||||
sendReportButton.click();
|
||||
await viewShown;
|
||||
|
||||
ok(true, "Report breakage view was shown");
|
||||
|
||||
let comments = document.getElementById(
|
||||
"identity-popup-breakageReportView-collection-comments"
|
||||
"protections-popup-sendReportView-collection-comments"
|
||||
);
|
||||
is(comments.value, "", "Comments textarea should initially be empty");
|
||||
|
||||
let reportBreakageButton = document.getElementById(
|
||||
"identity-popup-content-blocking-report-breakage"
|
||||
);
|
||||
await TestUtils.waitForCondition(
|
||||
() => BrowserTestUtils.is_visible(reportBreakageButton),
|
||||
"report breakage button is visible"
|
||||
);
|
||||
let reportBreakageView = document.getElementById(
|
||||
"identity-popup-breakageReportView"
|
||||
);
|
||||
let viewShown = BrowserTestUtils.waitForEvent(
|
||||
reportBreakageView,
|
||||
"ViewShown"
|
||||
);
|
||||
reportBreakageButton.click();
|
||||
await viewShown;
|
||||
|
||||
let submitButton = document.getElementById(
|
||||
"identity-popup-breakageReportView-submit"
|
||||
"protections-popup-sendReportView-submit"
|
||||
);
|
||||
let reportURL = document.getElementById(
|
||||
"identity-popup-breakageReportView-collection-url"
|
||||
"protections-popup-sendReportView-collection-url"
|
||||
).value;
|
||||
|
||||
is(reportURL, url, "Shows the correct URL in the report UI.");
|
||||
|
||||
// Make sure that sending the report closes the identity popup.
|
||||
let popuphidden = BrowserTestUtils.waitForEvent(
|
||||
gIdentityHandler._identityPopup,
|
||||
gProtectionsHandler._protectionsPopup,
|
||||
"popuphidden"
|
||||
);
|
||||
|
||||
|
|
|
@ -24,14 +24,14 @@ const TRACKING_PAGE =
|
|||
"http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
|
||||
const COOKIE_PAGE =
|
||||
"http://not-tracking.example.com/browser/browser/base/content/test/trackingUI/cookiePage.html";
|
||||
var ContentBlocking = null;
|
||||
var gProtectionsHandler = null;
|
||||
var TrackingProtection = null;
|
||||
var ThirdPartyCookies = null;
|
||||
var tabbrowser = null;
|
||||
var gTrackingPageURL = TRACKING_PAGE;
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
TrackingProtection = ContentBlocking = ThirdPartyCookies = tabbrowser = null;
|
||||
TrackingProtection = gProtectionsHandler = ThirdPartyCookies = tabbrowser = null;
|
||||
UrlClassifierTestUtils.cleanupTestTrackers();
|
||||
Services.prefs.clearUserPref(TP_PREF);
|
||||
Services.prefs.clearUserPref(TP_PB_PREF);
|
||||
|
@ -59,27 +59,31 @@ function clickButton(sel) {
|
|||
function testBenignPage() {
|
||||
info("Non-tracking content must not be blocked");
|
||||
ok(
|
||||
!ContentBlocking.content.hasAttribute("detected"),
|
||||
!gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"no trackers are detected"
|
||||
);
|
||||
ok(
|
||||
!ContentBlocking.content.hasAttribute("hasException"),
|
||||
!gProtectionsHandler._protectionsPopup.hasAttribute("hasException"),
|
||||
"content shows no exception"
|
||||
);
|
||||
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is not active");
|
||||
ok(
|
||||
!ContentBlocking.iconBox.hasAttribute("hasException"),
|
||||
!gProtectionsHandler.iconBox.hasAttribute("active"),
|
||||
"shield is not active"
|
||||
);
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("hasException"),
|
||||
"icon box shows no exception"
|
||||
);
|
||||
ok(
|
||||
!ContentBlocking.iconBox.hasAttribute("tooltiptext"),
|
||||
!gProtectionsHandler.iconBox.hasAttribute("tooltiptext"),
|
||||
"icon box has no tooltip"
|
||||
);
|
||||
|
||||
ok(BrowserTestUtils.is_hidden(ContentBlocking.iconBox), "icon box is hidden");
|
||||
ok(hidden("#tracking-action-block"), "blockButton is hidden");
|
||||
ok(hidden("#tracking-action-unblock"), "unblockButton is hidden");
|
||||
ok(
|
||||
BrowserTestUtils.is_hidden(gProtectionsHandler.iconBox),
|
||||
"icon box is hidden"
|
||||
);
|
||||
|
||||
ok(
|
||||
!hidden("#identity-popup-content-blocking-not-detected"),
|
||||
|
@ -102,31 +106,32 @@ function testBenignPage() {
|
|||
function testBenignPageWithException() {
|
||||
info("Non-tracking content must not be blocked");
|
||||
ok(
|
||||
!ContentBlocking.content.hasAttribute("detected"),
|
||||
!gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"no trackers are detected"
|
||||
);
|
||||
ok(
|
||||
ContentBlocking.content.hasAttribute("hasException"),
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("hasException"),
|
||||
"content shows exception"
|
||||
);
|
||||
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is not active");
|
||||
ok(
|
||||
ContentBlocking.iconBox.hasAttribute("hasException"),
|
||||
!gProtectionsHandler.iconBox.hasAttribute("active"),
|
||||
"shield is not active"
|
||||
);
|
||||
ok(
|
||||
gProtectionsHandler.iconBox.hasAttribute("hasException"),
|
||||
"shield shows exception"
|
||||
);
|
||||
is(
|
||||
ContentBlocking.iconBox.getAttribute("tooltiptext"),
|
||||
gProtectionsHandler.iconBox.getAttribute("tooltiptext"),
|
||||
gNavigatorBundle.getString("trackingProtection.icon.disabledTooltip"),
|
||||
"correct tooltip"
|
||||
);
|
||||
|
||||
ok(
|
||||
!BrowserTestUtils.is_hidden(ContentBlocking.iconBox),
|
||||
!BrowserTestUtils.is_hidden(gProtectionsHandler.iconBox),
|
||||
"icon box is not hidden"
|
||||
);
|
||||
ok(!hidden("#tracking-action-block"), "blockButton is visible");
|
||||
ok(hidden("#tracking-action-unblock"), "unblockButton is hidden");
|
||||
|
||||
ok(
|
||||
!hidden("#identity-popup-content-blocking-not-detected"),
|
||||
|
@ -158,57 +163,39 @@ function areTrackersBlocked(isPrivateBrowsing) {
|
|||
|
||||
function testTrackingPage(window) {
|
||||
info("Tracking content must be blocked");
|
||||
ok(ContentBlocking.content.hasAttribute("detected"), "trackers are detected");
|
||||
ok(
|
||||
!ContentBlocking.content.hasAttribute("hasException"),
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"trackers are detected"
|
||||
);
|
||||
ok(
|
||||
!gProtectionsHandler._protectionsPopup.hasAttribute("hasException"),
|
||||
"content shows no exception"
|
||||
);
|
||||
|
||||
let isWindowPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
|
||||
let blockedByTP = areTrackersBlocked(isWindowPrivate);
|
||||
is(
|
||||
BrowserTestUtils.is_visible(ContentBlocking.iconBox),
|
||||
BrowserTestUtils.is_visible(gProtectionsHandler.iconBox),
|
||||
blockedByTP,
|
||||
"icon box is" + (blockedByTP ? "" : " not") + " visible"
|
||||
);
|
||||
is(
|
||||
ContentBlocking.iconBox.hasAttribute("active"),
|
||||
gProtectionsHandler.iconBox.hasAttribute("active"),
|
||||
blockedByTP,
|
||||
"shield is" + (blockedByTP ? "" : " not") + " active"
|
||||
);
|
||||
ok(
|
||||
!ContentBlocking.iconBox.hasAttribute("hasException"),
|
||||
!gProtectionsHandler.iconBox.hasAttribute("hasException"),
|
||||
"icon box shows no exception"
|
||||
);
|
||||
is(
|
||||
ContentBlocking.iconBox.getAttribute("tooltiptext"),
|
||||
gProtectionsHandler.iconBox.getAttribute("tooltiptext"),
|
||||
blockedByTP
|
||||
? gNavigatorBundle.getString("trackingProtection.icon.activeTooltip")
|
||||
: "",
|
||||
"correct tooltip"
|
||||
);
|
||||
|
||||
ok(hidden("#tracking-action-block"), "blockButton is hidden");
|
||||
|
||||
if (isWindowPrivate) {
|
||||
ok(hidden("#tracking-action-unblock"), "unblockButton is hidden");
|
||||
is(
|
||||
!hidden("#tracking-action-unblock-private"),
|
||||
blockedByTP,
|
||||
"unblockButtonPrivate is" + (blockedByTP ? "" : " not") + " visible"
|
||||
);
|
||||
} else {
|
||||
ok(
|
||||
hidden("#tracking-action-unblock-private"),
|
||||
"unblockButtonPrivate is hidden"
|
||||
);
|
||||
is(
|
||||
!hidden("#tracking-action-unblock"),
|
||||
blockedByTP,
|
||||
"unblockButton is" + (blockedByTP ? "" : " not") + " visible"
|
||||
);
|
||||
}
|
||||
|
||||
ok(
|
||||
hidden("#identity-popup-content-blocking-not-detected"),
|
||||
"blocking not detected label is hidden"
|
||||
|
@ -237,29 +224,33 @@ function testTrackingPage(window) {
|
|||
|
||||
function testTrackingPageUnblocked(blockedByTP, window) {
|
||||
info("Tracking content must be white-listed and not blocked");
|
||||
ok(ContentBlocking.content.hasAttribute("detected"), "trackers are detected");
|
||||
ok(
|
||||
ContentBlocking.content.hasAttribute("hasException"),
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
|
||||
"trackers are detected"
|
||||
);
|
||||
ok(
|
||||
gProtectionsHandler._protectionsPopup.hasAttribute("hasException"),
|
||||
"content shows exception"
|
||||
);
|
||||
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is not active");
|
||||
ok(
|
||||
ContentBlocking.iconBox.hasAttribute("hasException"),
|
||||
!gProtectionsHandler.iconBox.hasAttribute("active"),
|
||||
"shield is not active"
|
||||
);
|
||||
ok(
|
||||
gProtectionsHandler.iconBox.hasAttribute("hasException"),
|
||||
"shield shows exception"
|
||||
);
|
||||
is(
|
||||
ContentBlocking.iconBox.getAttribute("tooltiptext"),
|
||||
gProtectionsHandler.iconBox.getAttribute("tooltiptext"),
|
||||
gNavigatorBundle.getString("trackingProtection.icon.disabledTooltip"),
|
||||
"correct tooltip"
|
||||
);
|
||||
|
||||
ok(
|
||||
BrowserTestUtils.is_visible(ContentBlocking.iconBox),
|
||||
BrowserTestUtils.is_visible(gProtectionsHandler.iconBox),
|
||||
"icon box is visible"
|
||||
);
|
||||
ok(!hidden("#tracking-action-block"), "blockButton is visible");
|
||||
ok(hidden("#tracking-action-unblock"), "unblockButton is hidden");
|
||||
|
||||
ok(
|
||||
hidden("#identity-popup-content-blocking-not-detected"),
|
||||
|
@ -315,7 +306,7 @@ async function testContentBlocking(tab) {
|
|||
|
||||
info("Disable CB for the page (which reloads the page)");
|
||||
let tabReloadPromise = promiseTabLoadEvent(tab);
|
||||
clickButton("#tracking-action-unblock");
|
||||
tab.ownerGlobal.gProtectionsHandler.disableForCurrentPage();
|
||||
await tabReloadPromise;
|
||||
let isPrivateBrowsing = PrivateBrowsingUtils.isWindowPrivate(tab.ownerGlobal);
|
||||
let blockedByTP = areTrackersBlocked(isPrivateBrowsing);
|
||||
|
@ -323,7 +314,7 @@ async function testContentBlocking(tab) {
|
|||
|
||||
info("Re-enable TP for the page (which reloads the page)");
|
||||
tabReloadPromise = promiseTabLoadEvent(tab);
|
||||
clickButton("#tracking-action-block");
|
||||
tab.ownerGlobal.gProtectionsHandler.enableForCurrentPage();
|
||||
await tabReloadPromise;
|
||||
testTrackingPage(tab.ownerGlobal);
|
||||
}
|
||||
|
@ -336,8 +327,11 @@ add_task(async function testNormalBrowsing() {
|
|||
tabbrowser = gBrowser;
|
||||
let tab = (tabbrowser.selectedTab = BrowserTestUtils.addTab(tabbrowser));
|
||||
|
||||
ContentBlocking = gBrowser.ownerGlobal.ContentBlocking;
|
||||
ok(ContentBlocking, "CB is attached to the browser window");
|
||||
gProtectionsHandler = gBrowser.ownerGlobal.gProtectionsHandler;
|
||||
ok(
|
||||
gProtectionsHandler,
|
||||
"gProtectionsHandler is attached to the browser window"
|
||||
);
|
||||
TrackingProtection = gBrowser.ownerGlobal.TrackingProtection;
|
||||
ok(TrackingProtection, "TP is attached to the browser window");
|
||||
is(
|
||||
|
@ -372,8 +366,11 @@ add_task(async function testPrivateBrowsing() {
|
|||
|
||||
Services.prefs.setIntPref(TPC_PREF, Ci.nsICookieService.BEHAVIOR_ACCEPT);
|
||||
|
||||
ContentBlocking = tabbrowser.ownerGlobal.ContentBlocking;
|
||||
ok(ContentBlocking, "CB is attached to the private window");
|
||||
gProtectionsHandler = tabbrowser.ownerGlobal.gProtectionsHandler;
|
||||
ok(
|
||||
gProtectionsHandler,
|
||||
"gProtectionsHandler is attached to the private window"
|
||||
);
|
||||
TrackingProtection = tabbrowser.ownerGlobal.TrackingProtection;
|
||||
ok(TrackingProtection, "TP is attached to the private window");
|
||||
is(
|
||||
|
@ -401,8 +398,11 @@ add_task(async function testThirdPartyCookies() {
|
|||
tabbrowser = gBrowser;
|
||||
let tab = (tabbrowser.selectedTab = BrowserTestUtils.addTab(tabbrowser));
|
||||
|
||||
ContentBlocking = gBrowser.ownerGlobal.ContentBlocking;
|
||||
ok(ContentBlocking, "CB is attached to the browser window");
|
||||
gProtectionsHandler = gBrowser.ownerGlobal.gProtectionsHandler;
|
||||
ok(
|
||||
gProtectionsHandler,
|
||||
"gProtectionsHandler is attached to the browser window"
|
||||
);
|
||||
ThirdPartyCookies = gBrowser.ownerGlobal.ThirdPartyCookies;
|
||||
ok(ThirdPartyCookies, "TP is attached to the browser window");
|
||||
is(
|
||||
|
|
|
@ -23,7 +23,10 @@ add_task(async function testResetOnLocationChange() {
|
|||
0,
|
||||
"Benign page has no content blocking event"
|
||||
);
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is not active");
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("active"),
|
||||
"shield is not active"
|
||||
);
|
||||
|
||||
await Promise.all([
|
||||
promiseTabLoadEvent(tab, TRACKING_PAGE),
|
||||
|
@ -35,7 +38,7 @@ add_task(async function testResetOnLocationChange() {
|
|||
Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT,
|
||||
"Tracking page has a content blocking event"
|
||||
);
|
||||
ok(ContentBlocking.iconBox.hasAttribute("active"), "shield is active");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("active"), "shield is active");
|
||||
|
||||
await promiseTabLoadEvent(tab, BENIGN_PAGE);
|
||||
|
||||
|
@ -44,7 +47,10 @@ add_task(async function testResetOnLocationChange() {
|
|||
0,
|
||||
"Benign page has no content blocking event"
|
||||
);
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is not active");
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("active"),
|
||||
"shield is not active"
|
||||
);
|
||||
|
||||
let contentBlockingEvent = waitForContentBlockingEvent(3);
|
||||
let trackingTab = await BrowserTestUtils.openNewForegroundTab(
|
||||
|
@ -58,7 +64,7 @@ add_task(async function testResetOnLocationChange() {
|
|||
Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT,
|
||||
"Tracking page has a content blocking event"
|
||||
);
|
||||
ok(ContentBlocking.iconBox.hasAttribute("active"), "shield is active");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("active"), "shield is active");
|
||||
|
||||
gBrowser.selectedTab = tab;
|
||||
is(
|
||||
|
@ -66,7 +72,10 @@ add_task(async function testResetOnLocationChange() {
|
|||
0,
|
||||
"Benign page has no content blocking event"
|
||||
);
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is not active");
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("active"),
|
||||
"shield is not active"
|
||||
);
|
||||
|
||||
gBrowser.removeTab(trackingTab);
|
||||
gBrowser.removeTab(tab);
|
||||
|
@ -80,16 +89,22 @@ add_task(async function testResetOnTabChange() {
|
|||
Services.prefs.setBoolPref(TP_PREF, true);
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, ABOUT_PAGE);
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is not active");
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("active"),
|
||||
"shield is not active"
|
||||
);
|
||||
|
||||
await Promise.all([
|
||||
promiseTabLoadEvent(tab, TRACKING_PAGE),
|
||||
waitForContentBlockingEvent(3),
|
||||
]);
|
||||
ok(ContentBlocking.iconBox.hasAttribute("active"), "shield is active");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("active"), "shield is active");
|
||||
|
||||
await promiseTabLoadEvent(tab, ABOUT_PAGE);
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is not active");
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("active"),
|
||||
"shield is not active"
|
||||
);
|
||||
|
||||
let contentBlockingEvent = waitForContentBlockingEvent(3);
|
||||
let trackingTab = await BrowserTestUtils.openNewForegroundTab(
|
||||
|
@ -97,10 +112,13 @@ add_task(async function testResetOnTabChange() {
|
|||
TRACKING_PAGE
|
||||
);
|
||||
await contentBlockingEvent;
|
||||
ok(ContentBlocking.iconBox.hasAttribute("active"), "shield is active");
|
||||
ok(gProtectionsHandler.iconBox.hasAttribute("active"), "shield is active");
|
||||
|
||||
gBrowser.selectedTab = tab;
|
||||
ok(!ContentBlocking.iconBox.hasAttribute("active"), "shield is not active");
|
||||
ok(
|
||||
!gProtectionsHandler.iconBox.hasAttribute("active"),
|
||||
"shield is not active"
|
||||
);
|
||||
|
||||
gBrowser.removeTab(trackingTab);
|
||||
gBrowser.removeTab(tab);
|
||||
|
|
|
@ -59,7 +59,7 @@ add_task(async function testShieldHistogram() {
|
|||
|
||||
info("Disable TP for the page (which reloads the page)");
|
||||
let tabReloadPromise = promiseTabLoadEvent(tab);
|
||||
document.querySelector("#tracking-action-unblock").doCommand();
|
||||
gProtectionsHandler.disableForCurrentPage();
|
||||
await tabReloadPromise;
|
||||
is(getShieldCounts()[0], 3, "Adds one more page load");
|
||||
is(
|
||||
|
@ -70,7 +70,7 @@ add_task(async function testShieldHistogram() {
|
|||
|
||||
info("Re-enable TP for the page (which reloads the page)");
|
||||
tabReloadPromise = promiseTabLoadEvent(tab);
|
||||
document.querySelector("#tracking-action-block").doCommand();
|
||||
gProtectionsHandler.enableForCurrentPage();
|
||||
await tabReloadPromise;
|
||||
is(getShieldCounts()[0], 4, "Adds one more page load");
|
||||
is(
|
||||
|
|
|
@ -19,7 +19,7 @@ add_task(async function setup() {
|
|||
|
||||
async function assertSitesListed(blocked) {
|
||||
await BrowserTestUtils.withNewTab(TRACKING_PAGE, async function(browser) {
|
||||
await openIdentityPopup();
|
||||
await openProtectionsPopup();
|
||||
|
||||
let categoryItem = document.getElementById(
|
||||
"identity-popup-content-blocking-category-tracking-protection"
|
||||
|
@ -49,7 +49,7 @@ async function assertSitesListed(blocked) {
|
|||
"Strict info is hidden if TP is enabled."
|
||||
);
|
||||
|
||||
let mainView = document.getElementById("identity-popup-mainView");
|
||||
let mainView = document.getElementById("protections-popup-mainView");
|
||||
viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
|
||||
let backButton = trackersView.querySelector(".subviewbutton-back");
|
||||
backButton.click();
|
||||
|
|
|
@ -2,6 +2,12 @@ var { UrlClassifierTestUtils } = ChromeUtils.import(
|
|||
"resource://testing-common/UrlClassifierTestUtils.jsm"
|
||||
);
|
||||
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"ContentBlockingAllowList",
|
||||
"resource://gre/modules/ContentBlockingAllowList.jsm"
|
||||
);
|
||||
|
||||
/**
|
||||
* Waits for a load (or custom) event to finish in a given tab. If provided
|
||||
* load an uri into the tab.
|
||||
|
@ -43,6 +49,14 @@ function openIdentityPopup() {
|
|||
return viewShown;
|
||||
}
|
||||
|
||||
function openProtectionsPopup() {
|
||||
let mainView = document.getElementById("protections-popup-mainView");
|
||||
let viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
|
||||
// TODO: This should click on the icon once we have it.
|
||||
gProtectionsHandler.showProtectionsPopup();
|
||||
return viewShown;
|
||||
}
|
||||
|
||||
function waitForSecurityChange(numChanges = 1, win = null) {
|
||||
if (!win) {
|
||||
win = window;
|
||||
|
|
|
@ -385,7 +385,7 @@ this.AntiTracking = {
|
|||
|
||||
if (options.allowList) {
|
||||
info("Disabling content blocking for this page");
|
||||
win.ContentBlocking.disableForCurrentPage();
|
||||
win.gProtectionsHandler.disableForCurrentPage();
|
||||
|
||||
// The previous function reloads the browser, so wait for it to load again!
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
@ -558,7 +558,7 @@ this.AntiTracking = {
|
|||
|
||||
if (options.allowList) {
|
||||
info("Enabling content blocking for this page");
|
||||
win.ContentBlocking.enableForCurrentPage();
|
||||
win.gProtectionsHandler.enableForCurrentPage();
|
||||
|
||||
// The previous function reloads the browser, so wait for it to load again!
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
|
|
@ -25,7 +25,7 @@ add_task(async function() {
|
|||
let browser = gBrowser.getBrowserForTab(tab);
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
ContentBlocking.disableForCurrentPage();
|
||||
gProtectionsHandler.disableForCurrentPage();
|
||||
|
||||
// The previous function reloads the browser, so wait for it to load again!
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
@ -112,7 +112,7 @@ add_task(async function() {
|
|||
expectTrackerFound(originLog[0]);
|
||||
}
|
||||
|
||||
ContentBlocking.enableForCurrentPage();
|
||||
gProtectionsHandler.enableForCurrentPage();
|
||||
|
||||
// The previous function reloads the browser, so wait for it to load again!
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
|
|
@ -22,7 +22,7 @@ add_task(async function() {
|
|||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
info("Disabling content blocking for this page");
|
||||
ContentBlocking.disableForCurrentPage();
|
||||
gProtectionsHandler.disableForCurrentPage();
|
||||
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ add_task(async function() {
|
|||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
info("Disabling content blocking for this page");
|
||||
ContentBlocking.disableForCurrentPage();
|
||||
gProtectionsHandler.disableForCurrentPage();
|
||||
|
||||
// The previous function reloads the browser, so wait for it to load again!
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
@ -57,7 +57,7 @@ add_task(async function() {
|
|||
});
|
||||
|
||||
info("Enabling content blocking for this page");
|
||||
ContentBlocking.enableForCurrentPage();
|
||||
gProtectionsHandler.enableForCurrentPage();
|
||||
|
||||
// The previous function reloads the browser, so wait for it to load again!
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
|
Загрузка…
Ссылка в новой задаче