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

Side by Side Diff: third_party/WebKit/Source/platform/feature_policy/FeaturePolicyTest.cpp

Issue 2923563003: Move container policy logic to frame owner classes. (Closed)
Patch Set: Addressing nits Created 3 years, 6 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 | « third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp ('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 "platform/feature_policy/FeaturePolicy.h" 5 #include "platform/feature_policy/FeaturePolicy.h"
6 6
7 #include "platform/RuntimeEnabledFeatures.h" 7 #include "platform/RuntimeEnabledFeatures.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 // Origin strings used for tests 10 // Origin strings used for tests
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 parsed_policy[1].origins[0].Get())); 117 parsed_policy[1].origins[0].Get()));
118 EXPECT_TRUE(origin_c_->IsSameSchemeHostPortAndSuborigin( 118 EXPECT_TRUE(origin_c_->IsSameSchemeHostPortAndSuborigin(
119 parsed_policy[1].origins[1].Get())); 119 parsed_policy[1].origins[1].Get()));
120 EXPECT_EQ(WebFeaturePolicyFeature::kPayment, parsed_policy[2].feature); 120 EXPECT_EQ(WebFeaturePolicyFeature::kPayment, parsed_policy[2].feature);
121 EXPECT_FALSE(parsed_policy[2].matches_all_origins); 121 EXPECT_FALSE(parsed_policy[2].matches_all_origins);
122 EXPECT_EQ(1UL, parsed_policy[2].origins.size()); 122 EXPECT_EQ(1UL, parsed_policy[2].origins.size());
123 EXPECT_TRUE(origin_a_->IsSameSchemeHostPortAndSuborigin( 123 EXPECT_TRUE(origin_a_->IsSameSchemeHostPortAndSuborigin(
124 parsed_policy[2].origins[0].Get())); 124 parsed_policy[2].origins[0].Get()));
125 } 125 }
126 126
127 TEST_F(FeaturePolicyTest, ParseEmptyContainerPolicy) {
128 WebParsedFeaturePolicy container_policy =
129 GetContainerPolicyFromAllowedFeatures(
130 std::vector<WebFeaturePolicyFeature>({}), false, false,
131 origin_a_.Get());
132 EXPECT_EQ(0UL, container_policy.size());
133 }
134
135 TEST_F(FeaturePolicyTest, ParseContainerPolicy) {
136 WebParsedFeaturePolicy container_policy =
137 GetContainerPolicyFromAllowedFeatures(
138 std::vector<WebFeaturePolicyFeature>(
139 {WebFeaturePolicyFeature::kVibrate,
140 WebFeaturePolicyFeature::kPayment}),
141 false, false, origin_a_.Get());
142 EXPECT_EQ(2UL, container_policy.size());
143 EXPECT_EQ(WebFeaturePolicyFeature::kVibrate, container_policy[0].feature);
144 EXPECT_FALSE(container_policy[0].matches_all_origins);
145 EXPECT_EQ(1UL, container_policy[0].origins.size());
146 EXPECT_TRUE(origin_a_->IsSameSchemeHostPortAndSuborigin(
147 container_policy[0].origins[0].Get()));
148 EXPECT_EQ(WebFeaturePolicyFeature::kPayment, container_policy[1].feature);
149 EXPECT_FALSE(container_policy[1].matches_all_origins);
150 EXPECT_EQ(1UL, container_policy[1].origins.size());
151 EXPECT_TRUE(origin_a_->IsSameSchemeHostPortAndSuborigin(
152 container_policy[1].origins[0].Get()));
153 }
154
155 TEST_F(FeaturePolicyTest, ParseContainerPolicyWithAllowFullscreen) {
156 WebParsedFeaturePolicy container_policy =
157 GetContainerPolicyFromAllowedFeatures(
158 std::vector<WebFeaturePolicyFeature>({}), true, false,
159 origin_a_.Get());
160 EXPECT_EQ(1UL, container_policy.size());
161 EXPECT_EQ(WebFeaturePolicyFeature::kFullscreen, container_policy[0].feature);
162 EXPECT_TRUE(container_policy[0].matches_all_origins);
163 }
164
165 TEST_F(FeaturePolicyTest, ParseContainerPolicyWithAllowPaymentRequest) {
166 WebParsedFeaturePolicy container_policy =
167 GetContainerPolicyFromAllowedFeatures(
168 std::vector<WebFeaturePolicyFeature>(
169 {WebFeaturePolicyFeature::kVibrate}),
170 false, true, origin_a_.Get());
171 EXPECT_EQ(2UL, container_policy.size());
172 EXPECT_EQ(WebFeaturePolicyFeature::kVibrate, container_policy[0].feature);
173 EXPECT_FALSE(container_policy[0].matches_all_origins);
174 EXPECT_EQ(1UL, container_policy[0].origins.size());
175 EXPECT_TRUE(origin_a_->IsSameSchemeHostPortAndSuborigin(
176 container_policy[0].origins[0].Get()));
177 EXPECT_EQ(WebFeaturePolicyFeature::kPayment, container_policy[1].feature);
178 EXPECT_TRUE(container_policy[1].matches_all_origins);
179 }
180
181 TEST_F(FeaturePolicyTest, ParseContainerPolicyWithAllowAttributes) {
182 WebParsedFeaturePolicy container_policy =
183 GetContainerPolicyFromAllowedFeatures(
184 std::vector<WebFeaturePolicyFeature>(
185 {WebFeaturePolicyFeature::kVibrate,
186 WebFeaturePolicyFeature::kPayment}),
187 true, true, origin_a_.Get());
188 EXPECT_EQ(3UL, container_policy.size());
189 EXPECT_EQ(WebFeaturePolicyFeature::kVibrate, container_policy[0].feature);
190 EXPECT_FALSE(container_policy[0].matches_all_origins);
191 EXPECT_EQ(1UL, container_policy[0].origins.size());
192 EXPECT_TRUE(origin_a_->IsSameSchemeHostPortAndSuborigin(
193 container_policy[0].origins[0].Get()));
194 EXPECT_EQ(WebFeaturePolicyFeature::kPayment, container_policy[1].feature);
195 EXPECT_FALSE(container_policy[1].matches_all_origins);
196 EXPECT_EQ(1UL, container_policy[1].origins.size());
197 EXPECT_TRUE(origin_a_->IsSameSchemeHostPortAndSuborigin(
198 container_policy[1].origins[0].Get()));
199 EXPECT_EQ(WebFeaturePolicyFeature::kFullscreen, container_policy[2].feature);
200 EXPECT_TRUE(container_policy[2].matches_all_origins);
201 }
202
203 } // namespace blink 127 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698