| 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 13 matching lines...) Expand all Loading... |
| 24 result = allow->parseAllowedFeatureNames(errorMessage); | 24 result = allow->parseAllowedFeatureNames(errorMessage); |
| 25 EXPECT_TRUE(result.isEmpty()); | 25 EXPECT_TRUE(result.isEmpty()); |
| 26 | 26 |
| 27 allow->setValue("fullscreen"); | 27 allow->setValue("fullscreen"); |
| 28 result = allow->parseAllowedFeatureNames(errorMessage); | 28 result = allow->parseAllowedFeatureNames(errorMessage); |
| 29 EXPECT_THAT(result, | 29 EXPECT_THAT(result, |
| 30 UnorderedElementsAre(WebFeaturePolicyFeature::Fullscreen)); | 30 UnorderedElementsAre(WebFeaturePolicyFeature::Fullscreen)); |
| 31 | 31 |
| 32 allow->setValue("fullscreen payment vibrate"); | 32 allow->setValue("fullscreen payment vibrate"); |
| 33 result = allow->parseAllowedFeatureNames(errorMessage); | 33 result = allow->parseAllowedFeatureNames(errorMessage); |
| 34 EXPECT_THAT(result, UnorderedElementsAre(WebFeaturePolicyFeature::Fullscreen, | 34 EXPECT_THAT(result, |
| 35 WebFeaturePolicyFeature::Payment, | 35 UnorderedElementsAre(WebFeaturePolicyFeature::Fullscreen, |
| 36 WebFeaturePolicyFeature::Vibrate)); | 36 WebFeaturePolicyFeature::Payment, |
| 37 WebFeaturePolicyFeature::Vibrate)); |
| 37 } | 38 } |
| 38 | 39 |
| 39 TEST(HTMLIFrameElementAllowTest, ParseAllowedFeatureNamesInvalid) { | 40 TEST(HTMLIFrameElementAllowTest, ParseAllowedFeatureNamesInvalid) { |
| 40 Document* document = Document::create(); | 41 Document* document = Document::create(); |
| 41 HTMLIFrameElement* iframe = HTMLIFrameElement::create(*document); | 42 HTMLIFrameElement* iframe = HTMLIFrameElement::create(*document); |
| 42 HTMLIFrameElementAllow* allow = HTMLIFrameElementAllow::create(iframe); | 43 HTMLIFrameElementAllow* allow = HTMLIFrameElementAllow::create(iframe); |
| 43 String errorMessage; | 44 String errorMessage; |
| 44 Vector<WebFeaturePolicyFeature> result; | 45 Vector<WebFeaturePolicyFeature> result; |
| 45 | 46 |
| 46 allow->setValue("invalid"); | 47 allow->setValue("invalid"); |
| 47 result = allow->parseAllowedFeatureNames(errorMessage); | 48 result = allow->parseAllowedFeatureNames(errorMessage); |
| 48 EXPECT_TRUE(result.isEmpty()); | 49 EXPECT_TRUE(result.isEmpty()); |
| 49 EXPECT_EQ("'invalid' is an invalid feature name.", errorMessage); | 50 EXPECT_EQ("'invalid' is an invalid feature name.", errorMessage); |
| 50 | 51 |
| 51 allow->setValue("fullscreen invalid1 invalid2"); | 52 allow->setValue("fullscreen invalid1 invalid2"); |
| 52 result = allow->parseAllowedFeatureNames(errorMessage); | 53 result = allow->parseAllowedFeatureNames(errorMessage); |
| 53 EXPECT_THAT(result, | 54 EXPECT_THAT(result, |
| 54 UnorderedElementsAre(WebFeaturePolicyFeature::Fullscreen)); | 55 UnorderedElementsAre(WebFeaturePolicyFeature::Fullscreen)); |
| 55 EXPECT_EQ("'invalid1', 'invalid2' are invalid feature names.", errorMessage); | 56 EXPECT_EQ("'invalid1', 'invalid2' are invalid feature names.", errorMessage); |
| 56 | 57 |
| 57 allow->setValue("fullscreen invalid vibrate fullscreen"); | 58 allow->setValue("fullscreen invalid vibrate fullscreen"); |
| 58 result = allow->parseAllowedFeatureNames(errorMessage); | 59 result = allow->parseAllowedFeatureNames(errorMessage); |
| 59 EXPECT_EQ("'invalid' is an invalid feature name.", errorMessage); | 60 EXPECT_EQ("'invalid' is an invalid feature name.", errorMessage); |
| 60 EXPECT_THAT(result, UnorderedElementsAre(WebFeaturePolicyFeature::Fullscreen, | 61 EXPECT_THAT(result, |
| 61 WebFeaturePolicyFeature::Vibrate)); | 62 UnorderedElementsAre(WebFeaturePolicyFeature::Fullscreen, |
| 63 WebFeaturePolicyFeature::Vibrate)); |
| 62 } | 64 } |
| 63 | 65 |
| 64 } // namespace blink | 66 } // namespace blink |
| OLD | NEW |