OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "config.h" | 5 #include "config.h" |
6 #include "core/html/DOMFormData.h" | 6 #include "core/html/DOMFormData.h" |
7 | 7 |
8 #include "core/html/FormDataList.h" | 8 #include "core/html/FormDataList.h" |
9 #include <gtest/gtest.h> | 9 #include <gtest/gtest.h> |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 TEST(DOMFormDataTest, opacityGet) | 13 TEST(DOMFormDataTest, opacityGet) |
14 { | 14 { |
15 DOMFormData* fd = DOMFormData::create(UTF8Encoding()); | 15 DOMFormData* fd = DOMFormData::create(UTF8Encoding()); |
16 fd->append("name1", "value1"); | 16 fd->append("name1", "value1"); |
17 | 17 |
18 FileOrUSVString result; | 18 FileOrUSVString result; |
19 fd->get("name1", result); | 19 fd->get("name1", result); |
20 EXPECT_TRUE(result.isUSVString()); | 20 EXPECT_TRUE(result.isUSVString()); |
21 EXPECT_EQ("value1", result.getAsUSVString()); | 21 EXPECT_EQ("value1", result.getAsUSVString()); |
22 | 22 |
23 FormDataList::Entry entry = fd->getEntry("name1"); | 23 const FormDataList::Item& entry = fd->items()[0]; |
24 EXPECT_EQ("value1", entry.string()); | 24 EXPECT_STREQ("name1", entry.key().data()); |
| 25 EXPECT_STREQ("value1", entry.data().data()); |
25 | 26 |
26 fd->makeOpaque(); | 27 fd->makeOpaque(); |
27 | 28 |
28 // Web-exposed interface should be opaque. | 29 // Web-exposed interface should be opaque. |
29 FileOrUSVString opaqueResult; | 30 FileOrUSVString opaqueResult; |
30 fd->get("name1", opaqueResult); | 31 fd->get("name1", opaqueResult); |
31 EXPECT_TRUE(opaqueResult.isNull()); | 32 EXPECT_TRUE(opaqueResult.isNull()); |
32 | 33 |
33 // Internal interface should be uneffected. | 34 // Internal interface should be uneffected. |
34 FormDataList::Entry opaqueEntry = fd->getEntry("name1"); | 35 const FormDataList::Item& entry2 = fd->items()[0]; |
35 EXPECT_EQ("value1", opaqueEntry.string()); | 36 EXPECT_STREQ("name1", entry2.key().data()); |
| 37 EXPECT_STREQ("value1", entry2.data().data()); |
36 } | 38 } |
37 | 39 |
38 TEST(DOMFormDataTest, opacityGetAll) | 40 TEST(DOMFormDataTest, opacityGetAll) |
39 { | 41 { |
40 DOMFormData* fd = DOMFormData::create(UTF8Encoding()); | 42 DOMFormData* fd = DOMFormData::create(UTF8Encoding()); |
41 fd->append("name1", "value1"); | 43 fd->append("name1", "value1"); |
42 | 44 |
43 HeapVector<FormDataEntryValue> results = fd->getAll("name1"); | 45 HeapVector<FormDataEntryValue> results = fd->getAll("name1"); |
44 EXPECT_EQ(1u, results.size()); | 46 EXPECT_EQ(1u, results.size()); |
45 EXPECT_TRUE(results[0].isUSVString()); | 47 EXPECT_TRUE(results[0].isUSVString()); |
(...skipping 22 matching lines...) Expand all Loading... |
68 fd->makeOpaque(); | 70 fd->makeOpaque(); |
69 | 71 |
70 // Web-exposed interface should be opaque. | 72 // Web-exposed interface should be opaque. |
71 EXPECT_FALSE(fd->has("name1")); | 73 EXPECT_FALSE(fd->has("name1")); |
72 | 74 |
73 // Internal collection should be uneffected. | 75 // Internal collection should be uneffected. |
74 EXPECT_EQ(1u, fd->size()); | 76 EXPECT_EQ(1u, fd->size()); |
75 } | 77 } |
76 | 78 |
77 } // namespace blink | 79 } // namespace blink |
OLD | NEW |