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

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

Issue 2739203002: Initial Implementation of Iframe Attribute for Feature Policy (Part 3) (Closed)
Patch Set: Bug fix: frame owner does not always exist. 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 unified diff | Download patch
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 parsedPolicy[1].origins[0].get())); 109 parsedPolicy[1].origins[0].get()));
110 EXPECT_TRUE(m_originC->isSameSchemeHostPortAndSuborigin( 110 EXPECT_TRUE(m_originC->isSameSchemeHostPortAndSuborigin(
111 parsedPolicy[1].origins[1].get())); 111 parsedPolicy[1].origins[1].get()));
112 EXPECT_EQ(WebFeaturePolicyFeature::Payment, parsedPolicy[2].feature); 112 EXPECT_EQ(WebFeaturePolicyFeature::Payment, parsedPolicy[2].feature);
113 EXPECT_FALSE(parsedPolicy[2].matchesAllOrigins); 113 EXPECT_FALSE(parsedPolicy[2].matchesAllOrigins);
114 EXPECT_EQ(1UL, parsedPolicy[2].origins.size()); 114 EXPECT_EQ(1UL, parsedPolicy[2].origins.size());
115 EXPECT_TRUE(m_originA->isSameSchemeHostPortAndSuborigin( 115 EXPECT_TRUE(m_originA->isSameSchemeHostPortAndSuborigin(
116 parsedPolicy[2].origins[0].get())); 116 parsedPolicy[2].origins[0].get()));
117 } 117 }
118 118
119 TEST_F(FeaturePolicyTest, ParseEmptyContainerPolicy) {
120 WebParsedFeaturePolicy containerPolicy =
121 getContainerPolicyFromAllowedFeatures(
122 std::vector<WebFeaturePolicyFeature>({}), m_originA.get());
123 EXPECT_EQ(0UL, containerPolicy.size());
124 }
125
126 TEST_F(FeaturePolicyTest, ParseContainerPolicy) {
127 WebParsedFeaturePolicy containerPolicy =
128 getContainerPolicyFromAllowedFeatures(
129 std::vector<WebFeaturePolicyFeature>(
130 {WebFeaturePolicyFeature::Vibrate,
131 WebFeaturePolicyFeature::Payment}),
132 m_originA.get());
133 EXPECT_EQ(2UL, containerPolicy.size());
134 EXPECT_EQ(WebFeaturePolicyFeature::Vibrate, containerPolicy[0].feature);
135 EXPECT_FALSE(containerPolicy[0].matchesAllOrigins);
136 EXPECT_EQ(1UL, containerPolicy[0].origins.size());
137 EXPECT_TRUE(m_originA->isSameSchemeHostPortAndSuborigin(
138 containerPolicy[0].origins[0].get()));
139 EXPECT_EQ(WebFeaturePolicyFeature::Payment, containerPolicy[1].feature);
140 EXPECT_FALSE(containerPolicy[1].matchesAllOrigins);
141 EXPECT_EQ(1UL, containerPolicy[1].origins.size());
142 EXPECT_TRUE(m_originA->isSameSchemeHostPortAndSuborigin(
143 containerPolicy[1].origins[0].get()));
144 }
145
119 } // namespace blink 146 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698