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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/DOMFormData.cpp ('k') | Source/core/html/FormData.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/DOMFormDataTest.cpp
diff --git a/Source/core/html/DOMFormDataTest.cpp b/Source/core/html/DOMFormDataTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..524193f1274cffa26a5a61bd303d9396dfb90dc3
--- /dev/null
+++ b/Source/core/html/DOMFormDataTest.cpp
@@ -0,0 +1,77 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/html/DOMFormData.h"
+
+#include "core/html/FormDataList.h"
+#include <gtest/gtest.h>
+
+namespace blink {
+
+TEST(DOMFormDataTest, opacityGet)
+{
+ DOMFormData* fd = DOMFormData::create(UTF8Encoding());
+ fd->append("name1", "value1");
+
+ FileOrUSVString result;
+ fd->get("name1", result);
+ EXPECT_TRUE(result.isUSVString());
+ EXPECT_EQ("value1", result.getAsUSVString());
+
+ FormDataList::Entry entry = fd->getEntry("name1");
+ EXPECT_EQ("value1", entry.string());
+
+ fd->makeOpaque();
+
+ // Web-exposed interface should be opaque.
+ FileOrUSVString opaqueResult;
+ fd->get("name1", opaqueResult);
+ EXPECT_TRUE(opaqueResult.isNull());
+
+ // Internal interface should be uneffected.
+ FormDataList::Entry opaqueEntry = fd->getEntry("name1");
+ EXPECT_EQ("value1", opaqueEntry.string());
+}
+
+TEST(DOMFormDataTest, opacityGetAll)
+{
+ DOMFormData* fd = DOMFormData::create(UTF8Encoding());
+ fd->append("name1", "value1");
+
+ HeapVector<FormDataEntryValue> results = fd->getAll("name1");
+ EXPECT_EQ(1u, results.size());
+ EXPECT_TRUE(results[0].isUSVString());
+ EXPECT_EQ("value1", results[0].getAsUSVString());
+
+ EXPECT_EQ(1u, fd->size());
+
+ fd->makeOpaque();
+
+ // Web-exposed interface should be opaque.
+ results = fd->getAll("name1");
+ EXPECT_EQ(0u, results.size());
+
+ // Internal interface should be uneffected.
+ EXPECT_EQ(1u, fd->size());
+}
+
+TEST(DOMFormDataTest, opacityHas)
+{
+ DOMFormData* fd = DOMFormData::create(UTF8Encoding());
+ fd->append("name1", "value1");
+
+ EXPECT_TRUE(fd->has("name1"));
+ EXPECT_TRUE(fd->hasEntry("name1"));
+
+ fd->makeOpaque();
+
+ // Web-exposed interface should be opaque.
+ EXPECT_FALSE(fd->has("name1"));
+
+ // Internal interface should be uneffected.
+ EXPECT_TRUE(fd->hasEntry("name1"));
+}
+
+} // namespace blink
« 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