OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "net/cookies/cookie_constants.h" | 7 #include "net/cookies/cookie_constants.h" |
8 #include "net/cookies/parsed_cookie.h" | 8 #include "net/cookies/parsed_cookie.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 EXPECT_FALSE(pc5.IsValid()); | 31 EXPECT_FALSE(pc5.IsValid()); |
32 ParsedCookie pc6("; path=/; secure;"); | 32 ParsedCookie pc6("; path=/; secure;"); |
33 EXPECT_FALSE(pc6.IsValid()); | 33 EXPECT_FALSE(pc6.IsValid()); |
34 } | 34 } |
35 | 35 |
36 TEST(ParsedCookieTest, TestQuoted) { | 36 TEST(ParsedCookieTest, TestQuoted) { |
37 // These are some quoting cases which the major browsers all | 37 // These are some quoting cases which the major browsers all |
38 // handle differently. I've tested Internet Explorer 6, Opera 9.6, | 38 // handle differently. I've tested Internet Explorer 6, Opera 9.6, |
39 // Firefox 3, and Safari Windows 3.2.1. We originally tried to match | 39 // Firefox 3, and Safari Windows 3.2.1. We originally tried to match |
40 // Firefox closely, however we now match Internet Explorer and Safari. | 40 // Firefox closely, however we now match Internet Explorer and Safari. |
41 const char* values[] = { | 41 const char* const values[] = { |
42 // Trailing whitespace after a quoted value. The whitespace after | 42 // Trailing whitespace after a quoted value. The whitespace after |
43 // the quote is stripped in all browsers. | 43 // the quote is stripped in all browsers. |
44 "\"zzz \" ", "\"zzz \"", | 44 "\"zzz \" ", "\"zzz \"", |
45 // Handling a quoted value with a ';', like FOO="zz;pp" ; | 45 // Handling a quoted value with a ';', like FOO="zz;pp" ; |
46 // IE and Safari: "zz; | 46 // IE and Safari: "zz; |
47 // Firefox and Opera: "zz;pp" | 47 // Firefox and Opera: "zz;pp" |
48 "\"zz;pp\" ;", "\"zz", | 48 "\"zz;pp\" ;", "\"zz", |
49 // Handling a value with multiple quoted parts, like FOO="zzz " "ppp" ; | 49 // Handling a value with multiple quoted parts, like FOO="zzz " "ppp" ; |
50 // IE and Safari: "zzz " "ppp"; | 50 // IE and Safari: "zzz " "ppp"; |
51 // Firefox: "zzz "; | 51 // Firefox: "zzz "; |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 EXPECT_FALSE(pc8.IsValid()); | 464 EXPECT_FALSE(pc8.IsValid()); |
465 EXPECT_FALSE(pc9.IsValid()); | 465 EXPECT_FALSE(pc9.IsValid()); |
466 EXPECT_FALSE(pc10.IsValid()); | 466 EXPECT_FALSE(pc10.IsValid()); |
467 EXPECT_FALSE(pc11.IsValid()); | 467 EXPECT_FALSE(pc11.IsValid()); |
468 EXPECT_FALSE(pc12.IsValid()); | 468 EXPECT_FALSE(pc12.IsValid()); |
469 } | 469 } |
470 | 470 |
471 TEST(ParsedCookieTest, ValidNonAlphanumericChars) { | 471 TEST(ParsedCookieTest, ValidNonAlphanumericChars) { |
472 // Note that some of these words are pasted backwords thanks to poor vim bidi | 472 // Note that some of these words are pasted backwords thanks to poor vim bidi |
473 // support. This should not affect the tests, however. | 473 // support. This should not affect the tests, however. |
474 const char* pc1_literal = "name=العربية"; | 474 const char pc1_literal[] = "name=العربية"; |
475 const char* pc2_literal = "name=普通話"; | 475 const char pc2_literal[] = "name=普通話"; |
476 const char* pc3_literal = "name=ภาษาไทย"; | 476 const char pc3_literal[] = "name=ภาษาไทย"; |
477 const char* pc4_literal = "name=עִבְרִית"; | 477 const char pc4_literal[] = "name=עִבְרִית"; |
478 const char* pc5_literal = "العربية=value"; | 478 const char pc5_literal[] = "العربية=value"; |
479 const char* pc6_literal = "普通話=value"; | 479 const char pc6_literal[] = "普通話=value"; |
480 const char* pc7_literal = "ภาษาไทย=value"; | 480 const char pc7_literal[] = "ภาษาไทย=value"; |
481 const char* pc8_literal = "עִבְרִית=value"; | 481 const char pc8_literal[] = "עִבְרִית=value"; |
482 ParsedCookie pc1(pc1_literal); | 482 ParsedCookie pc1(pc1_literal); |
483 ParsedCookie pc2(pc2_literal); | 483 ParsedCookie pc2(pc2_literal); |
484 ParsedCookie pc3(pc3_literal); | 484 ParsedCookie pc3(pc3_literal); |
485 ParsedCookie pc4(pc4_literal); | 485 ParsedCookie pc4(pc4_literal); |
486 ParsedCookie pc5(pc5_literal); | 486 ParsedCookie pc5(pc5_literal); |
487 ParsedCookie pc6(pc6_literal); | 487 ParsedCookie pc6(pc6_literal); |
488 ParsedCookie pc7(pc7_literal); | 488 ParsedCookie pc7(pc7_literal); |
489 ParsedCookie pc8(pc8_literal); | 489 ParsedCookie pc8(pc8_literal); |
490 | 490 |
491 EXPECT_TRUE(pc1.IsValid()); | 491 EXPECT_TRUE(pc1.IsValid()); |
492 EXPECT_EQ(pc1_literal, pc1.ToCookieLine()); | 492 EXPECT_EQ(pc1_literal, pc1.ToCookieLine()); |
493 EXPECT_TRUE(pc2.IsValid()); | 493 EXPECT_TRUE(pc2.IsValid()); |
494 EXPECT_EQ(pc2_literal, pc2.ToCookieLine()); | 494 EXPECT_EQ(pc2_literal, pc2.ToCookieLine()); |
495 EXPECT_TRUE(pc3.IsValid()); | 495 EXPECT_TRUE(pc3.IsValid()); |
496 EXPECT_EQ(pc3_literal, pc3.ToCookieLine()); | 496 EXPECT_EQ(pc3_literal, pc3.ToCookieLine()); |
497 EXPECT_TRUE(pc4.IsValid()); | 497 EXPECT_TRUE(pc4.IsValid()); |
498 EXPECT_EQ(pc4_literal, pc4.ToCookieLine()); | 498 EXPECT_EQ(pc4_literal, pc4.ToCookieLine()); |
499 EXPECT_TRUE(pc5.IsValid()); | 499 EXPECT_TRUE(pc5.IsValid()); |
500 EXPECT_EQ(pc5_literal, pc5.ToCookieLine()); | 500 EXPECT_EQ(pc5_literal, pc5.ToCookieLine()); |
501 EXPECT_TRUE(pc6.IsValid()); | 501 EXPECT_TRUE(pc6.IsValid()); |
502 EXPECT_EQ(pc6_literal, pc6.ToCookieLine()); | 502 EXPECT_EQ(pc6_literal, pc6.ToCookieLine()); |
503 EXPECT_TRUE(pc7.IsValid()); | 503 EXPECT_TRUE(pc7.IsValid()); |
504 EXPECT_EQ(pc7_literal, pc7.ToCookieLine()); | 504 EXPECT_EQ(pc7_literal, pc7.ToCookieLine()); |
505 EXPECT_TRUE(pc8.IsValid()); | 505 EXPECT_TRUE(pc8.IsValid()); |
506 EXPECT_EQ(pc8_literal, pc8.ToCookieLine()); | 506 EXPECT_EQ(pc8_literal, pc8.ToCookieLine()); |
507 } | 507 } |
508 | 508 |
509 } | 509 } |
OLD | NEW |