| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "core/html/HTMLIFrameElementAllow.h" | 5 #include "core/html/HTMLIFrameElementAllow.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/html/HTMLIFrameElement.h" | 8 #include "core/html/HTMLIFrameElement.h" |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 allow->setValue(""); | 23 allow->setValue(""); |
| 24 result = allow->ParseAllowedFeatureNames(error_message); | 24 result = allow->ParseAllowedFeatureNames(error_message); |
| 25 EXPECT_TRUE(result.IsEmpty()); | 25 EXPECT_TRUE(result.IsEmpty()); |
| 26 | 26 |
| 27 allow->setValue("fullscreen"); | 27 allow->setValue("fullscreen"); |
| 28 result = allow->ParseAllowedFeatureNames(error_message); | 28 result = allow->ParseAllowedFeatureNames(error_message); |
| 29 EXPECT_THAT(result, | 29 EXPECT_THAT(result, |
| 30 UnorderedElementsAre(WebFeaturePolicyFeature::kFullscreen)); | 30 UnorderedElementsAre(WebFeaturePolicyFeature::kFullscreen)); |
| 31 | 31 |
| 32 allow->setValue("fullscreen payment vibrate"); | 32 allow->setValue("fullscreen payment"); |
| 33 result = allow->ParseAllowedFeatureNames(error_message); | 33 result = allow->ParseAllowedFeatureNames(error_message); |
| 34 EXPECT_THAT(result, UnorderedElementsAre(WebFeaturePolicyFeature::kFullscreen, | 34 EXPECT_THAT(result, UnorderedElementsAre(WebFeaturePolicyFeature::kFullscreen, |
| 35 WebFeaturePolicyFeature::kPayment, | 35 WebFeaturePolicyFeature::kPayment)); |
| 36 WebFeaturePolicyFeature::kVibrate)); | |
| 37 } | 36 } |
| 38 | 37 |
| 39 TEST(HTMLIFrameElementAllowTest, ParseAllowedFeatureNamesInvalid) { | 38 TEST(HTMLIFrameElementAllowTest, ParseAllowedFeatureNamesInvalid) { |
| 40 Document* document = Document::Create(); | 39 Document* document = Document::Create(); |
| 41 HTMLIFrameElement* iframe = HTMLIFrameElement::Create(*document); | 40 HTMLIFrameElement* iframe = HTMLIFrameElement::Create(*document); |
| 42 HTMLIFrameElementAllow* allow = HTMLIFrameElementAllow::Create(iframe); | 41 HTMLIFrameElementAllow* allow = HTMLIFrameElementAllow::Create(iframe); |
| 43 String error_message; | 42 String error_message; |
| 44 Vector<WebFeaturePolicyFeature> result; | 43 Vector<WebFeaturePolicyFeature> result; |
| 45 | 44 |
| 46 allow->setValue("invalid"); | 45 allow->setValue("invalid"); |
| 47 result = allow->ParseAllowedFeatureNames(error_message); | 46 result = allow->ParseAllowedFeatureNames(error_message); |
| 48 EXPECT_TRUE(result.IsEmpty()); | 47 EXPECT_TRUE(result.IsEmpty()); |
| 49 EXPECT_EQ("'invalid' is an invalid feature name.", error_message); | 48 EXPECT_EQ("'invalid' is an invalid feature name.", error_message); |
| 50 | 49 |
| 51 allow->setValue("fullscreen invalid1 invalid2"); | 50 allow->setValue("fullscreen invalid1 invalid2"); |
| 52 result = allow->ParseAllowedFeatureNames(error_message); | 51 result = allow->ParseAllowedFeatureNames(error_message); |
| 53 EXPECT_THAT(result, | 52 EXPECT_THAT(result, |
| 54 UnorderedElementsAre(WebFeaturePolicyFeature::kFullscreen)); | 53 UnorderedElementsAre(WebFeaturePolicyFeature::kFullscreen)); |
| 55 EXPECT_EQ("'invalid1', 'invalid2' are invalid feature names.", error_message); | 54 EXPECT_EQ("'invalid1', 'invalid2' are invalid feature names.", error_message); |
| 56 | 55 |
| 57 allow->setValue("fullscreen invalid vibrate fullscreen"); | 56 allow->setValue("fullscreen invalid payment fullscreen"); |
| 58 result = allow->ParseAllowedFeatureNames(error_message); | 57 result = allow->ParseAllowedFeatureNames(error_message); |
| 59 EXPECT_EQ("'invalid' is an invalid feature name.", error_message); | 58 EXPECT_EQ("'invalid' is an invalid feature name.", error_message); |
| 60 EXPECT_THAT(result, UnorderedElementsAre(WebFeaturePolicyFeature::kFullscreen, | 59 EXPECT_THAT(result, UnorderedElementsAre(WebFeaturePolicyFeature::kFullscreen, |
| 61 WebFeaturePolicyFeature::kVibrate)); | 60 WebFeaturePolicyFeature::kPayment)); |
| 62 } | 61 } |
| 63 | 62 |
| 64 } // namespace blink | 63 } // namespace blink |
| OLD | NEW |