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

Side by Side Diff: Source/core/html/DOMFormDataTest.cpp

Issue 1323043002: Define "opaque" FormData objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Dropping makeOpaque again. Created 5 years, 3 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
« no previous file with comments | « Source/core/html/DOMFormData.cpp ('k') | Source/core/html/FormData.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 FormDataList::Entry entry = fd->getEntry("name1");
24 EXPECT_EQ("value1", entry.string());
25
26 fd->makeOpaque();
27
28 // Web-exposed interface should be opaque.
29 FileOrUSVString opaqueResult;
30 fd->get("name1", opaqueResult);
31 EXPECT_TRUE(opaqueResult.isNull());
32
33 // Internal interface should be uneffected.
34 FormDataList::Entry opaqueEntry = fd->getEntry("name1");
35 EXPECT_EQ("value1", opaqueEntry.string());
36 }
37
38 TEST(DOMFormDataTest, opacityGetAll)
39 {
40 DOMFormData* fd = DOMFormData::create(UTF8Encoding());
41 fd->append("name1", "value1");
42
43 HeapVector<FormDataEntryValue> results = fd->getAll("name1");
44 EXPECT_EQ(1u, results.size());
45 EXPECT_TRUE(results[0].isUSVString());
46 EXPECT_EQ("value1", results[0].getAsUSVString());
47
48 EXPECT_EQ(1u, fd->size());
49
50 fd->makeOpaque();
51
52 // Web-exposed interface should be opaque.
53 results = fd->getAll("name1");
54 EXPECT_EQ(0u, results.size());
55
56 // Internal interface should be uneffected.
57 EXPECT_EQ(1u, fd->size());
58 }
59
60 TEST(DOMFormDataTest, opacityHas)
61 {
62 DOMFormData* fd = DOMFormData::create(UTF8Encoding());
63 fd->append("name1", "value1");
64
65 EXPECT_TRUE(fd->has("name1"));
66 EXPECT_TRUE(fd->hasEntry("name1"));
67
68 fd->makeOpaque();
69
70 // Web-exposed interface should be opaque.
71 EXPECT_FALSE(fd->has("name1"));
72
73 // Internal interface should be uneffected.
74 EXPECT_TRUE(fd->hasEntry("name1"));
75 }
76
77 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/DOMFormData.cpp ('k') | Source/core/html/FormData.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698