| 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 <queue> | 5 #include <queue> |
| 6 #include <map> | 6 #include <map> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1478 EXPECT_TRUE(credentials_set); | 1478 EXPECT_TRUE(credentials_set); |
| 1479 EXPECT_FALSE(auth3.Empty()); | 1479 EXPECT_FALSE(auth3.Empty()); |
| 1480 EXPECT_EQ(username, auth1.username()); | 1480 EXPECT_EQ(username, auth1.username()); |
| 1481 EXPECT_EQ(password, auth1.password()); | 1481 EXPECT_EQ(password, auth1.password()); |
| 1482 EXPECT_EQ(1u, conflicting_extensions.size()); | 1482 EXPECT_EQ(1u, conflicting_extensions.size()); |
| 1483 EXPECT_TRUE(ContainsKey(conflicting_extensions, "extid2")); | 1483 EXPECT_TRUE(ContainsKey(conflicting_extensions, "extid2")); |
| 1484 EXPECT_EQ(3u, event_log.size()); | 1484 EXPECT_EQ(3u, event_log.size()); |
| 1485 } | 1485 } |
| 1486 | 1486 |
| 1487 TEST(ExtensionWebRequestHelpersTest, TestHideRequestForURL) { | 1487 TEST(ExtensionWebRequestHelpersTest, TestHideRequestForURL) { |
| 1488 MessageLoopForIO message_loop; |
| 1488 const char* sensitive_urls[] = { | 1489 const char* sensitive_urls[] = { |
| 1489 "http://www.google.com/chrome", | 1490 "http://www.google.com/chrome", |
| 1490 "https://www.google.com/chrome", | 1491 "https://www.google.com/chrome", |
| 1491 "http://www.google.com/chrome/foobar", | 1492 "http://www.google.com/chrome/foobar", |
| 1492 "https://www.google.com/chrome/foobar", | 1493 "https://www.google.com/chrome/foobar", |
| 1493 "http://chrome.google.com", | 1494 "http://chrome.google.com", |
| 1494 "https://chrome.google.com", | 1495 "https://chrome.google.com", |
| 1495 "http://client2.google.com", | 1496 "http://client2.google.com", |
| 1496 "https://client2.google.com", | 1497 "https://client2.google.com", |
| 1497 // No http version of webstore. | 1498 // No http version of webstore. |
| 1498 "https://chrome.google.com/webstore", | 1499 "https://chrome.google.com/webstore", |
| 1499 "http://clients2.google.com/service/update2/crx", | 1500 "http://clients2.google.com/service/update2/crx", |
| 1500 "https://clients2.google.com/service/update2/crx", | 1501 "https://clients2.google.com/service/update2/crx", |
| 1501 "http://www.gstatic.com/chrome/extensions/blacklist", | 1502 "http://www.gstatic.com/chrome/extensions/blacklist", |
| 1502 "https://www.gstatic.com/chrome/extensions/blacklist", | 1503 "https://www.gstatic.com/chrome/extensions/blacklist", |
| 1503 "notregisteredscheme://www.foobar.com" | 1504 "notregisteredscheme://www.foobar.com" |
| 1504 }; | 1505 }; |
| 1505 const char* non_sensitive_urls[] = { | 1506 const char* non_sensitive_urls[] = { |
| 1506 "http://www.google.com/" | 1507 "http://www.google.com/" |
| 1507 }; | 1508 }; |
| 1509 // Check that requests are rejected based on the destination |
| 1508 for (size_t i = 0; i < arraysize(sensitive_urls); ++i) { | 1510 for (size_t i = 0; i < arraysize(sensitive_urls); ++i) { |
| 1509 EXPECT_TRUE(helpers::HideRequestForURL(GURL(sensitive_urls[i]))) | 1511 GURL sensitive_url(sensitive_urls[i]); |
| 1510 << sensitive_urls[i]; | 1512 TestURLRequest request(sensitive_url, NULL); |
| 1513 EXPECT_TRUE(helpers::HideRequest(&request)) << sensitive_urls[i]; |
| 1511 } | 1514 } |
| 1515 // Check that requests are accepted if they don't touch sensitive urls. |
| 1512 for (size_t i = 0; i < arraysize(non_sensitive_urls); ++i) { | 1516 for (size_t i = 0; i < arraysize(non_sensitive_urls); ++i) { |
| 1513 EXPECT_FALSE(helpers::HideRequestForURL(GURL(non_sensitive_urls[i]))) | 1517 GURL non_sensitive_url(non_sensitive_urls[i]); |
| 1514 << non_sensitive_urls[i]; | 1518 TestURLRequest request(non_sensitive_url, NULL); |
| 1519 EXPECT_FALSE(helpers::HideRequest(&request)) << non_sensitive_urls[i]; |
| 1520 } |
| 1521 // Check that requests are rejected if their first party url is sensitive. |
| 1522 ASSERT_GE(arraysize(non_sensitive_urls), 1u); |
| 1523 GURL non_sensitive_url(non_sensitive_urls[0]); |
| 1524 for (size_t i = 0; i < arraysize(sensitive_urls); ++i) { |
| 1525 TestURLRequest request(non_sensitive_url, NULL); |
| 1526 GURL sensitive_url(sensitive_urls[i]); |
| 1527 request.set_first_party_for_cookies(sensitive_url); |
| 1528 EXPECT_TRUE(helpers::HideRequest(&request)) << sensitive_urls[i]; |
| 1515 } | 1529 } |
| 1516 } | 1530 } |
| OLD | NEW |