Bug 1672649 - Part 2: Notify the observer when there is user-interaction or storage access permission added. r=dimi

We need to report when permission is added in order to wait it
explicitly. These will be put be hind a pref
'privacy.antitracking.testing' and should be only used for testing.

Differential Revision: https://phabricator.services.mozilla.com/D94979
This commit is contained in:
Tim Huang 2020-11-04 12:41:40 +00:00
Родитель b5a8e7ac7a
Коммит 442dee0715
3 изменённых файлов: 20 добавлений и 0 удалений

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

@ -9168,6 +9168,14 @@
value: 1800 # 30 minutes (in seconds)
mirror: always
# Enable Anti-tracking testing. When it enables, it will notify the observers
# when user-interaction permission or storage access permission is added. This
# is for testing only.
- name: privacy.antitracking.testing
type: bool
value: false
mirror: always
# Enable the heuristic to allow storage access for recent visited pages
- name: privacy.restrict3rdpartystorage.heuristic.recently_visited
type: bool

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

@ -724,6 +724,12 @@ ContentBlocking::SaveAccessForOriginOnParentProcess(
expirationType, when);
Unused << NS_WARN_IF(NS_FAILED(rv));
if (StaticPrefs::privacy_antitracking_testing()) {
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
obs->NotifyObservers(nullptr, "antitracking-test-storage-access-perm-added",
nullptr);
}
if (NS_SUCCEEDED(rv) && (aAllowMode == eAllowAutoGrant)) {
// Make sure temporary access grants do not survive more than 24 hours.
TemporaryAccessGrantObserver::Create(permManager, aParentPrincipal, type);

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

@ -51,6 +51,12 @@ void ContentBlockingUserInteraction::Observe(nsIPrincipal* aPrincipal) {
nsIPermissionManager::ALLOW_ACTION,
expirationType, when);
Unused << NS_WARN_IF(NS_FAILED(rv));
if (StaticPrefs::privacy_antitracking_testing()) {
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
obs->NotifyObservers(
nullptr, "antitracking-test-user-interaction-perm-added", nullptr);
}
return;
}