Ignore Set-Cookie Directive where both name and value are empty

BUG=392295

Review URL: https://codereview.chromium.org/405233004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285932 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/net/cookies/parsed_cookie_unittest.cc b/net/cookies/parsed_cookie_unittest.cc
index 23e3768a..0f571551 100644
--- a/net/cookies/parsed_cookie_unittest.cc
+++ b/net/cookies/parsed_cookie_unittest.cc
@@ -18,6 +18,21 @@
   EXPECT_EQ("b", pc.Value());
 }
 
+TEST(ParsedCookieTest, TestEmpty) {
+  ParsedCookie pc1("=; path=/; secure;");
+  EXPECT_FALSE(pc1.IsValid());
+  ParsedCookie pc2("= ; path=/; secure;");
+  EXPECT_FALSE(pc2.IsValid());
+  ParsedCookie pc3(" =; path=/; secure;");
+  EXPECT_FALSE(pc3.IsValid());
+  ParsedCookie pc4(" = ; path=/; secure;");
+  EXPECT_FALSE(pc4.IsValid());
+  ParsedCookie pc5(" ; path=/; secure;");
+  EXPECT_FALSE(pc5.IsValid());
+  ParsedCookie pc6("; path=/; secure;");
+  EXPECT_FALSE(pc6.IsValid());
+}
+
 TEST(ParsedCookieTest, TestQuoted) {
   // These are some quoting cases which the major browsers all
   // handle differently.  I've tested Internet Explorer 6, Opera 9.6,
@@ -184,13 +199,13 @@
 
 TEST(ParsedCookieTest, TooManyPairs) {
   std::string blankpairs;
-  blankpairs.resize(ParsedCookie::kMaxPairs - 1, ';');
+  blankpairs.resize(ParsedCookie::kMaxPairs - 2, ';');
 
-  ParsedCookie pc1(blankpairs + "secure");
+  ParsedCookie pc1("a=b;" + blankpairs + "secure");
   EXPECT_TRUE(pc1.IsValid());
   EXPECT_TRUE(pc1.IsSecure());
 
-  ParsedCookie pc2(blankpairs + ";secure");
+  ParsedCookie pc2("a=b;" + blankpairs + ";secure");
   EXPECT_TRUE(pc2.IsValid());
   EXPECT_FALSE(pc2.IsSecure());
 }