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

Side by Side Diff: third_party/WebKit/Source/core/frame/FeaturePolicyInFrameTest.cpp

Issue 2655023004: Feature policy: Add basic algorithm for supporting frame policies. (Closed)
Patch Set: Addressing review comments Created 3 years, 10 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 "bindings/core/v8/ConditionalFeatures.h" 7 #include "bindings/core/v8/ConditionalFeatures.h"
8 #include "core/frame/LocalFrame.h" 8 #include "core/frame/LocalFrame.h"
9 #include "core/testing/DummyPageHolder.h" 9 #include "core/testing/DummyPageHolder.h"
10 #include "platform/RuntimeEnabledFeatures.h" 10 #include "platform/RuntimeEnabledFeatures.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 m_dummyPageHolder->document().setSecurityOrigin(m_originA); 47 m_dummyPageHolder->document().setSecurityOrigin(m_originA);
48 } 48 }
49 49
50 ~FeaturePolicyInFrameTest() { 50 ~FeaturePolicyInFrameTest() {
51 RuntimeEnabledFeatures::setFeaturePolicyEnabled(m_frameworkWasEnabled); 51 RuntimeEnabledFeatures::setFeaturePolicyEnabled(m_frameworkWasEnabled);
52 } 52 }
53 53
54 std::unique_ptr<FeaturePolicy> createFromParentPolicy( 54 std::unique_ptr<FeaturePolicy> createFromParentPolicy(
55 const FeaturePolicy* parent, 55 const FeaturePolicy* parent,
56 RefPtr<SecurityOrigin> origin) { 56 RefPtr<SecurityOrigin> origin) {
57 return FeaturePolicy::createFromParentPolicy(parent, origin, m_featureList); 57 return FeaturePolicy::createFromParentPolicy(parent, nullptr, origin,
58 m_featureList);
58 } 59 }
59 60
60 Document& document() { return m_dummyPageHolder->document(); } 61 Document& document() { return m_dummyPageHolder->document(); }
61 62
62 LocalFrame* frame() { return m_dummyPageHolder->document().frame(); } 63 LocalFrame* frame() { return m_dummyPageHolder->document().frame(); }
63 64
64 RefPtr<SecurityOrigin> m_originA = SecurityOrigin::createFromString(ORIGIN_A); 65 RefPtr<SecurityOrigin> m_originA = SecurityOrigin::createFromString(ORIGIN_A);
65 RefPtr<SecurityOrigin> m_originB = SecurityOrigin::createFromString(ORIGIN_B); 66 RefPtr<SecurityOrigin> m_originB = SecurityOrigin::createFromString(ORIGIN_B);
66 67
67 private: 68 private:
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 std::unique_ptr<FeaturePolicy> policy1 = 125 std::unique_ptr<FeaturePolicy> policy1 =
125 createFromParentPolicy(nullptr, m_originA); 126 createFromParentPolicy(nullptr, m_originA);
126 policy1->setHeaderPolicy(FeaturePolicy::parseFeaturePolicy( 127 policy1->setHeaderPolicy(FeaturePolicy::parseFeaturePolicy(
127 "{\"default-on\": []}", m_originA.get(), &messages)); 128 "{\"default-on\": []}", m_originA.get(), &messages));
128 EXPECT_EQ(0UL, messages.size()); 129 EXPECT_EQ(0UL, messages.size());
129 document().setFeaturePolicyForTesting(std::move(policy1)); 130 document().setFeaturePolicyForTesting(std::move(policy1));
130 EXPECT_TRUE(isFeatureEnabledInFrame(kDefaultOnFeature, frame())); 131 EXPECT_TRUE(isFeatureEnabledInFrame(kDefaultOnFeature, frame()));
131 } 132 }
132 133
133 } // namespace blink 134 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698