permission_decision_auto_blocker_unittest.cc 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  1. // Copyright 2016 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/permissions/permission_decision_auto_blocker.h"
  5. #include <map>
  6. #include <memory>
  7. #include "base/bind.h"
  8. #include "base/run_loop.h"
  9. #include "base/test/gtest_util.h"
  10. #include "base/test/metrics/histogram_tester.h"
  11. #include "base/test/scoped_feature_list.h"
  12. #include "base/test/simple_test_clock.h"
  13. #include "components/permissions/features.h"
  14. #include "components/permissions/permission_util.h"
  15. #include "components/permissions/test/test_permissions_client.h"
  16. #include "content/public/test/browser_task_environment.h"
  17. #include "content/public/test/test_browser_context.h"
  18. namespace permissions {
  19. namespace {
  20. bool FilterGoogle(const GURL& url) {
  21. return url == "https://www.google.com/";
  22. }
  23. bool FilterAll(const GURL& url) {
  24. return true;
  25. }
  26. } // namespace
  27. class PermissionDecisionAutoBlockerUnitTest : public testing::Test {
  28. protected:
  29. PermissionDecisionAutoBlockerUnitTest() {
  30. feature_list_.InitWithFeatures({features::kBlockPromptsIfDismissedOften,
  31. features::kBlockPromptsIfIgnoredOften},
  32. {});
  33. last_embargoed_status_ = false;
  34. autoblocker()->SetClockForTesting(&clock_);
  35. callback_was_run_ = false;
  36. }
  37. PermissionDecisionAutoBlocker* autoblocker() {
  38. return PermissionsClient::Get()->GetPermissionDecisionAutoBlocker(
  39. &browser_context_);
  40. }
  41. void SetLastEmbargoStatus(base::OnceClosure quit_closure, bool status) {
  42. callback_was_run_ = true;
  43. last_embargoed_status_ = status;
  44. if (quit_closure) {
  45. std::move(quit_closure).Run();
  46. }
  47. }
  48. bool last_embargoed_status() { return last_embargoed_status_; }
  49. bool callback_was_run() { return callback_was_run_; }
  50. base::SimpleTestClock* clock() { return &clock_; }
  51. private:
  52. content::BrowserTaskEnvironment task_environment_;
  53. base::SimpleTestClock clock_;
  54. base::test::ScopedFeatureList feature_list_;
  55. content::TestBrowserContext browser_context_;
  56. TestPermissionsClient permissions_client_;
  57. bool last_embargoed_status_;
  58. bool callback_was_run_;
  59. };
  60. // Check removing the the embargo for a single permission on a site works, and
  61. // that it doesn't interfere with other embargoed permissions or the same
  62. // permission embargoed on other sites.
  63. TEST_F(PermissionDecisionAutoBlockerUnitTest, RemoveEmbargoAndResetCounts) {
  64. GURL url1("https://www.google.com");
  65. GURL url2("https://www.example.com");
  66. // Record dismissals for location and notifications in |url1|.
  67. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  68. url1, ContentSettingsType::GEOLOCATION, false));
  69. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  70. url1, ContentSettingsType::GEOLOCATION, false));
  71. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  72. url1, ContentSettingsType::GEOLOCATION, false));
  73. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  74. url1, ContentSettingsType::NOTIFICATIONS, false));
  75. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  76. url1, ContentSettingsType::NOTIFICATIONS, false));
  77. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  78. url1, ContentSettingsType::NOTIFICATIONS, false));
  79. // Record dismissals for location in |url2|.
  80. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  81. url2, ContentSettingsType::GEOLOCATION, false));
  82. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  83. url2, ContentSettingsType::GEOLOCATION, false));
  84. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  85. url2, ContentSettingsType::GEOLOCATION, false));
  86. // Verify all dismissals recorded above resulted in embargo.
  87. absl::optional<PermissionResult> result =
  88. autoblocker()->GetEmbargoResult(url1, ContentSettingsType::GEOLOCATION);
  89. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  90. EXPECT_EQ(PermissionStatusSource::MULTIPLE_DISMISSALS, result->source);
  91. result =
  92. autoblocker()->GetEmbargoResult(url1, ContentSettingsType::NOTIFICATIONS);
  93. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  94. EXPECT_EQ(PermissionStatusSource::MULTIPLE_DISMISSALS, result->source);
  95. result =
  96. autoblocker()->GetEmbargoResult(url2, ContentSettingsType::GEOLOCATION);
  97. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  98. EXPECT_EQ(PermissionStatusSource::MULTIPLE_DISMISSALS, result->source);
  99. // Remove the embargo on notifications. Verify it is no longer under embargo,
  100. // but location still is.
  101. autoblocker()->RemoveEmbargoAndResetCounts(
  102. url1, ContentSettingsType::NOTIFICATIONS);
  103. result =
  104. autoblocker()->GetEmbargoResult(url1, ContentSettingsType::GEOLOCATION);
  105. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  106. EXPECT_EQ(PermissionStatusSource::MULTIPLE_DISMISSALS, result->source);
  107. result =
  108. autoblocker()->GetEmbargoResult(url1, ContentSettingsType::NOTIFICATIONS);
  109. // If not under embargo, GetEmbargoResult() returns absl::nullopt.
  110. EXPECT_FALSE(result.has_value());
  111. // Verify |url2|'s embargo is still intact as well.
  112. result =
  113. autoblocker()->GetEmbargoResult(url2, ContentSettingsType::GEOLOCATION);
  114. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  115. EXPECT_EQ(PermissionStatusSource::MULTIPLE_DISMISSALS, result->source);
  116. }
  117. // Test it does not take one more dismissal to re-trigger embargo after
  118. // removing the embargo status for a site.
  119. TEST_F(PermissionDecisionAutoBlockerUnitTest,
  120. DismissAfterRemovingEmbargoByURL) {
  121. GURL url("https://www.example.com");
  122. // Record dismissals for location.
  123. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  124. url, ContentSettingsType::GEOLOCATION, false));
  125. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  126. url, ContentSettingsType::GEOLOCATION, false));
  127. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  128. url, ContentSettingsType::GEOLOCATION, false));
  129. // Verify location is under embargo.
  130. absl::optional<PermissionResult> result =
  131. autoblocker()->GetEmbargoResult(url, ContentSettingsType::GEOLOCATION);
  132. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  133. EXPECT_EQ(PermissionStatusSource::MULTIPLE_DISMISSALS, result->source);
  134. // Remove embargo and verify this is true.
  135. autoblocker()->RemoveEmbargoAndResetCounts(url,
  136. ContentSettingsType::GEOLOCATION);
  137. result =
  138. autoblocker()->GetEmbargoResult(url, ContentSettingsType::GEOLOCATION);
  139. EXPECT_FALSE(result.has_value());
  140. // Record another dismissal and verify location is not under embargo again.
  141. autoblocker()->RecordDismissAndEmbargo(url, ContentSettingsType::GEOLOCATION,
  142. false);
  143. result =
  144. autoblocker()->GetEmbargoResult(url, ContentSettingsType::GEOLOCATION);
  145. EXPECT_FALSE(result.has_value());
  146. }
  147. TEST_F(PermissionDecisionAutoBlockerUnitTest,
  148. NonembargoedOriginRemoveEmbargoCounts) {
  149. GURL gurl_to_embargo("https://www.google.com");
  150. // Make sure that an origin's Dismiss count is 0.
  151. EXPECT_EQ(0, autoblocker()->GetDismissCount(
  152. gurl_to_embargo, ContentSettingsType::GEOLOCATION));
  153. // Dismiss the origin a few times but do not add under embargo.
  154. autoblocker()->RecordDismissAndEmbargo(
  155. gurl_to_embargo, ContentSettingsType::GEOLOCATION, false);
  156. autoblocker()->RecordDismissAndEmbargo(
  157. gurl_to_embargo, ContentSettingsType::GEOLOCATION, false);
  158. EXPECT_EQ(2, autoblocker()->GetDismissCount(
  159. gurl_to_embargo, ContentSettingsType::GEOLOCATION));
  160. autoblocker()->RemoveEmbargoAndResetCounts(gurl_to_embargo,
  161. ContentSettingsType::GEOLOCATION);
  162. EXPECT_EQ(0, autoblocker()->GetDismissCount(
  163. gurl_to_embargo, ContentSettingsType::GEOLOCATION));
  164. autoblocker()->RecordIgnoreAndEmbargo(gurl_to_embargo,
  165. ContentSettingsType::MIDI_SYSEX, false);
  166. autoblocker()->RecordIgnoreAndEmbargo(gurl_to_embargo,
  167. ContentSettingsType::MIDI_SYSEX, false);
  168. EXPECT_EQ(2, autoblocker()->GetIgnoreCount(gurl_to_embargo,
  169. ContentSettingsType::MIDI_SYSEX));
  170. autoblocker()->RemoveEmbargoAndResetCounts(gurl_to_embargo,
  171. ContentSettingsType::MIDI_SYSEX);
  172. EXPECT_EQ(0, autoblocker()->GetIgnoreCount(gurl_to_embargo,
  173. ContentSettingsType::MIDI_SYSEX));
  174. }
  175. TEST_F(PermissionDecisionAutoBlockerUnitTest, RemoveEmbargoCounts) {
  176. GURL gurl_to_embargo("https://www.google.com");
  177. // Add an origin under embargo for 2 dismissed and 1 ignored
  178. // ContentSettingsType.
  179. autoblocker()->RecordDismissAndEmbargo(
  180. gurl_to_embargo, ContentSettingsType::GEOLOCATION, false);
  181. autoblocker()->RecordDismissAndEmbargo(
  182. gurl_to_embargo, ContentSettingsType::GEOLOCATION, false);
  183. autoblocker()->RecordDismissAndEmbargo(
  184. gurl_to_embargo, ContentSettingsType::GEOLOCATION, false);
  185. EXPECT_EQ(3, autoblocker()->GetDismissCount(
  186. gurl_to_embargo, ContentSettingsType::GEOLOCATION));
  187. autoblocker()->RecordDismissAndEmbargo(
  188. gurl_to_embargo, ContentSettingsType::NOTIFICATIONS, false);
  189. autoblocker()->RecordDismissAndEmbargo(
  190. gurl_to_embargo, ContentSettingsType::NOTIFICATIONS, false);
  191. autoblocker()->RecordDismissAndEmbargo(
  192. gurl_to_embargo, ContentSettingsType::NOTIFICATIONS, false);
  193. EXPECT_EQ(3, autoblocker()->GetDismissCount(
  194. gurl_to_embargo, ContentSettingsType::NOTIFICATIONS));
  195. autoblocker()->RecordIgnoreAndEmbargo(gurl_to_embargo,
  196. ContentSettingsType::MIDI_SYSEX, false);
  197. autoblocker()->RecordIgnoreAndEmbargo(gurl_to_embargo,
  198. ContentSettingsType::MIDI_SYSEX, false);
  199. autoblocker()->RecordIgnoreAndEmbargo(gurl_to_embargo,
  200. ContentSettingsType::MIDI_SYSEX, false);
  201. autoblocker()->RecordIgnoreAndEmbargo(gurl_to_embargo,
  202. ContentSettingsType::MIDI_SYSEX, false);
  203. EXPECT_EQ(4, autoblocker()->GetIgnoreCount(gurl_to_embargo,
  204. ContentSettingsType::MIDI_SYSEX));
  205. autoblocker()->RemoveEmbargoAndResetCounts(gurl_to_embargo,
  206. ContentSettingsType::GEOLOCATION);
  207. // GEOLOCATION has been cleared, a dismiss count should be 0.
  208. EXPECT_EQ(0, autoblocker()->GetDismissCount(
  209. gurl_to_embargo, ContentSettingsType::GEOLOCATION));
  210. // GEOLOCATION has been cleared, but other counts should be
  211. // preservet.
  212. EXPECT_EQ(3, autoblocker()->GetDismissCount(
  213. gurl_to_embargo, ContentSettingsType::NOTIFICATIONS));
  214. EXPECT_EQ(4, autoblocker()->GetIgnoreCount(gurl_to_embargo,
  215. ContentSettingsType::MIDI_SYSEX));
  216. }
  217. TEST_F(PermissionDecisionAutoBlockerUnitTest, RemoveEmbargoAndResetCounts_All) {
  218. GURL url1("https://www.google.com");
  219. GURL url2("https://www.example.com");
  220. // Record some dismissals.
  221. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  222. url1, ContentSettingsType::GEOLOCATION, false));
  223. EXPECT_EQ(1, autoblocker()->GetDismissCount(
  224. url1, ContentSettingsType::GEOLOCATION));
  225. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  226. url1, ContentSettingsType::GEOLOCATION, false));
  227. EXPECT_EQ(2, autoblocker()->GetDismissCount(
  228. url1, ContentSettingsType::GEOLOCATION));
  229. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  230. url1, ContentSettingsType::GEOLOCATION, false));
  231. EXPECT_EQ(3, autoblocker()->GetDismissCount(
  232. url1, ContentSettingsType::GEOLOCATION));
  233. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  234. url2, ContentSettingsType::GEOLOCATION, false));
  235. EXPECT_EQ(1, autoblocker()->GetDismissCount(
  236. url2, ContentSettingsType::GEOLOCATION));
  237. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  238. url1, ContentSettingsType::NOTIFICATIONS, false));
  239. EXPECT_EQ(1, autoblocker()->GetDismissCount(
  240. url1, ContentSettingsType::NOTIFICATIONS));
  241. // Record some ignores.
  242. EXPECT_FALSE(autoblocker()->RecordIgnoreAndEmbargo(
  243. url1, ContentSettingsType::MIDI_SYSEX, false));
  244. EXPECT_EQ(
  245. 1, autoblocker()->GetIgnoreCount(url1, ContentSettingsType::MIDI_SYSEX));
  246. EXPECT_FALSE(autoblocker()->RecordIgnoreAndEmbargo(
  247. url1, ContentSettingsType::DURABLE_STORAGE, false));
  248. EXPECT_EQ(1, autoblocker()->GetIgnoreCount(
  249. url1, ContentSettingsType::DURABLE_STORAGE));
  250. EXPECT_FALSE(autoblocker()->RecordIgnoreAndEmbargo(
  251. url2, ContentSettingsType::GEOLOCATION, false));
  252. EXPECT_FALSE(autoblocker()->RecordIgnoreAndEmbargo(
  253. url2, ContentSettingsType::GEOLOCATION, false));
  254. EXPECT_EQ(
  255. 2, autoblocker()->GetIgnoreCount(url2, ContentSettingsType::GEOLOCATION));
  256. autoblocker()->RemoveEmbargoAndResetCounts(
  257. base::BindRepeating(&FilterGoogle));
  258. // Expect that url1's actions are gone, but url2's remain.
  259. EXPECT_EQ(0, autoblocker()->GetDismissCount(
  260. url1, ContentSettingsType::GEOLOCATION));
  261. EXPECT_EQ(0, autoblocker()->GetDismissCount(
  262. url1, ContentSettingsType::NOTIFICATIONS));
  263. EXPECT_EQ(
  264. 0, autoblocker()->GetIgnoreCount(url1, ContentSettingsType::MIDI_SYSEX));
  265. EXPECT_EQ(0, autoblocker()->GetIgnoreCount(
  266. url1, ContentSettingsType::DURABLE_STORAGE));
  267. EXPECT_EQ(1, autoblocker()->GetDismissCount(
  268. url2, ContentSettingsType::GEOLOCATION));
  269. EXPECT_EQ(
  270. 2, autoblocker()->GetIgnoreCount(url2, ContentSettingsType::GEOLOCATION));
  271. // Add some more actions.
  272. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  273. url1, ContentSettingsType::GEOLOCATION, false));
  274. EXPECT_EQ(1, autoblocker()->GetDismissCount(
  275. url1, ContentSettingsType::GEOLOCATION));
  276. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  277. url1, ContentSettingsType::NOTIFICATIONS, false));
  278. EXPECT_EQ(1, autoblocker()->GetDismissCount(
  279. url1, ContentSettingsType::NOTIFICATIONS));
  280. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  281. url2, ContentSettingsType::GEOLOCATION, false));
  282. EXPECT_EQ(2, autoblocker()->GetDismissCount(
  283. url2, ContentSettingsType::GEOLOCATION));
  284. EXPECT_FALSE(autoblocker()->RecordIgnoreAndEmbargo(
  285. url1, ContentSettingsType::GEOLOCATION, false));
  286. EXPECT_EQ(
  287. 1, autoblocker()->GetIgnoreCount(url1, ContentSettingsType::GEOLOCATION));
  288. EXPECT_FALSE(autoblocker()->RecordIgnoreAndEmbargo(
  289. url1, ContentSettingsType::NOTIFICATIONS, false));
  290. EXPECT_EQ(1, autoblocker()->GetIgnoreCount(
  291. url1, ContentSettingsType::NOTIFICATIONS));
  292. EXPECT_FALSE(autoblocker()->RecordIgnoreAndEmbargo(
  293. url1, ContentSettingsType::DURABLE_STORAGE, false));
  294. EXPECT_EQ(1, autoblocker()->GetIgnoreCount(
  295. url1, ContentSettingsType::DURABLE_STORAGE));
  296. EXPECT_FALSE(autoblocker()->RecordIgnoreAndEmbargo(
  297. url2, ContentSettingsType::MIDI_SYSEX, false));
  298. EXPECT_EQ(
  299. 1, autoblocker()->GetIgnoreCount(url2, ContentSettingsType::MIDI_SYSEX));
  300. // Remove everything and expect that it's all gone.
  301. autoblocker()->RemoveEmbargoAndResetCounts(base::BindRepeating(&FilterAll));
  302. EXPECT_EQ(0, autoblocker()->GetDismissCount(
  303. url1, ContentSettingsType::GEOLOCATION));
  304. EXPECT_EQ(0, autoblocker()->GetDismissCount(
  305. url1, ContentSettingsType::NOTIFICATIONS));
  306. EXPECT_EQ(0, autoblocker()->GetDismissCount(
  307. url2, ContentSettingsType::GEOLOCATION));
  308. EXPECT_EQ(
  309. 0, autoblocker()->GetIgnoreCount(url1, ContentSettingsType::GEOLOCATION));
  310. EXPECT_EQ(0, autoblocker()->GetIgnoreCount(
  311. url1, ContentSettingsType::NOTIFICATIONS));
  312. EXPECT_EQ(
  313. 0, autoblocker()->GetIgnoreCount(url2, ContentSettingsType::GEOLOCATION));
  314. EXPECT_EQ(0, autoblocker()->GetIgnoreCount(
  315. url2, ContentSettingsType::DURABLE_STORAGE));
  316. EXPECT_EQ(
  317. 0, autoblocker()->GetIgnoreCount(url2, ContentSettingsType::MIDI_SYSEX));
  318. }
  319. // Check that GetEmbargoedOrigins only returns origins where embargo is the
  320. // effective permission enforcement mechanism.
  321. TEST_F(PermissionDecisionAutoBlockerUnitTest, CheckEmbargoedOrigins) {
  322. GURL url1("https://www.google.com");
  323. GURL url2("https://www.google.com:8443");
  324. std::vector<ContentSettingsType> content_types = {
  325. ContentSettingsType::GEOLOCATION, ContentSettingsType::NOTIFICATIONS};
  326. std::set<GURL> origins;
  327. clock()->SetNow(base::Time::Now());
  328. EXPECT_EQ(0UL, autoblocker()->GetEmbargoedOrigins(content_types).size());
  329. // Place both origins under embargo and verify.
  330. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  331. url1, ContentSettingsType::GEOLOCATION, false));
  332. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  333. url1, ContentSettingsType::GEOLOCATION, false));
  334. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  335. url1, ContentSettingsType::GEOLOCATION, false));
  336. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  337. url2, ContentSettingsType::NOTIFICATIONS, false));
  338. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  339. url2, ContentSettingsType::NOTIFICATIONS, false));
  340. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  341. url2, ContentSettingsType::NOTIFICATIONS, false));
  342. origins = autoblocker()->GetEmbargoedOrigins(content_types);
  343. EXPECT_EQ(2UL, origins.size());
  344. EXPECT_EQ(1UL, origins.count(url1));
  345. EXPECT_EQ(1UL, origins.count(url2));
  346. // Check no leakage between content types
  347. origins =
  348. autoblocker()->GetEmbargoedOrigins(ContentSettingsType::GEOLOCATION);
  349. EXPECT_EQ(1UL, origins.count(url1));
  350. origins =
  351. autoblocker()->GetEmbargoedOrigins(ContentSettingsType::NOTIFICATIONS);
  352. EXPECT_EQ(1UL, origins.count(url2));
  353. // Remove an embargo and confirm it's removed from origins
  354. autoblocker()->RemoveEmbargoAndResetCounts(url1,
  355. ContentSettingsType::GEOLOCATION);
  356. origins = autoblocker()->GetEmbargoedOrigins(content_types);
  357. EXPECT_EQ(1UL, origins.size());
  358. EXPECT_EQ(1UL, origins.count(url2));
  359. // Expire the remaining embargo and confirm the origin is removed
  360. clock()->Advance(base::Days(8));
  361. origins = autoblocker()->GetEmbargoedOrigins(content_types);
  362. EXPECT_EQ(0UL, origins.size());
  363. }
  364. // Check that GetEmbargoResult returns the correct value when the embargo is set
  365. // and expires.
  366. TEST_F(PermissionDecisionAutoBlockerUnitTest, CheckEmbargoStatus) {
  367. GURL url("https://www.google.com");
  368. clock()->SetNow(base::Time::Now());
  369. // Check the default state.
  370. absl::optional<PermissionResult> result =
  371. autoblocker()->GetEmbargoResult(url, ContentSettingsType::GEOLOCATION);
  372. EXPECT_FALSE(result.has_value());
  373. // Place under embargo and verify.
  374. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  375. url, ContentSettingsType::GEOLOCATION, false));
  376. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  377. url, ContentSettingsType::GEOLOCATION, false));
  378. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  379. url, ContentSettingsType::GEOLOCATION, false));
  380. result =
  381. autoblocker()->GetEmbargoResult(url, ContentSettingsType::GEOLOCATION);
  382. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  383. EXPECT_EQ(PermissionStatusSource::MULTIPLE_DISMISSALS, result->source);
  384. // Check that the origin is not under embargo for a different permission.
  385. result =
  386. autoblocker()->GetEmbargoResult(url, ContentSettingsType::NOTIFICATIONS);
  387. EXPECT_FALSE(result.has_value());
  388. // Confirm embargo status during the embargo period.
  389. clock()->Advance(base::Days(5));
  390. result =
  391. autoblocker()->GetEmbargoResult(url, ContentSettingsType::GEOLOCATION);
  392. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  393. EXPECT_EQ(PermissionStatusSource::MULTIPLE_DISMISSALS, result->source);
  394. // Check embargo is lifted on expiry day. A small offset after the exact
  395. // embargo expiration date has been added to account for any precision errors
  396. // when removing the date stored as a double from the permission dictionary.
  397. clock()->Advance(base::Hours(3 * 24 + 1));
  398. result =
  399. autoblocker()->GetEmbargoResult(url, ContentSettingsType::GEOLOCATION);
  400. EXPECT_FALSE(result.has_value());
  401. // Check embargo is lifted well after the expiry day.
  402. clock()->Advance(base::Days(1));
  403. result =
  404. autoblocker()->GetEmbargoResult(url, ContentSettingsType::GEOLOCATION);
  405. EXPECT_FALSE(result.has_value());
  406. // Place under embargo again and verify the embargo status.
  407. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  408. url, ContentSettingsType::NOTIFICATIONS, false));
  409. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  410. url, ContentSettingsType::NOTIFICATIONS, false));
  411. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  412. url, ContentSettingsType::NOTIFICATIONS, false));
  413. clock()->Advance(base::Days(1));
  414. result =
  415. autoblocker()->GetEmbargoResult(url, ContentSettingsType::NOTIFICATIONS);
  416. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  417. EXPECT_EQ(PermissionStatusSource::MULTIPLE_DISMISSALS, result->source);
  418. result =
  419. autoblocker()->GetEmbargoResult(url, ContentSettingsType::GEOLOCATION);
  420. EXPECT_FALSE(result.has_value());
  421. }
  422. // Check that GetEmbargoStartTime returns the correct time for embargoes whether
  423. // they are nonexistent, expired or active.
  424. TEST_F(PermissionDecisionAutoBlockerUnitTest, CheckEmbargoStartTime) {
  425. GURL url("https://www.google.com");
  426. // The time recorded for embargoes will be stored as a double, which will
  427. // cause aliasing to a limited set of base::Time values upon retrieval. We
  428. // thus pick a base::Time for our test time that is part of this set via
  429. // aliasing the current time by passing it through a double. This allows us
  430. // to directly compare the test time and times retrieved from storage.
  431. base::Time test_time = base::Time::FromDeltaSinceWindowsEpoch(
  432. base::Microseconds(static_cast<double>(
  433. base::Time::Now().ToDeltaSinceWindowsEpoch().InMicroseconds())));
  434. clock()->SetNow(test_time);
  435. // Check the default non embargod state.
  436. base::Time embargo_start_time =
  437. autoblocker()->GetEmbargoStartTime(url, ContentSettingsType::GEOLOCATION);
  438. EXPECT_EQ(base::Time(), embargo_start_time);
  439. // Ensure that dismissing less than the required number for an embargo
  440. // does not record an embargo start time.
  441. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  442. url, ContentSettingsType::GEOLOCATION, false));
  443. embargo_start_time =
  444. autoblocker()->GetEmbargoStartTime(url, ContentSettingsType::GEOLOCATION);
  445. EXPECT_EQ(base::Time(), embargo_start_time);
  446. // Place site under geolocation dismissal embargo.
  447. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  448. url, ContentSettingsType::GEOLOCATION, false));
  449. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  450. url, ContentSettingsType::GEOLOCATION, false));
  451. // Confirm embargo is recorded as starting at the correct time.
  452. embargo_start_time =
  453. autoblocker()->GetEmbargoStartTime(url, ContentSettingsType::GEOLOCATION);
  454. EXPECT_EQ(test_time, embargo_start_time);
  455. // Ensure moving clock while within embargo period does not affect embargo
  456. // start time.
  457. clock()->Advance(base::Days(5));
  458. embargo_start_time =
  459. autoblocker()->GetEmbargoStartTime(url, ContentSettingsType::GEOLOCATION);
  460. EXPECT_EQ(test_time, embargo_start_time);
  461. // Move clock beyond embaro (plus a small offset for potential precision
  462. // errors) and confirm start time is unaffected but embargo is suspended.
  463. clock()->Advance(base::Hours(3 * 24 + 1));
  464. embargo_start_time =
  465. autoblocker()->GetEmbargoStartTime(url, ContentSettingsType::GEOLOCATION);
  466. EXPECT_EQ(test_time, embargo_start_time);
  467. absl::optional<PermissionResult> result =
  468. autoblocker()->GetEmbargoResult(url, ContentSettingsType::GEOLOCATION);
  469. EXPECT_FALSE(result.has_value());
  470. // Advance time, reinstate embargo and confirm that time is updated.
  471. test_time += base::Days(9);
  472. test_time = base::Time::FromDeltaSinceWindowsEpoch(
  473. base::Microseconds(static_cast<double>(
  474. test_time.ToDeltaSinceWindowsEpoch().InMicroseconds())));
  475. clock()->SetNow(test_time);
  476. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  477. url, ContentSettingsType::GEOLOCATION, false));
  478. embargo_start_time =
  479. autoblocker()->GetEmbargoStartTime(url, ContentSettingsType::GEOLOCATION);
  480. EXPECT_EQ(test_time, embargo_start_time);
  481. // Advance time to expire dismiss embargo and create new embargo for ignoring.
  482. test_time += base::Days(7);
  483. test_time = base::Time::FromDeltaSinceWindowsEpoch(
  484. base::Microseconds(static_cast<double>(
  485. test_time.ToDeltaSinceWindowsEpoch().InMicroseconds())));
  486. clock()->SetNow(test_time);
  487. EXPECT_FALSE(autoblocker()->RecordIgnoreAndEmbargo(
  488. url, ContentSettingsType::GEOLOCATION, false));
  489. EXPECT_FALSE(autoblocker()->RecordIgnoreAndEmbargo(
  490. url, ContentSettingsType::GEOLOCATION, false));
  491. EXPECT_FALSE(autoblocker()->RecordIgnoreAndEmbargo(
  492. url, ContentSettingsType::GEOLOCATION, false));
  493. EXPECT_TRUE(autoblocker()->RecordIgnoreAndEmbargo(
  494. url, ContentSettingsType::GEOLOCATION, false));
  495. // Confirm the most recent embargo is updated to match new ignore embargo.
  496. embargo_start_time =
  497. autoblocker()->GetEmbargoStartTime(url, ContentSettingsType::GEOLOCATION);
  498. EXPECT_EQ(test_time, embargo_start_time);
  499. // Advance time, reinstate the dismiss embargo via a single action, and
  500. // confirm that time is updated.
  501. test_time += base::Days(1);
  502. test_time = base::Time::FromDeltaSinceWindowsEpoch(
  503. base::Microseconds(static_cast<double>(
  504. test_time.ToDeltaSinceWindowsEpoch().InMicroseconds())));
  505. clock()->SetNow(test_time);
  506. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  507. url, ContentSettingsType::GEOLOCATION, false));
  508. embargo_start_time =
  509. autoblocker()->GetEmbargoStartTime(url, ContentSettingsType::GEOLOCATION);
  510. EXPECT_EQ(test_time, embargo_start_time);
  511. // Remove records of dismiss and ignore embargoes and confirm start time
  512. // reverts to default.
  513. autoblocker()->RemoveEmbargoAndResetCounts(
  514. base::BindRepeating(&FilterGoogle));
  515. embargo_start_time =
  516. autoblocker()->GetEmbargoStartTime(url, ContentSettingsType::GEOLOCATION);
  517. EXPECT_EQ(base::Time(), embargo_start_time);
  518. }
  519. // Tests the alternating pattern of the block on multiple dismiss behaviour. On
  520. // N dismissals, the origin to be embargoed for the requested permission and
  521. // automatically blocked. Each time the embargo is lifted, the site gets another
  522. // chance to request the permission, but if it is again dismissed it is placed
  523. // under embargo again and its permission requests blocked.
  524. TEST_F(PermissionDecisionAutoBlockerUnitTest, TestDismissEmbargoBackoff) {
  525. GURL url("https://www.google.com");
  526. clock()->SetNow(base::Time::Now());
  527. base::HistogramTester histograms;
  528. // Record some dismisses.
  529. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  530. url, ContentSettingsType::GEOLOCATION, false));
  531. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  532. url, ContentSettingsType::GEOLOCATION, false));
  533. // A request with < 3 prior dismisses should not be automatically blocked.
  534. absl::optional<PermissionResult> result =
  535. autoblocker()->GetEmbargoResult(url, ContentSettingsType::GEOLOCATION);
  536. EXPECT_FALSE(result.has_value());
  537. // After the 3rd dismiss subsequent permission requests should be autoblocked.
  538. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  539. url, ContentSettingsType::GEOLOCATION, false));
  540. result =
  541. autoblocker()->GetEmbargoResult(url, ContentSettingsType::GEOLOCATION);
  542. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  543. EXPECT_EQ(PermissionStatusSource::MULTIPLE_DISMISSALS, result->source);
  544. // Accelerate time forward, check that the embargo status is lifted and the
  545. // request won't be automatically blocked.
  546. clock()->Advance(base::Days(8));
  547. result =
  548. autoblocker()->GetEmbargoResult(url, ContentSettingsType::GEOLOCATION);
  549. EXPECT_FALSE(result.has_value());
  550. // Record another dismiss, subsequent requests should be autoblocked again.
  551. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  552. url, ContentSettingsType::GEOLOCATION, false));
  553. result =
  554. autoblocker()->GetEmbargoResult(url, ContentSettingsType::GEOLOCATION);
  555. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  556. EXPECT_EQ(PermissionStatusSource::MULTIPLE_DISMISSALS, result->source);
  557. // Accelerate time again, check embargo is lifted and another permission
  558. // request is let through.
  559. clock()->Advance(base::Days(8));
  560. result =
  561. autoblocker()->GetEmbargoResult(url, ContentSettingsType::GEOLOCATION);
  562. EXPECT_FALSE(result.has_value());
  563. // Record another dismiss, subsequent requests should be autoblocked again.
  564. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  565. url, ContentSettingsType::GEOLOCATION, false));
  566. result =
  567. autoblocker()->GetEmbargoResult(url, ContentSettingsType::GEOLOCATION);
  568. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  569. EXPECT_EQ(PermissionStatusSource::MULTIPLE_DISMISSALS, result->source);
  570. }
  571. // Tests the alternating pattern of the block on multiple ignores behaviour.
  572. TEST_F(PermissionDecisionAutoBlockerUnitTest, TestIgnoreEmbargoBackoff) {
  573. GURL url("https://www.google.com");
  574. clock()->SetNow(base::Time::Now());
  575. base::HistogramTester histograms;
  576. // Record some ignores.
  577. EXPECT_FALSE(autoblocker()->RecordIgnoreAndEmbargo(
  578. url, ContentSettingsType::MIDI_SYSEX, false));
  579. EXPECT_FALSE(autoblocker()->RecordIgnoreAndEmbargo(
  580. url, ContentSettingsType::MIDI_SYSEX, false));
  581. // A request with < 4 prior ignores should not be automatically blocked.
  582. absl::optional<PermissionResult> result =
  583. autoblocker()->GetEmbargoResult(url, ContentSettingsType::MIDI_SYSEX);
  584. EXPECT_FALSE(result.has_value());
  585. // After the 4th ignore subsequent permission requests should be autoblocked.
  586. EXPECT_FALSE(autoblocker()->RecordIgnoreAndEmbargo(
  587. url, ContentSettingsType::MIDI_SYSEX, false));
  588. EXPECT_TRUE(autoblocker()->RecordIgnoreAndEmbargo(
  589. url, ContentSettingsType::MIDI_SYSEX, false));
  590. result =
  591. autoblocker()->GetEmbargoResult(url, ContentSettingsType::MIDI_SYSEX);
  592. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  593. EXPECT_EQ(PermissionStatusSource::MULTIPLE_IGNORES, result->source);
  594. // Accelerate time forward, check that the embargo status is lifted and the
  595. // request won't be automatically blocked.
  596. clock()->Advance(base::Days(8));
  597. result =
  598. autoblocker()->GetEmbargoResult(url, ContentSettingsType::MIDI_SYSEX);
  599. EXPECT_FALSE(result.has_value());
  600. // Record another dismiss, subsequent requests should be autoblocked again.
  601. EXPECT_TRUE(autoblocker()->RecordIgnoreAndEmbargo(
  602. url, ContentSettingsType::MIDI_SYSEX, false));
  603. result =
  604. autoblocker()->GetEmbargoResult(url, ContentSettingsType::MIDI_SYSEX);
  605. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  606. EXPECT_EQ(PermissionStatusSource::MULTIPLE_IGNORES, result->source);
  607. // Accelerate time again, check embargo is lifted and another permission
  608. // request is let through.
  609. clock()->Advance(base::Days(8));
  610. result =
  611. autoblocker()->GetEmbargoResult(url, ContentSettingsType::MIDI_SYSEX);
  612. EXPECT_FALSE(result.has_value());
  613. // Record another dismiss, subsequent requests should be autoblocked again.
  614. EXPECT_TRUE(autoblocker()->RecordIgnoreAndEmbargo(
  615. url, ContentSettingsType::MIDI_SYSEX, false));
  616. result =
  617. autoblocker()->GetEmbargoResult(url, ContentSettingsType::MIDI_SYSEX);
  618. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  619. EXPECT_EQ(PermissionStatusSource::MULTIPLE_IGNORES, result->source);
  620. }
  621. // Test that quiet ui embargo has a different threshold for ignores.
  622. TEST_F(PermissionDecisionAutoBlockerUnitTest, TestIgnoreEmbargoUsingQuietUi) {
  623. GURL url("https://www.google.com");
  624. clock()->SetNow(base::Time::Now());
  625. // Check the default state.
  626. absl::optional<PermissionResult> result =
  627. autoblocker()->GetEmbargoResult(url, ContentSettingsType::NOTIFICATIONS);
  628. EXPECT_FALSE(result.has_value());
  629. // One quiet ui ignore is not enough to trigger embargo.
  630. EXPECT_FALSE(autoblocker()->RecordIgnoreAndEmbargo(
  631. url, ContentSettingsType::NOTIFICATIONS, true));
  632. result =
  633. autoblocker()->GetEmbargoResult(url, ContentSettingsType::NOTIFICATIONS);
  634. EXPECT_FALSE(result.has_value());
  635. // Loud ui ignores are counted separately.
  636. EXPECT_FALSE(autoblocker()->RecordIgnoreAndEmbargo(
  637. url, ContentSettingsType::NOTIFICATIONS, false));
  638. result =
  639. autoblocker()->GetEmbargoResult(url, ContentSettingsType::NOTIFICATIONS);
  640. EXPECT_FALSE(result.has_value());
  641. // The second quiet ui ignore puts the url under embargo.
  642. EXPECT_TRUE(autoblocker()->RecordIgnoreAndEmbargo(
  643. url, ContentSettingsType::NOTIFICATIONS, true));
  644. result =
  645. autoblocker()->GetEmbargoResult(url, ContentSettingsType::NOTIFICATIONS);
  646. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  647. EXPECT_EQ(PermissionStatusSource::MULTIPLE_IGNORES, result->source);
  648. }
  649. // Test that quiet ui embargo has a different threshold for dismisses.
  650. TEST_F(PermissionDecisionAutoBlockerUnitTest, TestDismissEmbargoUsingQuietUi) {
  651. GURL url("https://www.google.com");
  652. clock()->SetNow(base::Time::Now());
  653. // Check the default state.
  654. absl::optional<PermissionResult> result =
  655. autoblocker()->GetEmbargoResult(url, ContentSettingsType::NOTIFICATIONS);
  656. EXPECT_FALSE(result.has_value());
  657. // One loud ui dismiss does not trigger embargo.
  658. EXPECT_FALSE(autoblocker()->RecordDismissAndEmbargo(
  659. url, ContentSettingsType::NOTIFICATIONS, false));
  660. result =
  661. autoblocker()->GetEmbargoResult(url, ContentSettingsType::NOTIFICATIONS);
  662. EXPECT_FALSE(result.has_value());
  663. // One quiet ui dismiss puts the url under embargo.
  664. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  665. url, ContentSettingsType::NOTIFICATIONS, true));
  666. result =
  667. autoblocker()->GetEmbargoResult(url, ContentSettingsType::NOTIFICATIONS);
  668. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  669. EXPECT_EQ(PermissionStatusSource::MULTIPLE_DISMISSALS, result->source);
  670. }
  671. namespace {
  672. // Checks that embargo on federated identity permission is lifted only after the
  673. // passed-in |time_delta| has elapsed.
  674. void CheckFederatedIdentityApiEmbargoLiftedAfterTimeElapsing(
  675. PermissionDecisionAutoBlocker* autoblocker,
  676. base::SimpleTestClock* clock,
  677. const GURL& url,
  678. base::TimeDelta time_delta) {
  679. ASSERT_LT(base::Minutes(1), time_delta);
  680. clock->Advance(time_delta - base::Minutes(1));
  681. absl::optional<PermissionResult> result = autoblocker->GetEmbargoResult(
  682. url, ContentSettingsType::FEDERATED_IDENTITY_API);
  683. EXPECT_EQ(CONTENT_SETTING_BLOCK, result->content_setting);
  684. EXPECT_EQ(PermissionStatusSource::MULTIPLE_DISMISSALS, result->source);
  685. clock->Advance(base::Minutes(2));
  686. result = autoblocker->GetEmbargoResult(
  687. url, ContentSettingsType::FEDERATED_IDENTITY_API);
  688. EXPECT_FALSE(result.has_value());
  689. }
  690. } // namespace
  691. TEST_F(PermissionDecisionAutoBlockerUnitTest,
  692. TestDismissFederatedIdentityApiBackoff) {
  693. GURL url("https://www.google.com");
  694. clock()->SetNow(base::Time::Now());
  695. absl::optional<PermissionResult> result = autoblocker()->GetEmbargoResult(
  696. url, ContentSettingsType::FEDERATED_IDENTITY_API);
  697. EXPECT_FALSE(result.has_value());
  698. // 2 hour embargo for 1st dismissal
  699. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  700. url, ContentSettingsType::FEDERATED_IDENTITY_API, false));
  701. CheckFederatedIdentityApiEmbargoLiftedAfterTimeElapsing(
  702. autoblocker(), clock(), url, base::Hours(2));
  703. // 1 day embargo for 2nd dismissal
  704. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  705. url, ContentSettingsType::FEDERATED_IDENTITY_API, false));
  706. CheckFederatedIdentityApiEmbargoLiftedAfterTimeElapsing(
  707. autoblocker(), clock(), url, base::Days(1));
  708. // 7 day embargo for 3rd dismissal
  709. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  710. url, ContentSettingsType::FEDERATED_IDENTITY_API, false));
  711. CheckFederatedIdentityApiEmbargoLiftedAfterTimeElapsing(
  712. autoblocker(), clock(), url, base::Days(7));
  713. // 28 day embargo for 4th dismissal (and all additional dismissals)
  714. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  715. url, ContentSettingsType::FEDERATED_IDENTITY_API, false));
  716. CheckFederatedIdentityApiEmbargoLiftedAfterTimeElapsing(
  717. autoblocker(), clock(), url, base::Days(28));
  718. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  719. url, ContentSettingsType::FEDERATED_IDENTITY_API, false));
  720. CheckFederatedIdentityApiEmbargoLiftedAfterTimeElapsing(
  721. autoblocker(), clock(), url, base::Days(28));
  722. // Return to 2 hour embargo after
  723. // PermissionDecisionAutoBlocker::RemoveEmbargoAndResetCounts()
  724. autoblocker()->RemoveEmbargoAndResetCounts(
  725. url, ContentSettingsType::FEDERATED_IDENTITY_API);
  726. result = autoblocker()->GetEmbargoResult(
  727. url, ContentSettingsType::FEDERATED_IDENTITY_API);
  728. EXPECT_FALSE(result.has_value());
  729. EXPECT_TRUE(autoblocker()->RecordDismissAndEmbargo(
  730. url, ContentSettingsType::FEDERATED_IDENTITY_API, false));
  731. CheckFederatedIdentityApiEmbargoLiftedAfterTimeElapsing(
  732. autoblocker(), clock(), url, base::Hours(2));
  733. }
  734. } // namespace permissions