OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "core/html/HTMLIFrameElementAllow.h" | |
6 | |
7 #include "core/dom/Document.h" | |
8 #include "core/html/HTMLIFrameElement.h" | |
9 #include "testing/gmock/include/gmock/gmock.h" | |
10 #include "testing/gtest/include/gtest/gtest.h" | |
11 | |
12 using testing::UnorderedElementsAre; | |
13 | |
14 namespace blink { | |
15 | |
16 TEST(HTMLIFrameElementAllowTest, ParseAllowedFeatureNamesValid) { | |
Rick Byers
2017/02/09 20:59:59
We're going to (eventually) need a web-platform-te
lunalu1
2017/02/09 23:19:04
Yes, I was planning to do the layout tests (I mean
Rick Byers
2017/02/10 22:09:20
Ok SGTM. Maybe just add a "// TODO(lunalu) Move t
| |
17 Document* document = Document::create(); | |
18 HTMLIFrameElement* iframe = HTMLIFrameElement::create(*document); | |
19 HTMLIFrameElementAllow* allow = HTMLIFrameElementAllow::create(iframe); | |
20 String errorMessage; | |
21 HashSet<WebFeaturePolicyFeature> result; | |
22 | |
23 allow->setValue(""); | |
24 result = allow->parseAllowedFeatureNames(errorMessage); | |
25 EXPECT_TRUE(result.isEmpty()); | |
26 | |
27 allow->setValue("fullscreen"); | |
28 result = allow->parseAllowedFeatureNames(errorMessage); | |
29 EXPECT_THAT(result, | |
30 UnorderedElementsAre(WebFeaturePolicyFeature::Fullscreen)); | |
31 | |
32 allow->setValue("fullscreen payment vibrate"); | |
33 result = allow->parseAllowedFeatureNames(errorMessage); | |
34 EXPECT_THAT(result, UnorderedElementsAre(WebFeaturePolicyFeature::Fullscreen, | |
35 WebFeaturePolicyFeature::Payment, | |
36 WebFeaturePolicyFeature::Vibrate)); | |
37 } | |
38 | |
39 TEST(HTMLIFrameElementAllowTest, ParseAllowedFeatureNamesInvalid) { | |
40 Document* document = Document::create(); | |
41 HTMLIFrameElement* iframe = HTMLIFrameElement::create(*document); | |
42 HTMLIFrameElementAllow* allow = HTMLIFrameElementAllow::create(iframe); | |
43 String errorMessage; | |
44 HashSet<WebFeaturePolicyFeature> result; | |
45 | |
46 allow->setValue("invalid"); | |
47 result = allow->parseAllowedFeatureNames(errorMessage); | |
48 EXPECT_TRUE(result.isEmpty()); | |
49 EXPECT_EQ("'invalid' is an invalid feature name.", errorMessage); | |
50 | |
51 allow->setValue("fullscreen invalid1 invalid2"); | |
52 result = allow->parseAllowedFeatureNames(errorMessage); | |
53 EXPECT_THAT(result, | |
54 UnorderedElementsAre(WebFeaturePolicyFeature::Fullscreen)); | |
55 EXPECT_EQ("'invalid1', 'invalid2' are invalid feature names.", errorMessage); | |
56 | |
57 allow->setValue("fullscreen invalid vibrate fullscreen"); | |
58 result = allow->parseAllowedFeatureNames(errorMessage); | |
59 EXPECT_EQ("'invalid' is an invalid feature name.", errorMessage); | |
60 EXPECT_THAT(result, UnorderedElementsAre(WebFeaturePolicyFeature::Fullscreen, | |
61 WebFeaturePolicyFeature::Vibrate)); | |
62 } | |
63 | |
64 } // namespace blink | |
OLD | NEW |