Commit e8d25d87 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Add ephemeral Guest profile support to CookieSettingsFactoryTest.

CookieSettingsFactory unittest is updated to cover ephemeral Guest
profiles.

Please see go/ephemeral-guest-profiles for more context.

Bug: 1125474
Change-Id: I71fa7a2027df6abf70a15bcde20ca0a3f749af0e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2516939Reviewed-by: default avatarChristian Dullweber <dullweber@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823522}
parent 8a4652d8
......@@ -86,15 +86,34 @@ TEST_F(CookieSettingsFactoryTest, IncognitoBehaviorOfBlockingEverything) {
// Android does not have guest profiles.
#if !defined(OS_ANDROID)
class GuestCookieSettingsFactoryTest
: public CookieSettingsFactoryTest,
public testing::WithParamInterface<bool> {
public:
GuestCookieSettingsFactoryTest() : is_ephemeral_(GetParam()) {
// Change the value if Ephemeral is not supported.
is_ephemeral_ &=
TestingProfile::SetScopedFeatureListForEphemeralGuestProfiles(
scoped_feature_list_, is_ephemeral_);
}
bool is_ephemeral() const { return is_ephemeral_; }
private:
bool is_ephemeral_;
base::test::ScopedFeatureList scoped_feature_list_;
};
// Tests that cookie blocking is not enabled by default for guest profiles.
TEST_F(CookieSettingsFactoryTest, GuestProfile) {
TEST_P(GuestCookieSettingsFactoryTest, GuestProfile) {
TestingProfile::Builder guest_profile_builder;
guest_profile_builder.SetGuestSession();
std::unique_ptr<Profile> guest_profile = guest_profile_builder.Build();
Profile* otr_guest_profile = guest_profile->GetPrimaryOTRProfile();
EXPECT_TRUE(otr_guest_profile->IsOffTheRecord());
Profile* profile_to_use = is_ephemeral()
? guest_profile.get()
: guest_profile->GetPrimaryOTRProfile();
scoped_refptr<content_settings::CookieSettings> guest_settings =
CookieSettingsFactory::GetForProfile(otr_guest_profile);
CookieSettingsFactory::GetForProfile(profile_to_use);
EXPECT_FALSE(guest_settings->ShouldBlockThirdPartyCookies());
// OTOH, cookie blocking is default for an incognito profile.
......@@ -102,6 +121,11 @@ TEST_F(CookieSettingsFactoryTest, GuestProfile) {
CookieSettingsFactory::GetForProfile(profile_.GetPrimaryOTRProfile())
->ShouldBlockThirdPartyCookies());
}
INSTANTIATE_TEST_SUITE_P(AllGuestTypes,
GuestCookieSettingsFactoryTest,
/*is_ephemeral=*/testing::Bool());
#endif
} // namespace
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment