0

[SAA] Check the feature's default state in addition to REF state

Fixed: 406271680
Change-Id: I6e8ae91f177eada86b70783eb1ab219dc872573d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6394958
Reviewed-by: Yi Gu <yigu@chromium.org>
Auto-Submit: Chris Fredrickson <cfredric@chromium.org>
Commit-Queue: Yi Gu <yigu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1438219}
This commit is contained in:
Chris Fredrickson 2025-03-26 10:08:18 -07:00 committed by Chromium LUCI CQ
parent e93d3dac09
commit bf53cd368c
3 changed files with 48 additions and 13 deletions

@ -2825,12 +2825,18 @@ IN_PROC_BROWSER_TEST_F(StorageAccessAPIWith3PCEnabledBrowserTest,
}
class StorageAccessAPIAutograntsWithFedCMBrowserTest
: public StorageAccessAPIBaseBrowserTest {
: public StorageAccessAPIBaseBrowserTest,
public testing::WithParamInterface<bool> {
public:
std::vector<base::test::FeatureRefAndParams> GetEnabledFeatures() override {
return {{blink::features::kFedCmWithStorageAccessAPI, {}}};
if (override_feature_state()) {
return {{blink::features::kFedCmWithStorageAccessAPI, {}}};
}
return {};
}
bool override_feature_state() const { return GetParam(); }
void GrantFedCMPermission() {
const url::Origin rp_embedder =
url::Origin::Create(GetURL(kHostASubdomain));
@ -2872,7 +2878,7 @@ class StorageAccessAPIAutograntsWithFedCMBrowserTest
}
};
IN_PROC_BROWSER_TEST_F(StorageAccessAPIAutograntsWithFedCMBrowserTest,
IN_PROC_BROWSER_TEST_P(StorageAccessAPIAutograntsWithFedCMBrowserTest,
FedCMGrants_RequiresPermissionPolicy) {
SetBlockThirdPartyCookies(true);
GrantFedCMPermission();
@ -2890,7 +2896,7 @@ IN_PROC_BROWSER_TEST_F(StorageAccessAPIAutograntsWithFedCMBrowserTest,
EXPECT_FALSE(storage::test::HasStorageAccessForFrame(GetFrame()));
}
IN_PROC_BROWSER_TEST_F(StorageAccessAPIAutograntsWithFedCMBrowserTest,
IN_PROC_BROWSER_TEST_P(StorageAccessAPIAutograntsWithFedCMBrowserTest,
FedCMGrants_PreventSilentAccess) {
SetBlockThirdPartyCookies(true);
GrantFedCMPermission();
@ -2911,7 +2917,7 @@ IN_PROC_BROWSER_TEST_F(StorageAccessAPIAutograntsWithFedCMBrowserTest,
EXPECT_EQ(ReadCookies(GetFrame(), kHostB), kNoCookies);
}
IN_PROC_BROWSER_TEST_F(StorageAccessAPIAutograntsWithFedCMBrowserTest,
IN_PROC_BROWSER_TEST_P(StorageAccessAPIAutograntsWithFedCMBrowserTest,
FedCMGrants_PreventSilentAccess_AfterAutogrant) {
SetBlockThirdPartyCookies(true);
GrantFedCMPermission();
@ -2932,7 +2938,7 @@ IN_PROC_BROWSER_TEST_F(StorageAccessAPIAutograntsWithFedCMBrowserTest,
EXPECT_EQ(ReadCookies(GetFrame(), kHostB), kNoCookies);
}
IN_PROC_BROWSER_TEST_F(StorageAccessAPIAutograntsWithFedCMBrowserTest,
IN_PROC_BROWSER_TEST_P(StorageAccessAPIAutograntsWithFedCMBrowserTest,
FedCMGrants_PermissionPolicyHeaderIgnored) {
SetBlockThirdPartyCookies(true);
GrantFedCMPermission();
@ -2970,7 +2976,7 @@ IN_PROC_BROWSER_TEST_F(StorageAccessAPIAutograntsWithFedCMBrowserTest,
EXPECT_FALSE(storage::test::HasStorageAccessForFrame(GetFrame()));
}
IN_PROC_BROWSER_TEST_F(StorageAccessAPIAutograntsWithFedCMBrowserTest,
IN_PROC_BROWSER_TEST_P(StorageAccessAPIAutograntsWithFedCMBrowserTest,
FedCMGrantsAllowCookieAccessViaSAA) {
SetBlockThirdPartyCookies(true);
GrantFedCMPermission();
@ -2992,7 +2998,7 @@ IN_PROC_BROWSER_TEST_F(StorageAccessAPIAutograntsWithFedCMBrowserTest,
EXPECT_FALSE(storage::test::HasStorageAccessForFrame(GetFrame()));
}
IN_PROC_BROWSER_TEST_F(StorageAccessAPIAutograntsWithFedCMBrowserTest,
IN_PROC_BROWSER_TEST_P(StorageAccessAPIAutograntsWithFedCMBrowserTest,
FedCMGrantsAllowCookieAccess_NestedFrame) {
SetBlockThirdPartyCookies(true);
GrantFedCMPermission();
@ -3019,6 +3025,10 @@ IN_PROC_BROWSER_TEST_F(StorageAccessAPIAutograntsWithFedCMBrowserTest,
EXPECT_FALSE(storage::test::HasStorageAccessForFrame(GetNestedFrame()));
}
INSTANTIATE_TEST_SUITE_P(,
StorageAccessAPIAutograntsWithFedCMBrowserTest,
testing::Bool());
class StorageAccessHeadersDisabledBrowserTest
: public StorageAccessAPIBrowserTest {
public:
@ -3496,7 +3506,7 @@ class StorageAccessHeadersWithFedCMBrowserTest
}
};
IN_PROC_BROWSER_TEST_F(StorageAccessHeadersWithFedCMBrowserTest, RetryHeader) {
IN_PROC_BROWSER_TEST_P(StorageAccessHeadersWithFedCMBrowserTest, RetryHeader) {
SetBlockThirdPartyCookies(true);
SetRetryAllowedOriginFromHost(kHostA);
GrantFedCMPermission();
@ -3518,6 +3528,9 @@ IN_PROC_BROWSER_TEST_F(StorageAccessHeadersWithFedCMBrowserTest, RetryHeader) {
Pair(kSecFetchStorageAccess, "none"))));
EXPECT_EQ(retry_path_fetch_count_, 1);
}
INSTANTIATE_TEST_SUITE_P(,
StorageAccessHeadersWithFedCMBrowserTest,
testing::Bool());
class StorageAccessAPIWindowOpenTestBase
: public StorageAccessAPIBaseBrowserTest {

@ -197,6 +197,13 @@ bool AreFedCmAutograntsEnabled(content::RenderFrameHost* rfh) {
state.has_value()) {
return state.value();
}
// RuntimeFeatureStateDocumentData doesn't know what the default state of a
// feature is, so we check the underlying feature explicitly.
if (base::FeatureList::IsEnabled(
blink::features::kFedCmWithStorageAccessAPI)) {
return true;
}
content::RuntimeFeatureStateDocumentData* document_data =
content::RuntimeFeatureStateDocumentData::GetForCurrentDocument(rfh);
CHECK(document_data);

@ -710,15 +710,23 @@ TEST_F(StorageAccessGrantPermissionContextAPIWithFirstPartySetsTest,
}
class StorageAccessGrantPermissionContextAPIWithFedCMConnectionTest
: public StorageAccessGrantPermissionContextTest {
: public StorageAccessGrantPermissionContextTest,
public testing::WithParamInterface<bool> {
public:
StorageAccessGrantPermissionContextAPIWithFedCMConnectionTest() = default;
void SetUp() override {
StorageAccessGrantPermissionContextTest::SetUp();
feature_list_.InitAndEnableFeature(
blink::features::kFedCmWithStorageAccessAPI);
// This feature is already enabled by default, but the SUT behavior does
// different things if it's overridden or not. So we also try initializing
// as-is, without overriding.
if (override_feature_state()) {
feature_list_.InitAndEnableFeature(
blink::features::kFedCmWithStorageAccessAPI);
} else {
feature_list_.Init();
}
FederatedIdentityPermissionContextFactory::GetForProfile(profile())
->GrantSharingPermission(
@ -730,11 +738,13 @@ class StorageAccessGrantPermissionContextAPIWithFedCMConnectionTest
"my_account");
}
bool override_feature_state() const { return GetParam(); }
private:
base::test::ScopedFeatureList feature_list_;
};
TEST_F(StorageAccessGrantPermissionContextAPIWithFedCMConnectionTest,
TEST_P(StorageAccessGrantPermissionContextAPIWithFedCMConnectionTest,
AutoResolveWithConnection) {
prompt_factory().set_response_type(
permissions::PermissionRequestManager::AutoResponseType::NONE);
@ -762,3 +772,8 @@ TEST_F(StorageAccessGrantPermissionContextAPIWithFedCMConnectionTest,
ContentSettingsType::STORAGE_ACCESS),
IsEmpty());
}
INSTANTIATE_TEST_SUITE_P(
,
StorageAccessGrantPermissionContextAPIWithFedCMConnectionTest,
testing::Bool());