-
Notifications
You must be signed in to change notification settings - Fork 885
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests of plugins content settings type with INHERIT_IN_INCOGNITO
- Loading branch information
Showing
2 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
...c/components/content_settings/core/browser/brave_content_settings_registry_browsertest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/components/brave_shields/common/brave_shield_constants.h" | ||
#include "chrome/browser/content_settings/host_content_settings_map_factory.h" | ||
#include "chrome/browser/profiles/profile.h" | ||
#include "chrome/browser/ui/browser.h" | ||
#include "chrome/test/base/in_process_browser_test.h" | ||
#include "components/content_settings/core/browser/host_content_settings_map.h" | ||
#include "components/content_settings/core/common/content_settings_pattern.h" | ||
|
||
const GURL kBraveURL("https://www.brave.com"); | ||
|
||
class BraveContentSettingsRegistryBrowserTest : public InProcessBrowserTest { | ||
public: | ||
using InProcessBrowserTest::InProcessBrowserTest; | ||
|
||
HostContentSettingsMap* content_settings() { | ||
return HostContentSettingsMapFactory::GetForProfile(browser()->profile()); | ||
} | ||
|
||
HostContentSettingsMap* private_content_settings() { | ||
return HostContentSettingsMapFactory::GetForProfile( | ||
browser()->profile()->GetOffTheRecordProfile()); | ||
} | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(BraveContentSettingsRegistryBrowserTest); | ||
}; | ||
|
||
IN_PROC_BROWSER_TEST_F(BraveContentSettingsRegistryBrowserTest, | ||
WithWildcardContentSetting) { | ||
content_settings()->SetContentSettingCustomScope( | ||
ContentSettingsPattern::Wildcard(), | ||
ContentSettingsPattern::Wildcard(), | ||
CONTENT_SETTINGS_TYPE_PLUGINS, | ||
brave_shields::kBraveShields, | ||
CONTENT_SETTING_ALLOW); | ||
|
||
ContentSetting brave_url_shields_setting = | ||
content_settings()->GetContentSetting( | ||
kBraveURL, kBraveURL, CONTENT_SETTINGS_TYPE_PLUGINS, | ||
brave_shields::kBraveShields); | ||
EXPECT_EQ(CONTENT_SETTING_ALLOW, brave_url_shields_setting); | ||
|
||
ContentSetting brave_url_shields_setting_private = | ||
private_content_settings()->GetContentSetting( | ||
kBraveURL, kBraveURL, CONTENT_SETTINGS_TYPE_PLUGINS, | ||
brave_shields::kBraveShields); | ||
EXPECT_EQ(CONTENT_SETTING_ALLOW, brave_url_shields_setting_private); | ||
} | ||
|
||
IN_PROC_BROWSER_TEST_F(BraveContentSettingsRegistryBrowserTest, | ||
WithoutWildcardContentSetting) { | ||
ContentSetting brave_url_shields_setting = | ||
content_settings()->GetContentSetting( | ||
kBraveURL, kBraveURL, CONTENT_SETTINGS_TYPE_PLUGINS, | ||
brave_shields::kBraveShields); | ||
EXPECT_EQ(CONTENT_SETTING_DEFAULT, brave_url_shields_setting); | ||
|
||
ContentSetting brave_url_shields_setting_private = | ||
private_content_settings()->GetContentSetting( | ||
kBraveURL, kBraveURL, CONTENT_SETTINGS_TYPE_PLUGINS, | ||
brave_shields::kBraveShields); | ||
EXPECT_EQ(CONTENT_SETTING_DEFAULT, brave_url_shields_setting_private); | ||
} | ||
|
||
IN_PROC_BROWSER_TEST_F(BraveContentSettingsRegistryBrowserTest, | ||
WithBraveShieldsContentSetting) { | ||
ContentSettingsPattern brave_url_pattern = | ||
ContentSettingsPattern::FromURL(kBraveURL); | ||
|
||
content_settings()->SetContentSettingCustomScope( | ||
brave_url_pattern, | ||
brave_url_pattern, | ||
CONTENT_SETTINGS_TYPE_PLUGINS, | ||
brave_shields::kBraveShields, | ||
CONTENT_SETTING_ALLOW); | ||
|
||
ContentSetting brave_url_shields_setting = | ||
content_settings()->GetContentSetting( | ||
kBraveURL, kBraveURL, CONTENT_SETTINGS_TYPE_PLUGINS, | ||
brave_shields::kBraveShields); | ||
EXPECT_EQ(CONTENT_SETTING_ALLOW, brave_url_shields_setting); | ||
|
||
ContentSetting brave_url_shields_setting_private = | ||
private_content_settings()->GetContentSetting( | ||
kBraveURL, kBraveURL, CONTENT_SETTINGS_TYPE_PLUGINS, | ||
brave_shields::kBraveShields); | ||
EXPECT_EQ(CONTENT_SETTING_ALLOW, brave_url_shields_setting_private); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters