OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/base64.h" | 8 #include "base/base64.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 base::DictionaryValue* cookie; | 1480 base::DictionaryValue* cookie; |
1481 std::string name; | 1481 std::string name; |
1482 std::string value; | 1482 std::string value; |
1483 EXPECT_TRUE(cookies->GetDictionary(0, &cookie)); | 1483 EXPECT_TRUE(cookies->GetDictionary(0, &cookie)); |
1484 EXPECT_TRUE(cookie->GetString("name", &name)); | 1484 EXPECT_TRUE(cookie->GetString("name", &name)); |
1485 EXPECT_TRUE(cookie->GetString("value", &value)); | 1485 EXPECT_TRUE(cookie->GetString("value", &value)); |
1486 EXPECT_EQ("cookie_for_this_url", name); | 1486 EXPECT_EQ("cookie_for_this_url", name); |
1487 EXPECT_EQ("mendacious", value); | 1487 EXPECT_EQ("mendacious", value); |
1488 | 1488 |
1489 // Then get all the cookies in the cookie jar. | 1489 // Then get all the cookies in the cookie jar. |
1490 command_params.reset(new base::DictionaryValue()); | 1490 SendCommand("Network.getAllCookies", nullptr, true); |
1491 command_params->SetBoolean("global", true); | |
1492 SendCommand("Network.getCookies", std::move(command_params), true); | |
1493 | 1491 |
1494 EXPECT_TRUE(result_->HasKey("cookies")); | 1492 EXPECT_TRUE(result_->HasKey("cookies")); |
1495 EXPECT_TRUE(result_->GetList("cookies", &cookies)); | 1493 EXPECT_TRUE(result_->GetList("cookies", &cookies)); |
1496 EXPECT_EQ(2u, cookies->GetSize()); | 1494 EXPECT_EQ(2u, cookies->GetSize()); |
1497 | 1495 |
1498 // Note: the cookies will be returned in unspecified order. | 1496 // Note: the cookies will be returned in unspecified order. |
1499 size_t found = 0; | 1497 size_t found = 0; |
1500 for (size_t i = 0; i < cookies->GetSize(); i++) { | 1498 for (size_t i = 0; i < cookies->GetSize(); i++) { |
1501 EXPECT_TRUE(cookies->GetDictionary(i, &cookie)); | 1499 EXPECT_TRUE(cookies->GetDictionary(i, &cookie)); |
1502 EXPECT_TRUE(cookie->GetString("name", &name)); | 1500 EXPECT_TRUE(cookie->GetString("name", &name)); |
1503 if (name == "cookie_for_this_url") { | 1501 if (name == "cookie_for_this_url") { |
1504 EXPECT_TRUE(cookie->GetString("value", &value)); | 1502 EXPECT_TRUE(cookie->GetString("value", &value)); |
1505 EXPECT_EQ("mendacious", value); | 1503 EXPECT_EQ("mendacious", value); |
1506 found++; | 1504 found++; |
1507 } else if (name == "cookie_for_another_url") { | 1505 } else if (name == "cookie_for_another_url") { |
1508 EXPECT_TRUE(cookie->GetString("value", &value)); | 1506 EXPECT_TRUE(cookie->GetString("value", &value)); |
1509 EXPECT_EQ("polyglottal", value); | 1507 EXPECT_EQ("polyglottal", value); |
1510 found++; | 1508 found++; |
1511 } else { | 1509 } else { |
1512 FAIL(); | 1510 FAIL(); |
1513 } | 1511 } |
1514 } | 1512 } |
1515 EXPECT_EQ(2u, found); | 1513 EXPECT_EQ(2u, found); |
1516 } | 1514 } |
1517 | 1515 |
1518 } // namespace content | 1516 } // namespace content |
OLD | NEW |