forked from mirrors/gecko-dev
Backed out 4 changesets (bug 1854940) for causing multiple failures.
Backed out changeset 2d264402493e (bug 1854940) Backed out changeset 144b76e6db22 (bug 1854940) Backed out changeset 5a9e45504f32 (bug 1854940) Backed out changeset c8c7ec382574 (bug 1854940)
This commit is contained in:
parent
d8ddd3cc26
commit
582e249d86
28 changed files with 35 additions and 1229 deletions
|
|
@ -389,16 +389,11 @@ export var Sanitizer = {
|
|||
await maybeSanitizeSessionPrincipals(
|
||||
progress,
|
||||
principalsForShutdownClearing,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIES |
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD
|
||||
Ci.nsIClearDataService.CLEAR_COOKIES
|
||||
);
|
||||
} else {
|
||||
// Not on shutdown
|
||||
await clearData(
|
||||
range,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIES |
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD
|
||||
);
|
||||
await clearData(range, Ci.nsIClearDataService.CLEAR_COOKIES);
|
||||
}
|
||||
await clearData(range, Ci.nsIClearDataService.CLEAR_MEDIA_DEVICES);
|
||||
TelemetryStopwatch.finish("FX_SANITIZE_COOKIES_2", refObj);
|
||||
|
|
@ -416,16 +411,11 @@ export var Sanitizer = {
|
|||
await maybeSanitizeSessionPrincipals(
|
||||
progress,
|
||||
principalsForShutdownClearing,
|
||||
Ci.nsIClearDataService.CLEAR_DOM_STORAGES |
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD
|
||||
Ci.nsIClearDataService.CLEAR_DOM_STORAGES
|
||||
);
|
||||
} else {
|
||||
// Not on shutdown
|
||||
await clearData(
|
||||
range,
|
||||
Ci.nsIClearDataService.CLEAR_DOM_STORAGES |
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD
|
||||
);
|
||||
await clearData(range, Ci.nsIClearDataService.CLEAR_DOM_STORAGES);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
@ -559,8 +549,7 @@ export var Sanitizer = {
|
|||
Ci.nsIClearDataService.CLEAR_DOM_PUSH_NOTIFICATIONS |
|
||||
Ci.nsIClearDataService.CLEAR_CLIENT_AUTH_REMEMBER_SERVICE |
|
||||
Ci.nsIClearDataService.CLEAR_CERT_EXCEPTIONS |
|
||||
Ci.nsIClearDataService.CLEAR_CREDENTIAL_MANAGER_STATE |
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXCEPTION
|
||||
Ci.nsIClearDataService.CLEAR_CREDENTIAL_MANAGER_STATE
|
||||
);
|
||||
TelemetryStopwatch.finish("FX_SANITIZE_SITESETTINGS", refObj);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -473,8 +473,7 @@ export var SiteDataManager = {
|
|||
Ci.nsIClearDataService.CLEAR_COOKIES |
|
||||
Ci.nsIClearDataService.CLEAR_DOM_STORAGES |
|
||||
Ci.nsIClearDataService.CLEAR_EME |
|
||||
Ci.nsIClearDataService.CLEAR_ALL_CACHES |
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD;
|
||||
Ci.nsIClearDataService.CLEAR_ALL_CACHES;
|
||||
promises.push(
|
||||
new Promise(function (resolve) {
|
||||
const { clearData } = Services;
|
||||
|
|
|
|||
|
|
@ -36,8 +36,7 @@ const ClearFlags = [
|
|||
// COOKIES
|
||||
1 << 0,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIES |
|
||||
Ci.nsIClearDataService.CLEAR_MEDIA_DEVICES |
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD,
|
||||
Ci.nsIClearDataService.CLEAR_MEDIA_DEVICES,
|
||||
],
|
||||
[
|
||||
// NETWORK_CACHE
|
||||
|
|
@ -60,8 +59,7 @@ const ClearFlags = [
|
|||
1 << 4,
|
||||
Ci.nsIClearDataService.CLEAR_DOM_QUOTA |
|
||||
Ci.nsIClearDataService.CLEAR_DOM_PUSH_NOTIFICATIONS |
|
||||
Ci.nsIClearDataService.CLEAR_REPORTS |
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD,
|
||||
Ci.nsIClearDataService.CLEAR_REPORTS,
|
||||
],
|
||||
[
|
||||
// AUTH_SESSIONS
|
||||
|
|
|
|||
|
|
@ -2033,13 +2033,6 @@
|
|||
value: 31536000
|
||||
mirror: always
|
||||
|
||||
# Whether the banner clicking code only get executed once when the site is
|
||||
# loaded in the browsing session.
|
||||
- name: cookiebanners.bannerClicking.executeOnce
|
||||
type: bool
|
||||
value: true
|
||||
mirror: always
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Prefs starting with "datareporting."
|
||||
#---------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -210,8 +210,7 @@ PurgeTrackerService.prototype = {
|
|||
Ci.nsIClearDataService.CLEAR_MEDIA_DEVICES |
|
||||
Ci.nsIClearDataService.CLEAR_STORAGE_ACCESS |
|
||||
Ci.nsIClearDataService.CLEAR_AUTH_TOKENS |
|
||||
Ci.nsIClearDataService.CLEAR_AUTH_CACHE |
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD,
|
||||
Ci.nsIClearDataService.CLEAR_AUTH_CACHE,
|
||||
resolve
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -173,63 +173,6 @@ const CookieCleaner = {
|
|||
},
|
||||
};
|
||||
|
||||
// A cleaner for clearing cookie banner handling exceptions.
|
||||
const CookieBannerExceptionCleaner = {
|
||||
async deleteAll() {
|
||||
Services.cookieBanners.removeAllDomainPrefs(false);
|
||||
},
|
||||
|
||||
async deleteByPrincipal(aPrincipal) {
|
||||
Services.cookieBanners.removeDomainPref(aPrincipal.URI, false);
|
||||
},
|
||||
|
||||
async deleteByBaseDomain(aDomain) {
|
||||
Services.cookieBanners.removeDomainPref(
|
||||
Services.io.newURI("https://" + aDomain),
|
||||
false
|
||||
);
|
||||
},
|
||||
|
||||
async deleteByHost(aHost, aOriginAttributes) {
|
||||
let isPrivate =
|
||||
!!aOriginAttributes.privateBrowsingId &&
|
||||
aOriginAttributes.privateBrowsingId !==
|
||||
Services.scriptSecurityManager.DEFAULT_PRIVATE_BROWSING_ID;
|
||||
|
||||
Services.cookieBanners.removeDomainPref(
|
||||
Services.io.newURI("https://" + aHost),
|
||||
isPrivate
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
// A cleaner for cleaning cookie banner handling executed records.
|
||||
const CookieBannerExecutedRecordCleaner = {
|
||||
async deleteAll() {
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
},
|
||||
|
||||
async deleteByPrincipal(aPrincipal) {
|
||||
Services.cookieBanners.removeExecutedRecordForSite(
|
||||
aPrincipal.baseDomain,
|
||||
false
|
||||
);
|
||||
},
|
||||
|
||||
async deleteByBaseDomain(aDomain) {
|
||||
Services.cookieBanners.removeExecutedRecordForSite(aDomain, false);
|
||||
},
|
||||
|
||||
async deleteByHost(aHost, aOriginAttributes) {
|
||||
let isPrivate =
|
||||
!!aOriginAttributes.privateBrowsingId &&
|
||||
aOriginAttributes.privateBrowsingId !==
|
||||
Services.scriptSecurityManager.DEFAULT_PRIVATE_BROWSING_ID;
|
||||
|
||||
Services.cookieBanners.removeExecutedRecordForSite(aHost, isPrivate);
|
||||
},
|
||||
};
|
||||
|
||||
const CertCleaner = {
|
||||
async deleteByHost(aHost, aOriginAttributes) {
|
||||
let overrideService = Cc["@mozilla.org/security/certoverride;1"].getService(
|
||||
|
|
@ -1677,16 +1620,6 @@ const FLAGS_MAP = [
|
|||
flag: Ci.nsIClearDataService.CLEAR_CREDENTIAL_MANAGER_STATE,
|
||||
cleaners: [IdentityCredentialStorageCleaner],
|
||||
},
|
||||
|
||||
{
|
||||
flag: Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXCEPTION,
|
||||
cleaners: [CookieBannerExceptionCleaner],
|
||||
},
|
||||
|
||||
{
|
||||
flag: Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD,
|
||||
cleaners: [CookieBannerExecutedRecordCleaner],
|
||||
},
|
||||
];
|
||||
|
||||
export function ClearDataService() {
|
||||
|
|
|
|||
|
|
@ -399,9 +399,7 @@ export var SiteDataTestUtils = {
|
|||
Ci.nsIClearDataService.CLEAR_PREDICTOR_NETWORK_DATA |
|
||||
Ci.nsIClearDataService.CLEAR_CLIENT_AUTH_REMEMBER_SERVICE |
|
||||
Ci.nsIClearDataService.CLEAR_EME |
|
||||
Ci.nsIClearDataService.CLEAR_STORAGE_ACCESS |
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXCEPTION |
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD,
|
||||
Ci.nsIClearDataService.CLEAR_STORAGE_ACCESS,
|
||||
resolve
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -287,16 +287,6 @@ interface nsIClearDataService : nsISupports
|
|||
*/
|
||||
const uint32_t CLEAR_CREDENTIAL_MANAGER_STATE = 1 << 24;
|
||||
|
||||
/**
|
||||
* Clear the per-site exception for cookie banner handling.
|
||||
*/
|
||||
const uint32_t CLEAR_COOKIE_BANNER_EXCEPTION = 1 << 25;
|
||||
|
||||
/**
|
||||
* Clear the site executed record for cookie banner handling.
|
||||
*/
|
||||
const uint32_t CLEAR_COOKIE_BANNER_EXECUTED_RECORD = 1 << 26;
|
||||
|
||||
/**
|
||||
* Use this value to delete all the data.
|
||||
*/
|
||||
|
|
@ -327,8 +317,7 @@ interface nsIClearDataService : nsISupports
|
|||
CLEAR_PERMISSIONS | CLEAR_DOM_STORAGES | CLEAR_CONTENT_PREFERENCES |
|
||||
CLEAR_PREDICTOR_NETWORK_DATA | CLEAR_DOM_PUSH_NOTIFICATIONS |
|
||||
CLEAR_CLIENT_AUTH_REMEMBER_SERVICE | CLEAR_REPORTS | CLEAR_CERT_EXCEPTIONS |
|
||||
CLEAR_CREDENTIAL_MANAGER_STATE | CLEAR_COOKIE_BANNER_EXCEPTION |
|
||||
CLEAR_COOKIE_BANNER_EXECUTED_RECORD;
|
||||
CLEAR_CREDENTIAL_MANAGER_STATE;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,289 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
do_get_profile();
|
||||
|
||||
add_setup(_ => {
|
||||
// Init cookieBannerService and pretend we opened a profile.
|
||||
let cbs = Cc["@mozilla.org/cookie-banner-service;1"].getService(
|
||||
Ci.nsIObserver
|
||||
);
|
||||
cbs.observe(null, "profile-after-change", null);
|
||||
});
|
||||
|
||||
add_task(async function test_delete_exception() {
|
||||
info("Enabling cookie banner service with MODE_REJECT");
|
||||
Services.prefs.setIntPref(
|
||||
"cookiebanners.service.mode",
|
||||
Ci.nsICookieBannerService.MODE_REJECT
|
||||
);
|
||||
|
||||
// Test nsIClearDataService.deleteDataFromHost
|
||||
info("Adding an exception for example.com");
|
||||
let uri = Services.io.newURI("https://example.com");
|
||||
|
||||
Services.cookieBanners.setDomainPref(
|
||||
uri,
|
||||
Ci.nsICookieBannerService.MODE_REJECT_OR_ACCEPT,
|
||||
false
|
||||
);
|
||||
|
||||
info("Verify that the exception is properly added");
|
||||
Assert.equal(
|
||||
Services.cookieBanners.getDomainPref(uri, false),
|
||||
Ci.nsICookieBannerService.MODE_REJECT_OR_ACCEPT,
|
||||
"The exception is properly set."
|
||||
);
|
||||
|
||||
info("Trigger the deleteDataFromHost");
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteDataFromHost(
|
||||
"example.com",
|
||||
true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXCEPTION,
|
||||
_ => {
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
info("Verify that the exception is deleted");
|
||||
Assert.equal(
|
||||
Services.cookieBanners.getDomainPref(uri, false),
|
||||
Ci.nsICookieBannerService.MODE_UNSET,
|
||||
"The exception is properly cleared."
|
||||
);
|
||||
|
||||
// Test nsIClearDataService.deleteDataFromBaseDomain
|
||||
info("Adding an exception for example.com");
|
||||
Services.cookieBanners.setDomainPref(
|
||||
uri,
|
||||
Ci.nsICookieBannerService.MODE_REJECT_OR_ACCEPT,
|
||||
false
|
||||
);
|
||||
|
||||
info("Verify that the exception is properly added");
|
||||
Assert.equal(
|
||||
Services.cookieBanners.getDomainPref(uri, false),
|
||||
Ci.nsICookieBannerService.MODE_REJECT_OR_ACCEPT,
|
||||
"The exception is properly set."
|
||||
);
|
||||
|
||||
info("Trigger the deleteDataFromBaseDomain");
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteDataFromBaseDomain(
|
||||
"example.com",
|
||||
true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXCEPTION,
|
||||
_ => {
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
info("Verify that the exception is deleted");
|
||||
Assert.equal(
|
||||
Services.cookieBanners.getDomainPref(uri, false),
|
||||
Ci.nsICookieBannerService.MODE_UNSET,
|
||||
"The exception is properly cleared."
|
||||
);
|
||||
|
||||
// Test nsIClearDataService.deleteDataFromPrincipal
|
||||
info("Adding an exception for example.com");
|
||||
Services.cookieBanners.setDomainPref(
|
||||
uri,
|
||||
Ci.nsICookieBannerService.MODE_REJECT_OR_ACCEPT,
|
||||
false
|
||||
);
|
||||
|
||||
info("Verify that the exception is properly added");
|
||||
Assert.equal(
|
||||
Services.cookieBanners.getDomainPref(uri, false),
|
||||
Ci.nsICookieBannerService.MODE_REJECT_OR_ACCEPT,
|
||||
"The exception is properly set."
|
||||
);
|
||||
|
||||
info("Trigger the deleteDataFromPrincipal");
|
||||
let principal = Services.scriptSecurityManager.createContentPrincipal(
|
||||
uri,
|
||||
{}
|
||||
);
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteDataFromPrincipal(
|
||||
principal,
|
||||
true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXCEPTION,
|
||||
_ => {
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
info("Verify that the exception is deleted");
|
||||
Assert.equal(
|
||||
Services.cookieBanners.getDomainPref(uri, false),
|
||||
Ci.nsICookieBannerService.MODE_UNSET,
|
||||
"The exception is properly cleared."
|
||||
);
|
||||
|
||||
// Test nsIClearDataService.deleteData
|
||||
info("Adding an exception for example.com");
|
||||
Services.cookieBanners.setDomainPref(
|
||||
uri,
|
||||
Ci.nsICookieBannerService.MODE_REJECT_OR_ACCEPT,
|
||||
false
|
||||
);
|
||||
|
||||
info("Verify that the exception is properly added");
|
||||
Assert.equal(
|
||||
Services.cookieBanners.getDomainPref(uri, false),
|
||||
Ci.nsICookieBannerService.MODE_REJECT_OR_ACCEPT,
|
||||
"The exception is properly set."
|
||||
);
|
||||
|
||||
info("Trigger the deleteData");
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXCEPTION,
|
||||
_ => {
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
info("Verify that the exception is deleted");
|
||||
Assert.equal(
|
||||
Services.cookieBanners.getDomainPref(uri, false),
|
||||
Ci.nsICookieBannerService.MODE_UNSET,
|
||||
"The exception is properly cleared."
|
||||
);
|
||||
|
||||
Services.prefs.clearUserPref("cookiebanners.service.mode");
|
||||
});
|
||||
|
||||
add_task(async function test_delete_executed_record() {
|
||||
info("Enabling cookie banner service with MODE_REJECT");
|
||||
Services.prefs.setIntPref(
|
||||
"cookiebanners.service.mode",
|
||||
Ci.nsICookieBannerService.MODE_REJECT
|
||||
);
|
||||
|
||||
// Test nsIClearDataService.deleteDataFromHost
|
||||
info("Adding a record for example.com");
|
||||
Services.cookieBanners.markSiteExecuted("example.com", true, false);
|
||||
|
||||
info("Verify that the record is properly added");
|
||||
Assert.ok(
|
||||
Services.cookieBanners.hasExecutedForSite("example.com", true, false),
|
||||
"The record is properly set."
|
||||
);
|
||||
|
||||
info("Trigger the deleteDataFromHost");
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteDataFromHost(
|
||||
"example.com",
|
||||
true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD,
|
||||
_ => {
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
info("Verify that the exception is deleted");
|
||||
Assert.ok(
|
||||
!Services.cookieBanners.hasExecutedForSite("example.com", true, false),
|
||||
"The record is properly cleared."
|
||||
);
|
||||
|
||||
// Test nsIClearDataService.deleteDataFromBaseDomain
|
||||
info("Adding a record for example.com");
|
||||
Services.cookieBanners.markSiteExecuted("example.com", true, false);
|
||||
|
||||
info("Verify that the record is properly added");
|
||||
Assert.ok(
|
||||
Services.cookieBanners.hasExecutedForSite("example.com", true, false),
|
||||
"The record is properly set."
|
||||
);
|
||||
|
||||
info("Trigger the deleteDataFromBaseDomain");
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteDataFromBaseDomain(
|
||||
"example.com",
|
||||
true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD,
|
||||
_ => {
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
info("Verify that the exception is deleted");
|
||||
Assert.ok(
|
||||
!Services.cookieBanners.hasExecutedForSite("example.com", true, false),
|
||||
"The record is properly cleared."
|
||||
);
|
||||
|
||||
// Test nsIClearDataService.deleteDataFromPrincipal
|
||||
info("Adding a record for example.com");
|
||||
Services.cookieBanners.markSiteExecuted("example.com", true, false);
|
||||
|
||||
info("Verify that the record is properly added");
|
||||
Assert.ok(
|
||||
Services.cookieBanners.hasExecutedForSite("example.com", true, false),
|
||||
"The record is properly set."
|
||||
);
|
||||
|
||||
info("Trigger the deleteDataFromPrincipal");
|
||||
let uri = Services.io.newURI("https://example.com");
|
||||
let principal = Services.scriptSecurityManager.createContentPrincipal(
|
||||
uri,
|
||||
{}
|
||||
);
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteDataFromPrincipal(
|
||||
principal,
|
||||
true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD,
|
||||
_ => {
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
info("Verify that the exception is deleted");
|
||||
Assert.ok(
|
||||
!Services.cookieBanners.hasExecutedForSite("example.com", true, false),
|
||||
"The record is properly cleared."
|
||||
);
|
||||
|
||||
// Test nsIClearDataService.deleteData
|
||||
info("Adding a record for example.com");
|
||||
Services.cookieBanners.markSiteExecuted("example.com", true, false);
|
||||
|
||||
info("Verify that the record is properly added");
|
||||
Assert.ok(
|
||||
Services.cookieBanners.hasExecutedForSite("example.com", true, false),
|
||||
"The record is properly set."
|
||||
);
|
||||
|
||||
info("Trigger the deleteData");
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD,
|
||||
_ => {
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
info("Verify that the exception is deleted");
|
||||
Assert.ok(
|
||||
!Services.cookieBanners.hasExecutedForSite("example.com", true, false),
|
||||
"The record is properly cleared."
|
||||
);
|
||||
|
||||
Services.prefs.clearUserPref("cookiebanners.service.mode");
|
||||
});
|
||||
|
|
@ -7,7 +7,6 @@ support-files =
|
|||
|
||||
[test_basic.js]
|
||||
[test_certs.js]
|
||||
[test_cookie_banner_handling.js]
|
||||
[test_cookies.js]
|
||||
[test_identity_credential_storage.js]
|
||||
[test_downloads.js]
|
||||
|
|
|
|||
|
|
@ -187,14 +187,12 @@ void ClearSiteData::ClearDataFromChannel(nsIHttpChannel* aChannel) {
|
|||
|
||||
if (flags & eCookies) {
|
||||
LogOpToConsole(aChannel, uri, eCookies);
|
||||
cleanFlags |= nsIClearDataService::CLEAR_COOKIES |
|
||||
nsIClearDataService::CLEAR_COOKIE_BANNER_EXECUTED_RECORD;
|
||||
cleanFlags |= nsIClearDataService::CLEAR_COOKIES;
|
||||
}
|
||||
|
||||
if (flags & eStorage) {
|
||||
LogOpToConsole(aChannel, uri, eStorage);
|
||||
cleanFlags |= nsIClearDataService::CLEAR_DOM_STORAGES |
|
||||
nsIClearDataService::CLEAR_COOKIE_BANNER_EXECUTED_RECORD;
|
||||
cleanFlags |= nsIClearDataService::CLEAR_DOM_STORAGES;
|
||||
}
|
||||
|
||||
if (cleanFlags) {
|
||||
|
|
|
|||
|
|
@ -93,10 +93,6 @@ export class CookieBannerChild extends JSWindowActorChild {
|
|||
};
|
||||
// For measuring the cookie banner handling duration.
|
||||
#gleanBannerHandlingTimer = null;
|
||||
// Indicates whether we should stop running the cookie banner handling
|
||||
// mechanism because it has been previously executed for the site. So, we can
|
||||
// cool down the cookie banner handing to improve performance.
|
||||
#isCooledDownInSession = false;
|
||||
|
||||
handleEvent(event) {
|
||||
if (!this.#isEnabled) {
|
||||
|
|
@ -172,10 +168,7 @@ export class CookieBannerChild extends JSWindowActorChild {
|
|||
* @returns {boolean} Whether we handled the banner and dispatched events.
|
||||
*/
|
||||
#dispatchEventsForBannerHandledByInjection() {
|
||||
if (
|
||||
!this.#hasInjectedCookieForCookieBannerHandling ||
|
||||
this.#isCooledDownInSession
|
||||
) {
|
||||
if (!this.#hasInjectedCookieForCookieBannerHandling) {
|
||||
return false;
|
||||
}
|
||||
// Strictly speaking we don't actively detect a banner when we handle it by
|
||||
|
|
@ -216,12 +209,7 @@ export class CookieBannerChild extends JSWindowActorChild {
|
|||
let rules;
|
||||
|
||||
try {
|
||||
let data = await this.sendQuery("CookieBanner::GetClickRules", {});
|
||||
|
||||
rules = data.rules;
|
||||
// Set we are cooling down for this session if the cookie banner handling
|
||||
// has been executed previously.
|
||||
this.#isCooledDownInSession = data.hasExecuted;
|
||||
rules = await this.sendQuery("CookieBanner::GetClickRules", {});
|
||||
} catch (e) {
|
||||
lazy.logConsole.warn("Failed to get click rule from parent.", e);
|
||||
return;
|
||||
|
|
@ -260,9 +248,6 @@ export class CookieBannerChild extends JSWindowActorChild {
|
|||
let { bannerHandled, bannerDetected, matchedRule } =
|
||||
await this.handleCookieBanner();
|
||||
|
||||
// Send a message to mark that the cookie banner handling has been executed.
|
||||
this.sendAsyncMessage("CookieBanner::MarkSiteExecuted");
|
||||
|
||||
let dispatchedEventsForCookieInjection =
|
||||
this.#dispatchEventsForBannerHandledByInjection();
|
||||
// A cookie injection followed by not detecting the banner via querySelector
|
||||
|
|
|
|||
|
|
@ -22,12 +22,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
|||
"cookiebanners.service.mode.privateBrowsing",
|
||||
Ci.nsICookieBannerService.MODE_DISABLED
|
||||
);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
lazy,
|
||||
"executeOnce",
|
||||
"cookiebanners.bannerClicking.executeOnce",
|
||||
true
|
||||
);
|
||||
|
||||
ChromeUtils.defineLazyGetter(lazy, "CookieBannerL10n", () => {
|
||||
return new Localization([
|
||||
|
|
@ -52,24 +46,12 @@ export class CookieBannerParent extends JSWindowActorParent {
|
|||
return topBC.embedderElement;
|
||||
}
|
||||
|
||||
get #isTopLevel() {
|
||||
return !this.manager.browsingContext.parent;
|
||||
}
|
||||
|
||||
#isPrivateBrowsingCached;
|
||||
get #isPrivateBrowsing() {
|
||||
if (this.#isPrivateBrowsingCached !== undefined) {
|
||||
return this.#isPrivateBrowsingCached;
|
||||
}
|
||||
#isPrivateBrowsing() {
|
||||
let browser = this.#browserElement;
|
||||
if (!browser) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.#isPrivateBrowsingCached =
|
||||
lazy.PrivateBrowsingUtils.isBrowserPrivate(browser);
|
||||
|
||||
return this.#isPrivateBrowsingCached;
|
||||
return lazy.PrivateBrowsingUtils.isBrowserPrivate(browser);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -144,28 +126,14 @@ export class CookieBannerParent extends JSWindowActorParent {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
let domain = this.manager.documentPrincipal?.baseDomain;
|
||||
|
||||
if (message.name == "CookieBanner::MarkSiteExecuted") {
|
||||
if (!domain) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Services.cookieBanners.markSiteExecuted(
|
||||
domain,
|
||||
this.#isTopLevel,
|
||||
this.#isPrivateBrowsing
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (message.name != "CookieBanner::GetClickRules") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// TODO: Bug 1790688: consider moving this logic to the cookie banner service.
|
||||
let mode;
|
||||
if (this.#isPrivateBrowsing) {
|
||||
let isPrivateBrowsing = this.#isPrivateBrowsing();
|
||||
if (isPrivateBrowsing) {
|
||||
mode = lazy.serviceModePBM;
|
||||
} else {
|
||||
mode = lazy.serviceMode;
|
||||
|
|
@ -182,7 +150,7 @@ export class CookieBannerParent extends JSWindowActorParent {
|
|||
try {
|
||||
let perDomainMode = Services.cookieBanners.getDomainPref(
|
||||
topURI,
|
||||
this.#isPrivateBrowsing
|
||||
isPrivateBrowsing
|
||||
);
|
||||
|
||||
if (perDomainMode != Ci.nsICookieBannerService.MODE_UNSET) {
|
||||
|
|
@ -200,43 +168,33 @@ export class CookieBannerParent extends JSWindowActorParent {
|
|||
}
|
||||
}
|
||||
|
||||
// Check if we previously executed banner clicking for the site before. If
|
||||
// the pref instructs to always execute banner clicking, we will set it to
|
||||
// false.
|
||||
let hasExecuted = false;
|
||||
if (lazy.executeOnce) {
|
||||
hasExecuted = Services.cookieBanners.hasExecutedForSite(
|
||||
domain,
|
||||
this.#isTopLevel,
|
||||
this.#isPrivateBrowsing
|
||||
);
|
||||
// Service is disabled for current context (normal or private browsing),
|
||||
// return empty array.
|
||||
if (mode == Ci.nsICookieBannerService.MODE_DISABLED) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// If we have previously executed banner clicking or the service is disabled
|
||||
// for current context (normal or private browsing), return empty array.
|
||||
if (hasExecuted || mode == Ci.nsICookieBannerService.MODE_DISABLED) {
|
||||
return { rules: [], hasExecuted };
|
||||
}
|
||||
let domain = this.manager.documentPrincipal?.baseDomain;
|
||||
|
||||
if (!domain) {
|
||||
return { rules: [], hasExecuted };
|
||||
return [];
|
||||
}
|
||||
|
||||
let isTopLevel = !this.manager.browsingContext.parent;
|
||||
let rules = Services.cookieBanners.getClickRulesForDomain(
|
||||
domain,
|
||||
this.#isTopLevel
|
||||
isTopLevel
|
||||
);
|
||||
|
||||
if (!rules.length) {
|
||||
return { rules: [], hasExecuted };
|
||||
return [];
|
||||
}
|
||||
|
||||
// Determine whether we can fall back to opt-in rules. This includes the
|
||||
// detect-only mode where don't interact with the banner.
|
||||
let modeAllowsOptIn =
|
||||
mode == Ci.nsICookieBannerService.MODE_REJECT_OR_ACCEPT;
|
||||
|
||||
rules = rules.map(rule => {
|
||||
return rules.map(rule => {
|
||||
let target = rule.optOut;
|
||||
|
||||
if (modeAllowsOptIn && !target) {
|
||||
|
|
@ -249,7 +207,5 @@ export class CookieBannerParent extends JSWindowActorParent {
|
|||
target,
|
||||
};
|
||||
});
|
||||
|
||||
return { rules, hasExecuted };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,12 +158,6 @@ nsCookieBannerService::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
return RemoveWebProgressListener(aSubject);
|
||||
}
|
||||
|
||||
// Clear the executed data for private session when the last private browsing
|
||||
// session exits.
|
||||
if (nsCRT::strcmp(aTopic, "last-pb-context-exited") == 0) {
|
||||
return RemoveAllExecutedRecords(true);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
@ -214,8 +208,6 @@ nsresult nsCookieBannerService::Init() {
|
|||
obsSvc->AddObserver(this, OBSERVER_TOPIC_BC_ATTACHED, false);
|
||||
obsSvc->AddObserver(this, OBSERVER_TOPIC_BC_DISCARDED, false);
|
||||
|
||||
obsSvc->AddObserver(this, "last-pb-context-exited", false);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
@ -243,8 +235,6 @@ nsresult nsCookieBannerService::Shutdown() {
|
|||
obsSvc->RemoveObserver(this, OBSERVER_TOPIC_BC_ATTACHED);
|
||||
obsSvc->RemoveObserver(this, OBSERVER_TOPIC_BC_DISCARDED);
|
||||
|
||||
obsSvc->RemoveObserver(this, "last-pb-context-exited");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
@ -913,122 +903,6 @@ nsCookieBannerService::RemoveAllDomainPrefs(const bool aIsPrivate) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieBannerService::HasExecutedForSite(const nsACString& aSite,
|
||||
const bool aIsTopLevel,
|
||||
const bool aIsPrivate,
|
||||
bool* aHasExecuted) {
|
||||
if (!mIsInitialized) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
auto entry = mExecutedDataForSites.MaybeGet(aSite);
|
||||
|
||||
if (!entry) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
auto& data = entry.ref();
|
||||
|
||||
if (aIsPrivate) {
|
||||
*aHasExecuted = aIsTopLevel ? data.hasExecutedInTopPrivate
|
||||
: data.hasExecutedInFramePrivate;
|
||||
} else {
|
||||
*aHasExecuted =
|
||||
aIsTopLevel ? data.hasExecutedInTop : data.hasExecutedInFrame;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieBannerService::MarkSiteExecuted(const nsACString& aSite,
|
||||
const bool aIsTopLevel,
|
||||
const bool aIsPrivate) {
|
||||
NS_ENSURE_TRUE(!aSite.IsEmpty(), NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (!mIsInitialized) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
auto& data = mExecutedDataForSites.LookupOrInsert(aSite);
|
||||
|
||||
if (aIsPrivate) {
|
||||
if (aIsTopLevel) {
|
||||
data.hasExecutedInTopPrivate = true;
|
||||
} else {
|
||||
data.hasExecutedInFramePrivate = true;
|
||||
}
|
||||
} else {
|
||||
if (aIsTopLevel) {
|
||||
data.hasExecutedInTop = true;
|
||||
} else {
|
||||
data.hasExecutedInFrame = true;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieBannerService::RemoveExecutedRecordForSite(const nsACString& aSite,
|
||||
const bool aIsPrivate) {
|
||||
if (!mIsInitialized) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
auto entry = mExecutedDataForSites.Lookup(aSite);
|
||||
|
||||
if (!entry) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
auto data = entry.Data();
|
||||
|
||||
if (aIsPrivate) {
|
||||
data.hasExecutedInTopPrivate = false;
|
||||
data.hasExecutedInFramePrivate = false;
|
||||
} else {
|
||||
data.hasExecutedInTop = false;
|
||||
data.hasExecutedInFrame = false;
|
||||
}
|
||||
|
||||
// We can remove the entry if there is no flag set after removal.
|
||||
if (!data.hasExecutedInTop && !data.hasExecutedInFrame &&
|
||||
!data.hasExecutedInTopPrivate && !data.hasExecutedInFramePrivate) {
|
||||
entry.Remove();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieBannerService::RemoveAllExecutedRecords(const bool aIsPrivate) {
|
||||
if (!mIsInitialized) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
for (auto iter = mExecutedDataForSites.Iter(); !iter.Done(); iter.Next()) {
|
||||
auto& data = iter.Data();
|
||||
// Clear the flags.
|
||||
if (aIsPrivate) {
|
||||
data.hasExecutedInTopPrivate = false;
|
||||
data.hasExecutedInFramePrivate = false;
|
||||
} else {
|
||||
data.hasExecutedInTop = false;
|
||||
data.hasExecutedInFrame = false;
|
||||
}
|
||||
|
||||
// Remove the entry if there is no flag set.
|
||||
if (!data.hasExecutedInTop && !data.hasExecutedInFrame &&
|
||||
!data.hasExecutedInTopPrivate && !data.hasExecutedInFramePrivate) {
|
||||
iter.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieBannerService::ResetDomainTelemetryRecord(const nsACString& aDomain) {
|
||||
if (aDomain.IsEmpty()) {
|
||||
|
|
|
|||
|
|
@ -134,25 +134,6 @@ class nsCookieBannerService final : public nsIObserver,
|
|||
|
||||
void ReportRuleLookupTelemetry(const nsACString& aDomain,
|
||||
nsICookieBannerRule* aRule, bool aIsTopLevel);
|
||||
|
||||
// A record that stores whether we have executed the banner click for the
|
||||
// context.
|
||||
typedef struct ExecutedData {
|
||||
ExecutedData()
|
||||
: hasExecutedInTop(false),
|
||||
hasExecutedInFrame(false),
|
||||
hasExecutedInTopPrivate(false),
|
||||
hasExecutedInFramePrivate(false) {}
|
||||
|
||||
bool hasExecutedInTop;
|
||||
bool hasExecutedInFrame;
|
||||
bool hasExecutedInTopPrivate;
|
||||
bool hasExecutedInFramePrivate;
|
||||
} ExecutedData;
|
||||
|
||||
// Map of the sites (eTLD+1) that we have executed the cookie banner handling
|
||||
// for this session.
|
||||
nsTHashMap<nsCStringHashKey, ExecutedData> mExecutedDataForSites;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
|||
|
|
@ -126,34 +126,6 @@ interface nsICookieBannerService : nsISupports {
|
|||
*/
|
||||
void removeAllDomainPrefs(in boolean aIsPrivate);
|
||||
|
||||
/**
|
||||
* Return if we have run the cookie banner handling code for the given site
|
||||
* this session.
|
||||
*/
|
||||
boolean hasExecutedForSite(in ACString aSite,
|
||||
in bool aIsTopLevel,
|
||||
in bool aIsPrivate);
|
||||
|
||||
/**
|
||||
* Mark that the cookie banner handling code was executed for the given site
|
||||
* for this session.
|
||||
*/
|
||||
void markSiteExecuted(in ACString aSite,
|
||||
in bool aIsTopLevel,
|
||||
in bool aIsPrivate);
|
||||
|
||||
/*
|
||||
* Remove the executed record for a given site under the private browsing
|
||||
* session or the normal session.
|
||||
*/
|
||||
void removeExecutedRecordForSite(in ACString aSite, in bool aIsPrivate);
|
||||
|
||||
/**
|
||||
* Remove all the record of sites where cookie banner handling has been
|
||||
* executed under the private browsing session or normal session.
|
||||
*/
|
||||
void removeAllExecutedRecords(in bool aIsPrivate);
|
||||
|
||||
/**
|
||||
* Clears the in-memory set that we use to maintain the domains that we have
|
||||
* reported telemetry. This function will clear the entry for the given
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ support-files = [
|
|||
["browser_bannerClicking_events.js"]
|
||||
support-files = ["file_banner.html"]
|
||||
|
||||
["browser_bannerClicking_executeOnce.js"]
|
||||
|
||||
["browser_bannerClicking_globalRules.js"]
|
||||
|
||||
["browser_bannerClicking_runContext.js"]
|
||||
|
|
|
|||
|
|
@ -26,11 +26,6 @@ add_task(async function test_cookie_banner_service_disabled() {
|
|||
],
|
||||
});
|
||||
|
||||
// Clear the executed records before testing.
|
||||
if (serviceMode != Ci.nsICookieBannerService.MODE_DISABLED) {
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
}
|
||||
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_A,
|
||||
|
|
@ -55,9 +50,6 @@ add_task(async function test_no_rules() {
|
|||
],
|
||||
});
|
||||
|
||||
// Clear the executed records before testing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
info("Clearing existing rules");
|
||||
Services.cookieBanners.resetRules(false);
|
||||
|
||||
|
|
@ -83,9 +75,6 @@ add_task(async function test_clicking_mode_reject() {
|
|||
],
|
||||
});
|
||||
|
||||
// Clear the executed records before testing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
insertTestClickRules();
|
||||
|
||||
await openPageAndVerify({
|
||||
|
|
@ -101,8 +90,6 @@ add_task(async function test_clicking_mode_reject() {
|
|||
false
|
||||
);
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
// No opt out rule for the example.org, the banner shouldn't be clicked.
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
|
|
@ -134,9 +121,6 @@ add_task(async function test_clicking_mode_reject_or_accept() {
|
|||
],
|
||||
});
|
||||
|
||||
// Clear the executed records before testing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
insertTestClickRules();
|
||||
|
||||
await testClickResultTelemetry({});
|
||||
|
|
@ -157,8 +141,6 @@ add_task(async function test_clicking_mode_reject_or_accept() {
|
|||
false
|
||||
);
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_B,
|
||||
|
|
@ -185,9 +167,6 @@ add_task(async function test_clicking_with_delayed_banner() {
|
|||
],
|
||||
});
|
||||
|
||||
// Clear the executed records before testing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
insertTestClickRules();
|
||||
|
||||
await testClickResultTelemetry({});
|
||||
|
|
@ -218,9 +197,6 @@ add_task(async function test_embedded_iframe() {
|
|||
],
|
||||
});
|
||||
|
||||
// Clear the executed records before testing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
insertTestClickRules();
|
||||
|
||||
await testClickResultTelemetry({});
|
||||
|
|
@ -252,9 +228,6 @@ add_task(async function test_pbm() {
|
|||
],
|
||||
});
|
||||
|
||||
// Clear the executed records before testing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
insertTestClickRules();
|
||||
|
||||
await testClickResultTelemetry({});
|
||||
|
|
@ -294,9 +267,6 @@ add_task(async function test_pref_pbm_pref() {
|
|||
],
|
||||
});
|
||||
|
||||
// Clear the executed records before testing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
insertTestClickRules();
|
||||
|
||||
await testClickResultTelemetry({});
|
||||
|
|
@ -320,8 +290,6 @@ add_task(async function test_pref_pbm_pref() {
|
|||
false
|
||||
);
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
await openPageAndVerify({
|
||||
win: pbmWindow,
|
||||
domain: TEST_DOMAIN_A,
|
||||
|
|
@ -349,8 +317,6 @@ add_task(async function test_pref_pbm_pref() {
|
|||
],
|
||||
});
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
await openPageAndVerify({
|
||||
domain: TEST_DOMAIN_A,
|
||||
testURL: TEST_PAGE_A,
|
||||
|
|
@ -366,8 +332,6 @@ add_task(async function test_pref_pbm_pref() {
|
|||
false
|
||||
);
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
await openPageAndVerify({
|
||||
win: pbmWindow,
|
||||
domain: TEST_DOMAIN_A,
|
||||
|
|
@ -400,8 +364,6 @@ add_task(async function test_pref_pbm_pref() {
|
|||
],
|
||||
});
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
info(
|
||||
"The normal browsing window accepts the banner according to the opt-in rule."
|
||||
);
|
||||
|
|
@ -421,8 +383,6 @@ add_task(async function test_pref_pbm_pref() {
|
|||
false
|
||||
);
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
info(
|
||||
"The private browsing window should not perform any click, because there is only an opt-in rule."
|
||||
);
|
||||
|
|
@ -457,9 +417,6 @@ add_task(async function test_embedded_iframe_pbm() {
|
|||
],
|
||||
});
|
||||
|
||||
// Clear the executed records before testing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
insertTestClickRules();
|
||||
|
||||
await testClickResultTelemetry({});
|
||||
|
|
|
|||
|
|
@ -3,10 +3,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
let { ForgetAboutSite } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/ForgetAboutSite.sys.mjs"
|
||||
);
|
||||
|
||||
add_setup(clickTestSetup);
|
||||
|
||||
/**
|
||||
|
|
@ -25,10 +21,6 @@ add_task(async function test_domain_preference() {
|
|||
|
||||
insertTestClickRules();
|
||||
|
||||
// Clear executed records before testing for private and normal browsing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(true);
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
for (let testPBM of [false, true]) {
|
||||
let testWin = window;
|
||||
if (testPBM) {
|
||||
|
|
@ -58,8 +50,6 @@ add_task(async function test_domain_preference() {
|
|||
false
|
||||
);
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(testPBM);
|
||||
|
||||
info("Set the domain preference of example.org to MODE_REJECT_OR_ACCEPT");
|
||||
let uri = Services.io.newURI(TEST_ORIGIN_B);
|
||||
Services.cookieBanners.setDomainPref(
|
||||
|
|
@ -110,10 +100,6 @@ add_task(async function test_domain_preference_iframe() {
|
|||
|
||||
insertTestClickRules();
|
||||
|
||||
// Clear executed records before testing for private and normal browsing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(true);
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
await testClickResultTelemetry({});
|
||||
|
||||
for (let testPBM of [false, true]) {
|
||||
|
|
@ -143,8 +129,6 @@ add_task(async function test_domain_preference_iframe() {
|
|||
false
|
||||
);
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(testPBM);
|
||||
|
||||
info(
|
||||
"Set the domain preference of the top-level domain to MODE_REJECT_OR_ACCEPT"
|
||||
);
|
||||
|
|
@ -180,189 +164,3 @@ add_task(async function test_domain_preference_iframe() {
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Verify that the ForgetAboutSite clears the domain preference properly.
|
||||
add_task(async function test_domain_preference_forgetAboutSite() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["cookiebanners.service.mode", Ci.nsICookieBannerService.MODE_REJECT],
|
||||
[
|
||||
"cookiebanners.service.mode.privateBrowsing",
|
||||
Ci.nsICookieBannerService.MODE_REJECT,
|
||||
],
|
||||
],
|
||||
});
|
||||
|
||||
insertTestClickRules();
|
||||
|
||||
// Clear executed records before testing for private and normal browsing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(true);
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
info("Set the domain preference of example.org to MODE_REJECT_OR_ACCEPT");
|
||||
let uri = Services.io.newURI(TEST_ORIGIN_B);
|
||||
Services.cookieBanners.setDomainPref(
|
||||
uri,
|
||||
Ci.nsICookieBannerService.MODE_REJECT_OR_ACCEPT,
|
||||
false
|
||||
);
|
||||
|
||||
info(
|
||||
"Verify if domain preference takes precedence over then the pref setting for example.org"
|
||||
);
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_B,
|
||||
testURL: TEST_PAGE_B,
|
||||
visible: false,
|
||||
expected: "OptIn",
|
||||
});
|
||||
|
||||
// Call ForgetAboutSite for the domain.
|
||||
await ForgetAboutSite.removeDataFromDomain(TEST_DOMAIN_B);
|
||||
|
||||
info("Ensure the domain preference is cleared.");
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_B,
|
||||
testURL: TEST_PAGE_B,
|
||||
visible: true,
|
||||
expected: "NoClick",
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_domain_preference_clearDataService() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["cookiebanners.service.mode", Ci.nsICookieBannerService.MODE_REJECT],
|
||||
[
|
||||
"cookiebanners.service.mode.privateBrowsing",
|
||||
Ci.nsICookieBannerService.MODE_REJECT,
|
||||
],
|
||||
],
|
||||
});
|
||||
|
||||
insertTestClickRules();
|
||||
|
||||
// Clear executed records before testing or private and normal browsing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(true);
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
info("Set the domain preference of example.org to MODE_REJECT_OR_ACCEPT");
|
||||
let uri = Services.io.newURI(TEST_ORIGIN_B);
|
||||
Services.cookieBanners.setDomainPref(
|
||||
uri,
|
||||
Ci.nsICookieBannerService.MODE_REJECT_OR_ACCEPT,
|
||||
false
|
||||
);
|
||||
|
||||
info(
|
||||
"Verify if domain preference takes precedence over then the pref setting for example.org"
|
||||
);
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_B,
|
||||
testURL: TEST_PAGE_B,
|
||||
visible: false,
|
||||
expected: "OptIn",
|
||||
});
|
||||
|
||||
info("Call ClearDataService.deleteDataFromBaseDomain for the domain.");
|
||||
await new Promise(aResolve => {
|
||||
Services.clearData.deleteDataFromBaseDomain(
|
||||
TEST_DOMAIN_B,
|
||||
true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXCEPTION,
|
||||
aResolve
|
||||
);
|
||||
});
|
||||
|
||||
info("Ensure the domain preference is cleared.");
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_B,
|
||||
testURL: TEST_PAGE_B,
|
||||
visible: true,
|
||||
expected: "NoClick",
|
||||
});
|
||||
|
||||
info("Set the domain preference of example.org to MODE_REJECT_OR_ACCEPT");
|
||||
Services.cookieBanners.setDomainPref(
|
||||
uri,
|
||||
Ci.nsICookieBannerService.MODE_REJECT_OR_ACCEPT,
|
||||
false
|
||||
);
|
||||
|
||||
info("Call ClearDataService.deleteDataFromHost for the domain.");
|
||||
await new Promise(aResolve => {
|
||||
Services.clearData.deleteDataFromHost(
|
||||
TEST_DOMAIN_B,
|
||||
true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXCEPTION,
|
||||
aResolve
|
||||
);
|
||||
});
|
||||
|
||||
info("Ensure the domain preference is cleared.");
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_B,
|
||||
testURL: TEST_PAGE_B,
|
||||
visible: true,
|
||||
expected: "NoClick",
|
||||
});
|
||||
|
||||
info("Set the domain preference of example.org to MODE_REJECT_OR_ACCEPT");
|
||||
Services.cookieBanners.setDomainPref(
|
||||
uri,
|
||||
Ci.nsICookieBannerService.MODE_REJECT_OR_ACCEPT,
|
||||
false
|
||||
);
|
||||
|
||||
info("Call ClearDataService.deleteDataFromPrincipal for the domain.");
|
||||
let principal =
|
||||
Services.scriptSecurityManager.createContentPrincipalFromOrigin(
|
||||
"https://" + TEST_DOMAIN_B
|
||||
);
|
||||
await new Promise(aResolve => {
|
||||
Services.clearData.deleteDataFromPrincipal(
|
||||
principal,
|
||||
true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXCEPTION,
|
||||
aResolve
|
||||
);
|
||||
});
|
||||
|
||||
info("Ensure the domain preference is cleared.");
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_B,
|
||||
testURL: TEST_PAGE_B,
|
||||
visible: true,
|
||||
expected: "NoClick",
|
||||
});
|
||||
|
||||
info("Set the domain preference of example.org to MODE_REJECT_OR_ACCEPT");
|
||||
Services.cookieBanners.setDomainPref(
|
||||
uri,
|
||||
Ci.nsICookieBannerService.MODE_REJECT_OR_ACCEPT,
|
||||
false
|
||||
);
|
||||
|
||||
info("Call ClearDataService.deleteData for the domain.");
|
||||
await new Promise(aResolve => {
|
||||
Services.clearData.deleteData(
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXCEPTION,
|
||||
aResolve
|
||||
);
|
||||
});
|
||||
|
||||
info("Ensure the domain preference is cleared.");
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_B,
|
||||
testURL: TEST_PAGE_B,
|
||||
visible: true,
|
||||
expected: "NoClick",
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -41,9 +41,6 @@ async function runTest({ mode, detectOnly = false, openPageOptions = {} }) {
|
|||
});
|
||||
};
|
||||
|
||||
// Clear executed records before testing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
await runEventTest({ mode, detectOnly, initFn, triggerFn, testURL });
|
||||
|
||||
// Clean up the test tab opened by openPageAndVerify.
|
||||
|
|
|
|||
|
|
@ -1,261 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
let { ForgetAboutSite } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/ForgetAboutSite.sys.mjs"
|
||||
);
|
||||
|
||||
add_setup(async function () {
|
||||
await clickTestSetup();
|
||||
|
||||
// Enable the pref to once execute cookie banner handling once per domain.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["cookiebanners.bannerClicking.executeOnce", true]],
|
||||
});
|
||||
|
||||
// Clean the records.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
Services.cookieBanners.removeAllExecutedRecords(true);
|
||||
});
|
||||
|
||||
// Ensure the banner clicking doesn't execute at the second load if the
|
||||
// executeOnce feature is enabled.
|
||||
add_task(async function testExecuteOnce() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["cookiebanners.service.mode", Ci.nsICookieBannerService.MODE_REJECT],
|
||||
[
|
||||
"cookiebanners.service.mode.privateBrowsing",
|
||||
Ci.nsICookieBannerService.MODE_REJECT,
|
||||
],
|
||||
],
|
||||
});
|
||||
|
||||
insertTestClickRules();
|
||||
|
||||
// Open the domain and ensure the banner is clicked.
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_A,
|
||||
testURL: TEST_PAGE_A,
|
||||
visible: false,
|
||||
expected: "OptOut",
|
||||
});
|
||||
|
||||
// Open the domain again and the banner shouldn't be hidden nor the banner is
|
||||
// clicked.
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_A,
|
||||
testURL: TEST_PAGE_A,
|
||||
visible: true,
|
||||
expected: "NoClick",
|
||||
});
|
||||
|
||||
// Clear the record for the normal window.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
// Open the domain again after clearing the record and ensure the banner is
|
||||
// clicked.
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_A,
|
||||
testURL: TEST_PAGE_A,
|
||||
visible: false,
|
||||
expected: "OptOut",
|
||||
});
|
||||
|
||||
// Test in the private browsing mode.
|
||||
let pbmWindow = await BrowserTestUtils.openNewBrowserWindow({
|
||||
private: true,
|
||||
});
|
||||
|
||||
// Open the domain in PBM and ensure the banner is clicked.
|
||||
await openPageAndVerify({
|
||||
win: pbmWindow,
|
||||
domain: TEST_DOMAIN_A,
|
||||
testURL: TEST_PAGE_A,
|
||||
visible: false,
|
||||
expected: "OptOut",
|
||||
});
|
||||
|
||||
// Open the domain in PBM again and the banner shouldn't be hidden nor the
|
||||
// banner is clicked.
|
||||
await openPageAndVerify({
|
||||
win: pbmWindow,
|
||||
domain: TEST_DOMAIN_A,
|
||||
testURL: TEST_PAGE_A,
|
||||
visible: true,
|
||||
expected: "NoClick",
|
||||
});
|
||||
|
||||
// Clear the record for the private window.
|
||||
Services.cookieBanners.removeAllExecutedRecords(true);
|
||||
|
||||
// Open the domain again in PBM after clearing the record, and ensure the
|
||||
// banner is clicked.
|
||||
await openPageAndVerify({
|
||||
win: pbmWindow,
|
||||
domain: TEST_DOMAIN_A,
|
||||
testURL: TEST_PAGE_A,
|
||||
visible: false,
|
||||
expected: "OptOut",
|
||||
});
|
||||
|
||||
await BrowserTestUtils.closeWindow(pbmWindow);
|
||||
|
||||
// Clean the records.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
Services.cookieBanners.removeAllExecutedRecords(true);
|
||||
});
|
||||
|
||||
// Ensure that ForgetAboutSite clears the handled record properly.
|
||||
add_task(async function testForgetAboutSiteWithExecuteOnce() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["cookiebanners.service.mode", Ci.nsICookieBannerService.MODE_REJECT],
|
||||
],
|
||||
});
|
||||
|
||||
insertTestClickRules();
|
||||
|
||||
// Open the domain and ensure the banner is clicked.
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_A,
|
||||
testURL: TEST_PAGE_A,
|
||||
visible: false,
|
||||
expected: "OptOut",
|
||||
});
|
||||
|
||||
// Open the domain again and the banner shouldn't be hidden nor the banner is
|
||||
// clicked.
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_A,
|
||||
testURL: TEST_PAGE_A,
|
||||
visible: true,
|
||||
expected: "NoClick",
|
||||
});
|
||||
|
||||
// Call ForgetAboutSite for the domain.
|
||||
await ForgetAboutSite.removeDataFromDomain(TEST_DOMAIN_A);
|
||||
|
||||
// Open the domain again after ForgetAboutSite and the clicking should work
|
||||
// again.
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_A,
|
||||
testURL: TEST_PAGE_A,
|
||||
visible: false,
|
||||
expected: "OptOut",
|
||||
});
|
||||
|
||||
// Clean the records.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
Services.cookieBanners.removeAllExecutedRecords(true);
|
||||
});
|
||||
|
||||
// Ensure the ClearDataService clears the handled record properly.
|
||||
add_task(async function testClearDataServiceWithExecuteOnce() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["cookiebanners.service.mode", Ci.nsICookieBannerService.MODE_REJECT],
|
||||
],
|
||||
});
|
||||
|
||||
insertTestClickRules();
|
||||
|
||||
// Open the domain initially and ensure the banner is clicked.
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_A,
|
||||
testURL: TEST_PAGE_A,
|
||||
visible: false,
|
||||
expected: "OptOut",
|
||||
});
|
||||
|
||||
// Invoke deleteDataFromBaseDomain.
|
||||
await new Promise(aResolve => {
|
||||
Services.clearData.deleteDataFromBaseDomain(
|
||||
TEST_DOMAIN_A,
|
||||
true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD,
|
||||
aResolve
|
||||
);
|
||||
});
|
||||
|
||||
// Ensure the record is cleared. The banner clicking should work after clean.
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_A,
|
||||
testURL: TEST_PAGE_A,
|
||||
visible: false,
|
||||
expected: "OptOut",
|
||||
});
|
||||
|
||||
// Invoke deleteDataFromHost.
|
||||
await new Promise(aResolve => {
|
||||
Services.clearData.deleteDataFromHost(
|
||||
TEST_DOMAIN_A,
|
||||
true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD,
|
||||
aResolve
|
||||
);
|
||||
});
|
||||
|
||||
// Ensure the record is cleared. The banner clicking should work after clean.
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_A,
|
||||
testURL: TEST_PAGE_A,
|
||||
visible: false,
|
||||
expected: "OptOut",
|
||||
});
|
||||
|
||||
// Invoke deleteDataFromPrincipal.
|
||||
let principal =
|
||||
Services.scriptSecurityManager.createContentPrincipalFromOrigin(
|
||||
"https://" + TEST_DOMAIN_A
|
||||
);
|
||||
await new Promise(aResolve => {
|
||||
Services.clearData.deleteDataFromPrincipal(
|
||||
principal,
|
||||
true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD,
|
||||
aResolve
|
||||
);
|
||||
});
|
||||
|
||||
// Ensure the record is cleared. The banner clicking should work after clean.
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_A,
|
||||
testURL: TEST_PAGE_A,
|
||||
visible: false,
|
||||
expected: "OptOut",
|
||||
});
|
||||
|
||||
// Invoke deleteData.
|
||||
await new Promise(aResolve => {
|
||||
Services.clearData.deleteData(
|
||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD,
|
||||
aResolve
|
||||
);
|
||||
});
|
||||
|
||||
// Ensure the record is cleared. The banner clicking should work after clean.
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_A,
|
||||
testURL: TEST_PAGE_A,
|
||||
visible: false,
|
||||
expected: "OptOut",
|
||||
});
|
||||
|
||||
// Clean the records.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
Services.cookieBanners.removeAllExecutedRecords(true);
|
||||
});
|
||||
|
|
@ -16,9 +16,6 @@ add_task(async function test_clicking_global_rules() {
|
|||
],
|
||||
});
|
||||
|
||||
// Clear the executed records before testing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
info("Clearing existing rules");
|
||||
Services.cookieBanners.resetRules(false);
|
||||
|
||||
|
|
@ -94,8 +91,6 @@ add_task(async function test_clicking_global_rules() {
|
|||
false
|
||||
);
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
await openPageAndVerify({
|
||||
domain: TEST_DOMAIN_B,
|
||||
testURL: TEST_PAGE_B,
|
||||
|
|
@ -111,8 +106,6 @@ add_task(async function test_clicking_global_rules() {
|
|||
false
|
||||
);
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
info("No global rule should handle TEST_PAGE_C with div#bannerB.");
|
||||
await openPageAndVerify({
|
||||
domain: TEST_DOMAIN_C,
|
||||
|
|
@ -136,9 +129,6 @@ add_task(async function test_clicking_global_rules() {
|
|||
set: [["cookiebanners.bannerClicking.timeoutAfterLoad", 10000]],
|
||||
});
|
||||
|
||||
// Clear the executed records before testing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
info("Test delayed banner handling with global rules.");
|
||||
let TEST_PAGE =
|
||||
TEST_ORIGIN_A + TEST_PATH + "file_delayed_banner.html?delay=100";
|
||||
|
|
@ -174,9 +164,6 @@ add_task(async function test_clicking_global_rules_precedence() {
|
|||
],
|
||||
});
|
||||
|
||||
// Clear the executed records before testing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
info("Clearing existing rules");
|
||||
Services.cookieBanners.resetRules(false);
|
||||
|
||||
|
|
|
|||
|
|
@ -47,9 +47,6 @@ add_task(async function test_embedded_iframe() {
|
|||
|
||||
insertTestRules({ runContext: Ci.nsIClickRule.RUN_TOP });
|
||||
|
||||
// Clear executed records before testing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
await openIframeAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_A,
|
||||
|
|
@ -57,9 +54,6 @@ add_task(async function test_embedded_iframe() {
|
|||
visible: true,
|
||||
expected: "NoClick",
|
||||
});
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_A,
|
||||
|
|
@ -68,8 +62,6 @@ add_task(async function test_embedded_iframe() {
|
|||
expected: "OptOut",
|
||||
});
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
insertTestRules({ runContext: Ci.nsIClickRule.RUN_CHILD });
|
||||
|
||||
await openIframeAndVerify({
|
||||
|
|
@ -79,9 +71,6 @@ add_task(async function test_embedded_iframe() {
|
|||
visible: false,
|
||||
expected: "OptOut",
|
||||
});
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_A,
|
||||
|
|
@ -90,8 +79,6 @@ add_task(async function test_embedded_iframe() {
|
|||
expected: "NoClick",
|
||||
});
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
insertTestRules({ runContext: Ci.nsIClickRule.RUN_ALL });
|
||||
await openIframeAndVerify({
|
||||
win: window,
|
||||
|
|
@ -100,9 +87,6 @@ add_task(async function test_embedded_iframe() {
|
|||
visible: false,
|
||||
expected: "OptOut",
|
||||
});
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
domain: TEST_DOMAIN_A,
|
||||
|
|
@ -110,6 +94,4 @@ add_task(async function test_embedded_iframe() {
|
|||
visible: false,
|
||||
expected: "OptOut",
|
||||
});
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -110,8 +110,6 @@ add_task(async function test_click_query_selector_telemetry() {
|
|||
hasTopLevelData: true,
|
||||
});
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
info("Top level cookie banner with matching rule.");
|
||||
await openPageAndVerify({
|
||||
win: window,
|
||||
|
|
@ -125,8 +123,6 @@ add_task(async function test_click_query_selector_telemetry() {
|
|||
hasTopLevelData: true,
|
||||
});
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
info("Iframe cookie banner with matching rule.");
|
||||
await openIframeAndVerify({
|
||||
win: window,
|
||||
|
|
@ -140,8 +136,6 @@ add_task(async function test_click_query_selector_telemetry() {
|
|||
hasTopLevelData: true,
|
||||
});
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
// Reset test rules and insert only site-specific rules so we can ensure the
|
||||
// clicking mechanism is only running for the iframe, not the top level.
|
||||
info("Insert test rules without global rules.");
|
||||
|
|
|
|||
|
|
@ -52,9 +52,6 @@ add_task(async function test_clicking_with_delayed_banner() {
|
|||
});
|
||||
|
||||
for (let skipPresenceVisibilityCheck of [false, true]) {
|
||||
// Clear the executed records before testing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
insertVisibilityTestRules(skipPresenceVisibilityCheck);
|
||||
|
||||
await testClickResultTelemetry({});
|
||||
|
|
|
|||
|
|
@ -200,9 +200,6 @@ add_task(async function test_rule_lookup_telemetry_no_rule() {
|
|||
for (let context of ["top", "iframe"]) {
|
||||
let isTop = context === "top";
|
||||
|
||||
// Clear the executed records before testing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
// Open a test domain. We should record a rule miss because there is no rule
|
||||
// right now
|
||||
info("Open a test domain.");
|
||||
|
|
@ -230,8 +227,6 @@ add_task(async function test_rule_lookup_telemetry_no_rule() {
|
|||
verifyLookUpTelemetry("ruleLookupByLoad", expectedTelemetryOnce);
|
||||
verifyLookUpTelemetry("ruleLookupByDomain", expectedTelemetryOnce);
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
info("Open the same domain again.");
|
||||
// Load the same domain again, verify that the telemetry counts increases for
|
||||
// load telemetry not not for domain telemetry.
|
||||
|
|
@ -276,9 +271,6 @@ add_task(async function test_rule_lookup_telemetry() {
|
|||
});
|
||||
insertTestClickRules();
|
||||
|
||||
// Clear the executed records before testing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
// Open a tab for testing.
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
|
||||
|
||||
|
|
@ -349,9 +341,6 @@ add_task(async function test_rule_lookup_telemetry() {
|
|||
}
|
||||
|
||||
for (let context of ["top", "iframe"]) {
|
||||
// Clear the executed records before testing.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
info(`Test in a ${context} context.`);
|
||||
let isTop = context === "top";
|
||||
|
||||
|
|
@ -392,8 +381,6 @@ add_task(async function test_rule_lookup_telemetry() {
|
|||
verifyLookUpTelemetry("ruleLookupByLoad", expectedTelemetry);
|
||||
verifyLookUpTelemetry("ruleLookupByDomain", expectedTelemetry);
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
info("Load a domain with only opt-in clicking rules");
|
||||
await openLookUpTelemetryTestPage(
|
||||
tab.linkedBrowser,
|
||||
|
|
@ -432,8 +419,6 @@ add_task(async function test_rule_lookup_telemetry() {
|
|||
verifyLookUpTelemetry("ruleLookupByLoad", expectedTelemetry);
|
||||
verifyLookUpTelemetry("ruleLookupByDomain", expectedTelemetry);
|
||||
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
|
||||
info(
|
||||
"Load a domain again to verify that we don't collect domain telemetry for this time."
|
||||
);
|
||||
|
|
|
|||
|
|
@ -587,7 +587,7 @@ add_task(async function test_globalRules() {
|
|||
);
|
||||
|
||||
let clickRules = Services.cookieBanners.getClickRulesForDomain(
|
||||
"thishasnorule.com",
|
||||
Services.io.newURI("http://thishasnorule.com"),
|
||||
true
|
||||
);
|
||||
is(
|
||||
|
|
@ -627,8 +627,10 @@ add_task(async function test_globalRules() {
|
|||
);
|
||||
|
||||
is(
|
||||
Services.cookieBanners.getClickRulesForDomain("thishasnorule.com", true)
|
||||
.length,
|
||||
Services.cookieBanners.getClickRulesForDomain(
|
||||
Services.io.newURI("http://thishasnorule.com"),
|
||||
true
|
||||
).length,
|
||||
0,
|
||||
"There should be no click rules for thishasnorule.com since global rules are disabled"
|
||||
);
|
||||
|
|
|
|||
|
|
@ -50,10 +50,6 @@ async function testSetup() {
|
|||
// Restore original rules.
|
||||
Services.cookieBanners.resetRules(true);
|
||||
}
|
||||
|
||||
// Clear executed records.
|
||||
Services.cookieBanners.removeAllExecutedRecords(false);
|
||||
Services.cookieBanners.removeAllExecutedRecords(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue