1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
|
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/permissions/permission_revocation_request.h"
#include "base/files/scoped_temp_dir.h"
#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/permissions/crowd_deny_fake_safe_browsing_database_manager.h"
#include "chrome/browser/permissions/crowd_deny_preload_data.h"
#include "chrome/browser/permissions/notifications_permission_revocation_config.h"
#include "chrome/browser/safe_browsing/test_safe_browsing_service.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/prefs/pref_service.h"
#include "content/public/test/browser_task_environment.h"
class PermissionRevocationRequestTestBase : public testing::Test {
public:
using Outcome = PermissionRevocationRequest::Outcome;
using SiteReputation = CrowdDenyPreloadData::SiteReputation;
PermissionRevocationRequestTestBase() = default;
PermissionRevocationRequestTestBase(
const PermissionRevocationRequestTestBase&) = delete;
PermissionRevocationRequestTestBase& operator=(
const PermissionRevocationRequestTestBase&) = delete;
~PermissionRevocationRequestTestBase() override = default;
protected:
void SetUp() override {
testing::Test::SetUp();
DCHECK(profile_dir_.CreateUniqueTempDir());
TestingProfile::Builder profile_builder;
profile_builder.SetPath(profile_dir_.GetPath());
profile_builder.AddTestingFactory(
HistoryServiceFactory::GetInstance(),
HistoryServiceFactory::GetDefaultFactory());
testing_profile_ = profile_builder.Build();
fake_database_manager_ =
base::MakeRefCounted<CrowdDenyFakeSafeBrowsingDatabaseManager>();
safe_browsing_factory_ =
std::make_unique<safe_browsing::TestSafeBrowsingServiceFactory>();
safe_browsing_factory_->SetTestDatabaseManager(
fake_database_manager_.get());
TestingBrowserProcess::GetGlobal()->SetSafeBrowsingService(
safe_browsing_factory_->CreateSafeBrowsingService());
}
void TearDown() override {
TestingBrowserProcess::GetGlobal()->SetSafeBrowsingService(nullptr);
testing::Test::TearDown();
}
void AddToSafeBrowsingBlocklist(const GURL& url) {
safe_browsing::ThreatMetadata test_metadata;
test_metadata.api_permissions.emplace("NOTIFICATIONS");
fake_database_manager_->SetSimulatedMetadataForUrl(url, test_metadata);
}
void ClearSafeBrowsingBlocklist() {
fake_database_manager_->RemoveAllBlocklistedUrls();
}
void AddToPreloadDataBlocklist(
const GURL& origin,
chrome_browser_crowd_deny::
SiteReputation_NotificationUserExperienceQuality reputation_type,
bool has_warning) {
SiteReputation reputation;
reputation.set_notification_ux_quality(reputation_type);
reputation.set_warning_only(has_warning);
testing_preload_data_.SetOriginReputation(url::Origin::Create(origin),
std::move(reputation));
}
void QueryAndExpectDecisionForUrl(const GURL& origin,
Outcome expected_result) {
base::MockOnceCallback<void(Outcome)> mock_callback_receiver;
base::RunLoop run_loop;
auto permission_revocation = std::make_unique<PermissionRevocationRequest>(
testing_profile_.get(), origin, mock_callback_receiver.Get());
EXPECT_CALL(mock_callback_receiver, Run(expected_result))
.WillOnce(
testing::InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); }));
run_loop.Run();
}
void SetPermission(const GURL& origin, const ContentSetting value) {
HostContentSettingsMap* host_content_settings_map =
HostContentSettingsMapFactory::GetForProfile(testing_profile_.get());
host_content_settings_map->SetContentSettingDefaultScope(
origin, GURL(), ContentSettingsType::NOTIFICATIONS, value);
}
void VerifyNotificationsPermission(const GURL& origin,
const ContentSetting value) {
HostContentSettingsMap* host_content_settings_map =
HostContentSettingsMapFactory::GetForProfile(testing_profile_.get());
ContentSetting result = host_content_settings_map->GetContentSetting(
origin, GURL(), ContentSettingsType::NOTIFICATIONS);
EXPECT_EQ(value, result);
}
TestingProfile* GetTestingProfile() { return testing_profile_.get(); }
protected:
// This needs to be declared before |task_environment_|, so that it will be
// destroyed after |task_environment_|. This avoids tsan race errors with
// tasks running on other threads checking if features are enabled while
// |feature_list_| is being destroyed.
base::test::ScopedFeatureList feature_list_;
private:
base::ScopedTempDir profile_dir_;
content::BrowserTaskEnvironment task_environment_;
testing::ScopedCrowdDenyPreloadDataOverride testing_preload_data_;
std::unique_ptr<TestingProfile> testing_profile_;
scoped_refptr<CrowdDenyFakeSafeBrowsingDatabaseManager>
fake_database_manager_;
std::unique_ptr<safe_browsing::TestSafeBrowsingServiceFactory>
safe_browsing_factory_;
};
class PermissionRevocationRequestTest
: public PermissionRevocationRequestTestBase {
public:
PermissionRevocationRequestTest() {
feature_list_.InitAndEnableFeature(
features::kAbusiveNotificationPermissionRevocation);
}
~PermissionRevocationRequestTest() override = default;
};
TEST_F(PermissionRevocationRequestTest, OriginIsNotOnBlockingLists) {
const GURL origin_to_revoke = GURL("https://origin.com/");
SetPermission(origin_to_revoke, CONTENT_SETTING_ALLOW);
QueryAndExpectDecisionForUrl(origin_to_revoke,
Outcome::PERMISSION_NOT_REVOKED);
VerifyNotificationsPermission(origin_to_revoke, CONTENT_SETTING_ALLOW);
}
TEST_F(PermissionRevocationRequestTest, SafeBrowsingTest) {
const GURL origin_to_revoke = GURL("https://origin.com/");
SetPermission(origin_to_revoke, CONTENT_SETTING_ALLOW);
// The origin is not on any blocking lists. Notifications permission is not
// revoked.
QueryAndExpectDecisionForUrl(origin_to_revoke,
Outcome::PERMISSION_NOT_REVOKED);
AddToSafeBrowsingBlocklist(origin_to_revoke);
// Origin is not on CrowdDeny blocking lists.
QueryAndExpectDecisionForUrl(origin_to_revoke,
Outcome::PERMISSION_NOT_REVOKED);
VerifyNotificationsPermission(origin_to_revoke, CONTENT_SETTING_ALLOW);
EXPECT_FALSE(PermissionRevocationRequest::HasPreviouslyRevokedPermission(
GetTestingProfile(), origin_to_revoke));
AddToPreloadDataBlocklist(origin_to_revoke, SiteReputation::ABUSIVE_CONTENT,
/*has_warning=*/false);
QueryAndExpectDecisionForUrl(origin_to_revoke,
Outcome::PERMISSION_REVOKED_DUE_TO_ABUSE);
VerifyNotificationsPermission(origin_to_revoke, CONTENT_SETTING_ASK);
EXPECT_TRUE(PermissionRevocationRequest::HasPreviouslyRevokedPermission(
GetTestingProfile(), origin_to_revoke));
}
TEST_F(PermissionRevocationRequestTest, PreloadDataTest) {
const GURL abusive_content_origin_to_revoke =
GURL("https://abusive-content.com/");
const GURL abusive_prompts_origin_to_revoke =
GURL("https://abusive-prompts.com/");
const GURL unsolicited_prompts_origin =
GURL("https://unsolicited-prompts.com/");
const GURL acceptable_origin = GURL("https://acceptable-origin.com/");
const GURL unknown_origin = GURL("https://unknown-origin.com/");
auto origins = {abusive_content_origin_to_revoke,
abusive_prompts_origin_to_revoke, unsolicited_prompts_origin,
acceptable_origin, unknown_origin};
for (auto origin : origins)
SetPermission(origin, CONTENT_SETTING_ALLOW);
// The origins are not on any blocking lists.
for (auto origin : origins)
QueryAndExpectDecisionForUrl(origin, Outcome::PERMISSION_NOT_REVOKED);
AddToPreloadDataBlocklist(abusive_content_origin_to_revoke,
SiteReputation::ABUSIVE_CONTENT,
/*has_warning=*/false);
AddToPreloadDataBlocklist(abusive_prompts_origin_to_revoke,
SiteReputation::ABUSIVE_PROMPTS,
/*has_warning=*/false);
AddToPreloadDataBlocklist(unsolicited_prompts_origin,
SiteReputation::UNSOLICITED_PROMPTS,
/*has_warning=*/false);
AddToPreloadDataBlocklist(acceptable_origin, SiteReputation::ACCEPTABLE,
/*has_warning=*/false);
AddToPreloadDataBlocklist(unknown_origin, SiteReputation::UNKNOWN,
/*has_warning=*/false);
// The origins are on CrowdDeny blocking lists, but not on SafeBrowsing.
for (auto origin : origins)
QueryAndExpectDecisionForUrl(origin, Outcome::PERMISSION_NOT_REVOKED);
for (auto origin : origins)
AddToSafeBrowsingBlocklist(origin);
QueryAndExpectDecisionForUrl(abusive_content_origin_to_revoke,
Outcome::PERMISSION_REVOKED_DUE_TO_ABUSE);
QueryAndExpectDecisionForUrl(abusive_prompts_origin_to_revoke,
Outcome::PERMISSION_REVOKED_DUE_TO_ABUSE);
QueryAndExpectDecisionForUrl(unsolicited_prompts_origin,
Outcome::PERMISSION_NOT_REVOKED);
QueryAndExpectDecisionForUrl(acceptable_origin,
Outcome::PERMISSION_NOT_REVOKED);
QueryAndExpectDecisionForUrl(unknown_origin, Outcome::PERMISSION_NOT_REVOKED);
}
TEST_F(PermissionRevocationRequestTest, PreloadDataAsyncTest) {
auto* instance = CrowdDenyPreloadData::GetInstance();
// From this point on CrowdDenyPreloadData is not usable for origins
// verification.
instance->set_is_ready_to_use_for_testing(false);
const GURL abusive_content_origin_to_revoke =
GURL("https://abusive-content.com/");
base::MockOnceCallback<void(Outcome)> mock_callback_receiver_1;
auto permission_revocation_1 = std::make_unique<PermissionRevocationRequest>(
GetTestingProfile(), abusive_content_origin_to_revoke,
mock_callback_receiver_1.Get());
const GURL abusive_prompts_origin_to_revoke =
GURL("https://abusive-prompts.com/");
base::MockOnceCallback<void(Outcome)> mock_callback_receiver_2;
auto permission_revocation_2 = std::make_unique<PermissionRevocationRequest>(
GetTestingProfile(), abusive_prompts_origin_to_revoke,
mock_callback_receiver_2.Get());
base::RunLoop run_loop;
EXPECT_CALL(mock_callback_receiver_1,
Run(Outcome::PERMISSION_REVOKED_DUE_TO_ABUSE));
EXPECT_CALL(mock_callback_receiver_2,
Run(Outcome::PERMISSION_REVOKED_DUE_TO_ABUSE))
.WillOnce(testing::InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); }));
SetPermission(abusive_content_origin_to_revoke, CONTENT_SETTING_ALLOW);
SetPermission(abusive_prompts_origin_to_revoke, CONTENT_SETTING_ALLOW);
AddToSafeBrowsingBlocklist(abusive_content_origin_to_revoke);
AddToSafeBrowsingBlocklist(abusive_prompts_origin_to_revoke);
// At this point CrowdDenyPreloadData will be reactivated by a new data set.
AddToPreloadDataBlocklist(abusive_content_origin_to_revoke,
SiteReputation::ABUSIVE_CONTENT,
/*has_warning=*/false);
AddToPreloadDataBlocklist(abusive_prompts_origin_to_revoke,
SiteReputation::ABUSIVE_PROMPTS,
/*has_warning=*/false);
run_loop.Run();
}
TEST_F(PermissionRevocationRequestTest, PreloadDataAsyncHistogramTest) {
base::HistogramTester histograms;
// The Crowd Deny component is ready to use, there should be no
// DelayedPushNotification recording.
{
const GURL origin_1 = GURL("https://not-abusive-origin-1.com/");
SetPermission(origin_1, CONTENT_SETTING_ALLOW);
base::MockOnceCallback<void(Outcome)> mock_callback_receiver_1;
AddToPreloadDataBlocklist(origin_1, SiteReputation::ACCEPTABLE,
/*has_warning=*/false);
auto permission_revocation_1 =
std::make_unique<PermissionRevocationRequest>(
GetTestingProfile(), origin_1, mock_callback_receiver_1.Get());
EXPECT_CALL(mock_callback_receiver_1, Run(Outcome::PERMISSION_NOT_REVOKED));
base::RunLoop().RunUntilIdle();
histograms.ExpectTotalCount(
"Permissions.CrowdDeny.PreloadData.DelayedPushNotification", 0);
}
auto* crowd_deny = CrowdDenyPreloadData::GetInstance();
// From this point on CrowdDenyPreloadData is not usable for origin
// verification. DelayedPushNotification should be tracked for non-abusive
// origins.
crowd_deny->set_is_ready_to_use_for_testing(false);
const GURL origin_1 = GURL("https://not-abusive-origin-1.com/");
SetPermission(origin_1, CONTENT_SETTING_ALLOW);
base::MockOnceCallback<void(Outcome)> mock_callback_receiver_1;
auto permission_revocation_1 = std::make_unique<PermissionRevocationRequest>(
GetTestingProfile(), origin_1, mock_callback_receiver_1.Get());
EXPECT_CALL(mock_callback_receiver_1, Run(Outcome::PERMISSION_NOT_REVOKED));
const GURL origin_2 = GURL("https://not-abusive-origin-2.com/");
SetPermission(origin_2, CONTENT_SETTING_ALLOW);
base::MockOnceCallback<void(Outcome)> mock_callback_receiver_2;
auto permission_revocation_2 = std::make_unique<PermissionRevocationRequest>(
GetTestingProfile(), origin_2, mock_callback_receiver_2.Get());
EXPECT_CALL(mock_callback_receiver_2, Run(Outcome::PERMISSION_NOT_REVOKED));
const GURL abusive_origin = GURL("https://abusive-origin.com/");
SetPermission(abusive_origin, CONTENT_SETTING_ALLOW);
AddToSafeBrowsingBlocklist(abusive_origin);
base::MockOnceCallback<void(Outcome)> mock_callback_receiver_3;
auto permission_revocation_3 = std::make_unique<PermissionRevocationRequest>(
GetTestingProfile(), abusive_origin, mock_callback_receiver_3.Get());
EXPECT_CALL(mock_callback_receiver_3,
Run(Outcome::PERMISSION_REVOKED_DUE_TO_ABUSE));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(3, crowd_deny->get_pending_origins_queue_size_for_testing());
// Set Crowd Deny reputation only for abusive origin. Non-abusive origins will
// have default reputation.
AddToPreloadDataBlocklist(abusive_origin, SiteReputation::ABUSIVE_CONTENT,
/*has_warning=*/false);
base::RunLoop().RunUntilIdle();
histograms.ExpectTotalCount(
"Permissions.CrowdDeny.PreloadData.DelayedPushNotification", 2);
}
TEST_F(PermissionRevocationRequestTest, PreloadDataTestWithWarning) {
const GURL abusive_content_origin_to_revoke =
GURL("https://abusive-content.com/");
const GURL abusive_prompts_origin_to_revoke =
GURL("https://abusive-prompts.com/");
const GURL unsolicited_prompts_origin =
GURL("https://unsolicited-prompts.com/");
const GURL acceptable_origin = GURL("https://acceptable-origin.com/");
const GURL unknown_origin = GURL("https://unknown-origin.com/");
auto origins = {abusive_content_origin_to_revoke,
abusive_prompts_origin_to_revoke, unsolicited_prompts_origin,
acceptable_origin, unknown_origin};
for (auto origin : origins)
SetPermission(origin, CONTENT_SETTING_ALLOW);
// The origins are not on any blocking lists.
for (auto origin : origins)
QueryAndExpectDecisionForUrl(origin, Outcome::PERMISSION_NOT_REVOKED);
AddToPreloadDataBlocklist(abusive_content_origin_to_revoke,
SiteReputation::ABUSIVE_CONTENT,
/*has_warning=*/true);
AddToPreloadDataBlocklist(abusive_prompts_origin_to_revoke,
SiteReputation::ABUSIVE_PROMPTS,
/*has_warning=*/true);
AddToPreloadDataBlocklist(unsolicited_prompts_origin,
SiteReputation::UNSOLICITED_PROMPTS,
/*has_warning=*/true);
AddToPreloadDataBlocklist(acceptable_origin, SiteReputation::ACCEPTABLE,
/*has_warning=*/true);
AddToPreloadDataBlocklist(unknown_origin, SiteReputation::UNKNOWN,
/*has_warning=*/true);
// The origins are on CrowdDeny blocking lists, but not on SafeBrowsing.
for (auto origin : origins)
QueryAndExpectDecisionForUrl(origin, Outcome::PERMISSION_NOT_REVOKED);
for (auto origin : origins)
AddToSafeBrowsingBlocklist(origin);
// The warning is enabled for all origin, permission should not be revoked.
for (auto origin : origins)
QueryAndExpectDecisionForUrl(origin, Outcome::PERMISSION_NOT_REVOKED);
}
TEST_F(PermissionRevocationRequestTest, ExemptAbusiveOriginTest) {
const GURL origin_to_exempt = GURL("https://origin-allow.com/");
const GURL origin_to_revoke = GURL("https://origin.com/");
PermissionRevocationRequest::ExemptOriginFromFutureRevocations(
GetTestingProfile(), origin_to_exempt);
SetPermission(origin_to_exempt, CONTENT_SETTING_ALLOW);
AddToPreloadDataBlocklist(origin_to_exempt, SiteReputation::ABUSIVE_CONTENT,
/*has_warning=*/false);
AddToSafeBrowsingBlocklist(origin_to_exempt);
SetPermission(origin_to_revoke, CONTENT_SETTING_ALLOW);
AddToPreloadDataBlocklist(origin_to_revoke, SiteReputation::ABUSIVE_CONTENT,
/*has_warning=*/false);
AddToSafeBrowsingBlocklist(origin_to_revoke);
// The origin added to the exempt list will not be revoked.
QueryAndExpectDecisionForUrl(origin_to_exempt,
Outcome::PERMISSION_NOT_REVOKED);
VerifyNotificationsPermission(origin_to_revoke, CONTENT_SETTING_ALLOW);
QueryAndExpectDecisionForUrl(origin_to_revoke,
Outcome::PERMISSION_REVOKED_DUE_TO_ABUSE);
VerifyNotificationsPermission(origin_to_revoke, CONTENT_SETTING_ASK);
}
TEST_F(PermissionRevocationRequestTest, SafeBrowsingDisabledTest) {
const GURL origin_to_revoke = GURL("https://origin.com/");
SetPermission(origin_to_revoke, CONTENT_SETTING_ALLOW);
AddToSafeBrowsingBlocklist(origin_to_revoke);
AddToPreloadDataBlocklist(origin_to_revoke, SiteReputation::ABUSIVE_CONTENT,
/*has_warning=*/false);
QueryAndExpectDecisionForUrl(origin_to_revoke,
Outcome::PERMISSION_REVOKED_DUE_TO_ABUSE);
GetTestingProfile()->GetPrefs()->SetBoolean(prefs::kSafeBrowsingEnabled,
false);
// Permission should not be revoked because Safe Browsing is disabled.
const GURL origin_to_not_revoke = GURL("https://origin-not_revoked.com/");
SetPermission(origin_to_not_revoke, CONTENT_SETTING_ALLOW);
AddToSafeBrowsingBlocklist(origin_to_not_revoke);
AddToPreloadDataBlocklist(origin_to_not_revoke,
SiteReputation::ABUSIVE_CONTENT,
/*has_warning=*/false);
QueryAndExpectDecisionForUrl(origin_to_not_revoke,
Outcome::PERMISSION_NOT_REVOKED);
VerifyNotificationsPermission(origin_to_not_revoke, CONTENT_SETTING_ALLOW);
}
class PermissionRevocationRequestDisabledTest
: public PermissionRevocationRequestTestBase {
public:
PermissionRevocationRequestDisabledTest() {
feature_list_.InitAndDisableFeature(
features::kAbusiveNotificationPermissionRevocation);
}
~PermissionRevocationRequestDisabledTest() override = default;
};
TEST_F(PermissionRevocationRequestDisabledTest,
PermissionRevocationFeatureDisabled) {
const GURL origin_to_revoke = GURL("https://origin.com/");
SetPermission(origin_to_revoke, CONTENT_SETTING_ALLOW);
AddToPreloadDataBlocklist(origin_to_revoke, SiteReputation::ABUSIVE_CONTENT,
/*has_warning=*/false);
AddToSafeBrowsingBlocklist(origin_to_revoke);
QueryAndExpectDecisionForUrl(origin_to_revoke,
Outcome::PERMISSION_NOT_REVOKED);
VerifyNotificationsPermission(origin_to_revoke, CONTENT_SETTING_ALLOW);
}
class PermissionDisruptiveRevocationEnabledTest
: public PermissionRevocationRequestTestBase {
public:
PermissionDisruptiveRevocationEnabledTest() {
feature_list_.InitWithFeatures(
{},
{features::kAbusiveNotificationPermissionRevocation});
}
~PermissionDisruptiveRevocationEnabledTest() override = default;
};
TEST_F(PermissionDisruptiveRevocationEnabledTest,
PermissionDisruptiveRevocationEnabled) {
const GURL origin_to_revoke = GURL("https://origin.test/");
SetPermission(origin_to_revoke, CONTENT_SETTING_ALLOW);
// The origin is not on any blocking lists. Notifications permission is not
// revoked.
QueryAndExpectDecisionForUrl(origin_to_revoke,
Outcome::PERMISSION_NOT_REVOKED);
AddToSafeBrowsingBlocklist(origin_to_revoke);
// Origin is not on CrowdDeny blocking lists.
QueryAndExpectDecisionForUrl(origin_to_revoke,
Outcome::PERMISSION_NOT_REVOKED);
VerifyNotificationsPermission(origin_to_revoke, CONTENT_SETTING_ALLOW);
EXPECT_FALSE(PermissionRevocationRequest::HasPreviouslyRevokedPermission(
GetTestingProfile(), origin_to_revoke));
AddToPreloadDataBlocklist(origin_to_revoke,
SiteReputation::DISRUPTIVE_BEHAVIOR,
/*has_warning=*/false);
QueryAndExpectDecisionForUrl(
origin_to_revoke, Outcome::PERMISSION_REVOKED_DUE_TO_DISRUPTIVE_BEHAVIOR);
VerifyNotificationsPermission(origin_to_revoke, CONTENT_SETTING_ASK);
EXPECT_TRUE(PermissionRevocationRequest::HasPreviouslyRevokedPermission(
GetTestingProfile(), origin_to_revoke));
}
|