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