Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: chrome/browser/permissions/permission_decision_auto_blocker_unittest.cc

Issue 2772513004: Disable permissions embargo for plugins. (Closed)
Patch Set: Add todo Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/permissions/permission_decision_auto_blocker.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" 5 #include "chrome/browser/permissions/permission_decision_auto_blocker.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 303
304 CheckSafeBrowsingBlacklist(url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 304 CheckSafeBrowsingBlacklist(url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
305 EXPECT_FALSE(last_embargoed_status()); 305 EXPECT_FALSE(last_embargoed_status());
306 histograms.ExpectUniqueSample( 306 histograms.ExpectUniqueSample(
307 "Permissions.AutoBlocker.SafeBrowsingResponse", 307 "Permissions.AutoBlocker.SafeBrowsingResponse",
308 static_cast<int>(SafeBrowsingResponse::NOT_BLACKLISTED), 1); 308 static_cast<int>(SafeBrowsingResponse::NOT_BLACKLISTED), 1);
309 histograms.ExpectTotalCount( 309 histograms.ExpectTotalCount(
310 "Permissions.AutoBlocker.SafeBrowsingResponseTime", 1); 310 "Permissions.AutoBlocker.SafeBrowsingResponseTime", 1);
311 } 311 }
312 312
313 // Check that we do not apply embargo to the plugins content type, as prompts
314 // should be triggered only when necessary by Html5ByDefault.
315 TEST_F(PermissionDecisionAutoBlockerUnitTest,
316 PluginsNotEmbargoedByMultipleDismisses) {
317 GURL url("https://www.google.com");
318 autoblocker()->RecordDismissAndEmbargo(url, CONTENT_SETTINGS_TYPE_PLUGINS);
319 autoblocker()->RecordDismissAndEmbargo(url, CONTENT_SETTINGS_TYPE_PLUGINS);
320 PermissionResult result =
321 autoblocker()->GetEmbargoResult(url, CONTENT_SETTINGS_TYPE_PLUGINS);
322
323 EXPECT_EQ(CONTENT_SETTING_ASK, result.content_setting);
324 EXPECT_EQ(PermissionStatusSource::UNSPECIFIED, result.source);
325 EXPECT_EQ(2,
326 autoblocker()->GetDismissCount(url, CONTENT_SETTINGS_TYPE_PLUGINS));
327
328 // The third dismiss would normally embargo, but this shouldn't happen for
329 // plugins.
330 autoblocker()->RecordDismissAndEmbargo(url, CONTENT_SETTINGS_TYPE_PLUGINS);
331 result = autoblocker()->GetEmbargoResult(url, CONTENT_SETTINGS_TYPE_PLUGINS);
332
333 EXPECT_EQ(CONTENT_SETTING_ASK, result.content_setting);
334 EXPECT_EQ(PermissionStatusSource::UNSPECIFIED, result.source);
335 EXPECT_EQ(3,
336 autoblocker()->GetDismissCount(url, CONTENT_SETTINGS_TYPE_PLUGINS));
337
338 // Extra one for sanity checking.
339 autoblocker()->RecordDismissAndEmbargo(url, CONTENT_SETTINGS_TYPE_PLUGINS);
340 result = autoblocker()->GetEmbargoResult(url, CONTENT_SETTINGS_TYPE_PLUGINS);
341
342 EXPECT_EQ(CONTENT_SETTING_ASK, result.content_setting);
343 EXPECT_EQ(PermissionStatusSource::UNSPECIFIED, result.source);
344 EXPECT_EQ(4,
345 autoblocker()->GetDismissCount(url, CONTENT_SETTINGS_TYPE_PLUGINS));
346 }
347
313 // Check that GetEmbargoResult returns the correct value when the embargo is set 348 // Check that GetEmbargoResult returns the correct value when the embargo is set
314 // and expires. 349 // and expires.
315 TEST_F(PermissionDecisionAutoBlockerUnitTest, CheckEmbargoStatus) { 350 TEST_F(PermissionDecisionAutoBlockerUnitTest, CheckEmbargoStatus) {
316 GURL url("https://www.google.com"); 351 GURL url("https://www.google.com");
317 clock()->SetNow(base::Time::Now()); 352 clock()->SetNow(base::Time::Now());
318 353
319 // Check the default state. 354 // Check the default state.
320 PermissionResult result = 355 PermissionResult result =
321 autoblocker()->GetEmbargoResult(url, CONTENT_SETTINGS_TYPE_GEOLOCATION); 356 autoblocker()->GetEmbargoResult(url, CONTENT_SETTINGS_TYPE_GEOLOCATION);
322 EXPECT_EQ(CONTENT_SETTING_ASK, result.content_setting); 357 EXPECT_EQ(CONTENT_SETTING_ASK, result.content_setting);
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 db_manager->BlacklistUrlPermissions(url, blacklisted_permissions); 652 db_manager->BlacklistUrlPermissions(url, blacklisted_permissions);
618 SetSafeBrowsingDatabaseManagerAndTimeoutForTesting(db_manager, 653 SetSafeBrowsingDatabaseManagerAndTimeoutForTesting(db_manager,
619 0 /* timeout in ms */); 654 0 /* timeout in ms */);
620 655
621 CheckSafeBrowsingBlacklist(url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 656 CheckSafeBrowsingBlacklist(url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
622 EXPECT_FALSE(last_embargoed_status()); 657 EXPECT_FALSE(last_embargoed_status());
623 histograms.ExpectUniqueSample( 658 histograms.ExpectUniqueSample(
624 "Permissions.AutoBlocker.SafeBrowsingResponse", 659 "Permissions.AutoBlocker.SafeBrowsingResponse",
625 static_cast<int>(SafeBrowsingResponse::NOT_BLACKLISTED), 1); 660 static_cast<int>(SafeBrowsingResponse::NOT_BLACKLISTED), 1);
626 } 661 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_decision_auto_blocker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698