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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLIFrameElementAllowTest.cpp

Issue 2680083002: Initial Implementation of Iframe Attribute for Feature Policy (Part 1) (Closed)
Patch Set: Moved hash function for WebFeaturePolicyFeature to where the enum is defined for ODR purpose 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
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698