OLD | NEW |
| (Empty) |
1 // Copyright 2015 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 "config.h" | |
6 #include "core/html/DOMFormData.h" | |
7 | |
8 #include "core/html/FormDataList.h" | |
9 #include <gtest/gtest.h> | |
10 | |
11 namespace blink { | |
12 | |
13 TEST(DOMFormDataTest, opacityGet) | |
14 { | |
15 DOMFormData* fd = DOMFormData::create(UTF8Encoding()); | |
16 fd->append("name1", "value1"); | |
17 | |
18 FileOrUSVString result; | |
19 fd->get("name1", result); | |
20 EXPECT_TRUE(result.isUSVString()); | |
21 EXPECT_EQ("value1", result.getAsUSVString()); | |
22 | |
23 const FormDataList::Item& entry = fd->items()[0]; | |
24 EXPECT_STREQ("name1", entry.key().data()); | |
25 EXPECT_STREQ("value1", entry.data().data()); | |
26 | |
27 fd->makeOpaque(); | |
28 | |
29 // Web-exposed interface should be opaque. | |
30 FileOrUSVString opaqueResult; | |
31 fd->get("name1", opaqueResult); | |
32 EXPECT_TRUE(opaqueResult.isNull()); | |
33 | |
34 // Internal interface should be uneffected. | |
35 const FormDataList::Item& entry2 = fd->items()[0]; | |
36 EXPECT_STREQ("name1", entry2.key().data()); | |
37 EXPECT_STREQ("value1", entry2.data().data()); | |
38 } | |
39 | |
40 TEST(DOMFormDataTest, opacityGetAll) | |
41 { | |
42 DOMFormData* fd = DOMFormData::create(UTF8Encoding()); | |
43 fd->append("name1", "value1"); | |
44 | |
45 HeapVector<FormDataEntryValue> results = fd->getAll("name1"); | |
46 EXPECT_EQ(1u, results.size()); | |
47 EXPECT_TRUE(results[0].isUSVString()); | |
48 EXPECT_EQ("value1", results[0].getAsUSVString()); | |
49 | |
50 EXPECT_EQ(1u, fd->size()); | |
51 | |
52 fd->makeOpaque(); | |
53 | |
54 // Web-exposed interface should be opaque. | |
55 results = fd->getAll("name1"); | |
56 EXPECT_EQ(0u, results.size()); | |
57 | |
58 // Internal interface should be uneffected. | |
59 EXPECT_EQ(1u, fd->size()); | |
60 } | |
61 | |
62 TEST(DOMFormDataTest, opacityHas) | |
63 { | |
64 DOMFormData* fd = DOMFormData::create(UTF8Encoding()); | |
65 fd->append("name1", "value1"); | |
66 | |
67 EXPECT_TRUE(fd->has("name1")); | |
68 EXPECT_EQ(1u, fd->size()); | |
69 | |
70 fd->makeOpaque(); | |
71 | |
72 // Web-exposed interface should be opaque. | |
73 EXPECT_FALSE(fd->has("name1")); | |
74 | |
75 // Internal collection should be uneffected. | |
76 EXPECT_EQ(1u, fd->size()); | |
77 } | |
78 | |
79 } // namespace blink | |
OLD | NEW |