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

Unified Diff: third_party/WebKit/Source/platform/feature_policy/FeaturePolicyTest.cpp

Issue 2505663002: Add unit tests for testing Feature Policy features in frames, and for testing isFeatureEnabledForOr… (Closed)
Patch Set: Nit Created 4 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/feature_policy/FeaturePolicyTest.cpp
diff --git a/third_party/WebKit/Source/platform/feature_policy/FeaturePolicyTest.cpp b/third_party/WebKit/Source/platform/feature_policy/FeaturePolicyTest.cpp
index 27fb05b5e0208118044f4e55dc911f6db51f0ba5..59cdec9b1c845a628fc27e694beb801e086831a2 100644
--- a/third_party/WebKit/Source/platform/feature_policy/FeaturePolicyTest.cpp
+++ b/third_party/WebKit/Source/platform/feature_policy/FeaturePolicyTest.cpp
@@ -675,7 +675,7 @@ TEST_F(FeaturePolicyTest, TestFeaturesAreIndependent) {
// | | +-------------+ | |
// | +-------------------------------------------+ |
// +-----------------------------------------------+
- // Vibrate feature should be enabled in all frames; Docwrite feature
+ // Default-self feature should be enabled in all frames; Default-on feature
// should be enabled in frame 1, and disabled in frames 2 and 3.
Vector<String> messages;
std::unique_ptr<FeaturePolicy> policy1 =
@@ -699,4 +699,25 @@ TEST_F(FeaturePolicyTest, TestFeaturesAreIndependent) {
EXPECT_FALSE(policy3->isFeatureEnabled(kDefaultOnFeature));
}
+TEST_F(FeaturePolicyTest, TestFeatureEnabledForOrigin) {
+ // +-----------------------------------------------+
+ // |(1) Origin A |
+ // |Policy: {"default-off": ["self", "Origin B"]} |
+ // +-----------------------------------------------+
+ // Features should be enabled by the policy in frame 1 for origins A and B,
+ // and disabled for origin C.
+ Vector<String> messages;
+ std::unique_ptr<FeaturePolicy> policy1 =
+ createFromParentPolicy(nullptr, m_originA);
+ policy1->setHeaderPolicy("{\"default-off\": [\"self\", \"" ORIGIN_B "\"]}",
+ messages);
+ EXPECT_EQ(0UL, messages.size());
+ EXPECT_TRUE(
+ policy1->isFeatureEnabledForOrigin(kDefaultOffFeature, *m_originA));
+ EXPECT_TRUE(
+ policy1->isFeatureEnabledForOrigin(kDefaultOffFeature, *m_originB));
+ EXPECT_FALSE(
+ policy1->isFeatureEnabledForOrigin(kDefaultOffFeature, *m_originC));
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698