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

Unified Diff: content/browser/site_per_process_browsertest.cc

Issue 2727803004: Replace string by enum in WebParsedFeaturePolicyDeclaration#feature (Closed)
Patch Set: Filter out unrecognized features in parseFeaturePolicy (earlier) instead of setHeaderPolicy 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/site_per_process_browsertest.cc
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc
index 1540a4ff8348a234d2b295a8903c399303669369..34104e6208216e762733862eafa49135398d5d14 100644
--- a/content/browser/site_per_process_browsertest.cc
+++ b/content/browser/site_per_process_browsertest.cc
@@ -678,10 +678,11 @@ class SitePerProcessFeaturePolicyBrowserTest
"FeaturePolicy");
}
- ParsedFeaturePolicyHeader CreateFPHeader(const std::string& feature_name,
- const std::vector<GURL>& origins) {
+ ParsedFeaturePolicyHeader CreateFPHeader(
+ const blink::WebFeaturePolicyFeature feature,
+ const std::vector<GURL>& origins) {
ParsedFeaturePolicyHeader result(1);
- result[0].feature_name = feature_name;
+ result[0].feature = feature;
result[0].matches_all_origins = false;
DCHECK(!origins.empty());
for (const GURL& origin : origins)
@@ -690,9 +691,9 @@ class SitePerProcessFeaturePolicyBrowserTest
}
ParsedFeaturePolicyHeader CreateFPHeaderMatchesAll(
- const std::string& feature_name) {
+ const blink::WebFeaturePolicyFeature feature) {
ParsedFeaturePolicyHeader result(1);
- result[0].feature_name = feature_name;
+ result[0].feature = feature;
result[0].matches_all_origins = true;
return result;
}
@@ -700,10 +701,8 @@ class SitePerProcessFeaturePolicyBrowserTest
bool operator==(const ParsedFeaturePolicyDeclaration& first,
const ParsedFeaturePolicyDeclaration& second) {
- return std::tie(first.feature_name, first.matches_all_origins,
- first.origins) == std::tie(second.feature_name,
- second.matches_all_origins,
- second.origins);
+ return std::tie(first.feature, first.matches_all_origins, first.origins) ==
+ std::tie(second.feature, second.matches_all_origins, second.origins);
}
double GetFrameDeviceScaleFactor(const ToRenderFrameHost& adapter) {
@@ -8870,13 +8869,14 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessFeaturePolicyBrowserTest,
EXPECT_TRUE(NavigateToURL(shell(), start_url));
FrameTreeNode* root = web_contents()->GetFrameTree()->root();
- EXPECT_EQ(CreateFPHeader("vibrate", {start_url.GetOrigin()}),
+ EXPECT_EQ(CreateFPHeader(blink::WebFeaturePolicyFeature::Vibrate,
+ {start_url.GetOrigin()}),
root->current_replication_state().feature_policy_header);
// When the main frame navigates to a page with a new policy, it should
// overwrite the old one.
EXPECT_TRUE(NavigateToURL(shell(), first_nav_url));
- EXPECT_EQ(CreateFPHeaderMatchesAll("vibrate"),
+ EXPECT_EQ(CreateFPHeaderMatchesAll(blink::WebFeaturePolicyFeature::Vibrate),
root->current_replication_state().feature_policy_header);
// When the main frame navigates to a page without a policy, the replicated
@@ -8896,13 +8896,14 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessFeaturePolicyBrowserTest,
EXPECT_TRUE(NavigateToURL(shell(), start_url));
FrameTreeNode* root = web_contents()->GetFrameTree()->root();
- EXPECT_EQ(CreateFPHeader("vibrate", {start_url.GetOrigin()}),
+ EXPECT_EQ(CreateFPHeader(blink::WebFeaturePolicyFeature::Vibrate,
+ {start_url.GetOrigin()}),
root->current_replication_state().feature_policy_header);
// When the main frame navigates to a page with a new policy, it should
// overwrite the old one.
EXPECT_TRUE(NavigateToURL(shell(), first_nav_url));
- EXPECT_EQ(CreateFPHeaderMatchesAll("vibrate"),
+ EXPECT_EQ(CreateFPHeaderMatchesAll(blink::WebFeaturePolicyFeature::Vibrate),
root->current_replication_state().feature_policy_header);
// When the main frame navigates to a page without a policy, the replicated
@@ -8924,18 +8925,19 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessFeaturePolicyBrowserTest,
EXPECT_TRUE(NavigateToURL(shell(), main_url));
FrameTreeNode* root = web_contents()->GetFrameTree()->root();
- EXPECT_EQ(CreateFPHeader("vibrate",
+ EXPECT_EQ(CreateFPHeader(blink::WebFeaturePolicyFeature::Vibrate,
{main_url.GetOrigin(), GURL("http://example.com/")}),
root->current_replication_state().feature_policy_header);
EXPECT_EQ(1UL, root->child_count());
EXPECT_EQ(
- CreateFPHeader("vibrate", {main_url.GetOrigin()}),
+ CreateFPHeader(blink::WebFeaturePolicyFeature::Vibrate,
+ {main_url.GetOrigin()}),
root->child_at(0)->current_replication_state().feature_policy_header);
// Navigate the iframe cross-site.
NavigateFrameToURL(root->child_at(0), first_nav_url);
EXPECT_EQ(
- CreateFPHeaderMatchesAll("vibrate"),
+ CreateFPHeaderMatchesAll(blink::WebFeaturePolicyFeature::Vibrate),
root->child_at(0)->current_replication_state().feature_policy_header);
// Navigate the iframe to another location, this one with no policy header
@@ -8947,7 +8949,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessFeaturePolicyBrowserTest,
// Navigate the iframe back to a page with a policy
NavigateFrameToURL(root->child_at(0), first_nav_url);
EXPECT_EQ(
- CreateFPHeaderMatchesAll("vibrate"),
+ CreateFPHeaderMatchesAll(blink::WebFeaturePolicyFeature::Vibrate),
root->child_at(0)->current_replication_state().feature_policy_header);
}

Powered by Google App Engine
This is Rietveld 408576698