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; | |
1489 TestURLRequestContext context; | |
1490 const char* sensitive_urls[] = { | 1488 const char* sensitive_urls[] = { |
1491 "http://www.google.com/chrome", | 1489 "http://www.google.com/chrome", |
1492 "https://www.google.com/chrome", | 1490 "https://www.google.com/chrome", |
1493 "http://www.google.com/chrome/foobar", | 1491 "http://www.google.com/chrome/foobar", |
1494 "https://www.google.com/chrome/foobar", | 1492 "https://www.google.com/chrome/foobar", |
1495 "http://chrome.google.com", | 1493 "http://chrome.google.com", |
1496 "https://chrome.google.com", | 1494 "https://chrome.google.com", |
1497 "http://client2.google.com", | 1495 "http://client2.google.com", |
1498 "https://client2.google.com", | 1496 "https://client2.google.com", |
1499 // No http version of webstore. | 1497 // No http version of webstore. |
1500 "https://chrome.google.com/webstore", | 1498 "https://chrome.google.com/webstore", |
1501 "http://clients2.google.com/service/update2/crx", | 1499 "http://clients2.google.com/service/update2/crx", |
1502 "https://clients2.google.com/service/update2/crx", | 1500 "https://clients2.google.com/service/update2/crx", |
1503 "http://www.gstatic.com/chrome/extensions/blacklist", | 1501 "http://www.gstatic.com/chrome/extensions/blacklist", |
1504 "https://www.gstatic.com/chrome/extensions/blacklist", | 1502 "https://www.gstatic.com/chrome/extensions/blacklist", |
1505 "notregisteredscheme://www.foobar.com" | 1503 "notregisteredscheme://www.foobar.com" |
1506 }; | 1504 }; |
1507 const char* non_sensitive_urls[] = { | 1505 const char* non_sensitive_urls[] = { |
1508 "http://www.google.com/" | 1506 "http://www.google.com/" |
1509 }; | 1507 }; |
1510 // Check that requests are rejected based on the destination | |
1511 for (size_t i = 0; i < arraysize(sensitive_urls); ++i) { | 1508 for (size_t i = 0; i < arraysize(sensitive_urls); ++i) { |
1512 GURL sensitive_url(sensitive_urls[i]); | 1509 EXPECT_TRUE(helpers::HideRequestForURL(GURL(sensitive_urls[i]))) |
1513 TestURLRequest request(sensitive_url, NULL, &context); | 1510 << sensitive_urls[i]; |
1514 EXPECT_TRUE(helpers::HideRequest(&request)) << sensitive_urls[i]; | |
1515 } | 1511 } |
1516 // Check that requests are accepted if they don't touch sensitive urls. | |
1517 for (size_t i = 0; i < arraysize(non_sensitive_urls); ++i) { | 1512 for (size_t i = 0; i < arraysize(non_sensitive_urls); ++i) { |
1518 GURL non_sensitive_url(non_sensitive_urls[i]); | 1513 EXPECT_FALSE(helpers::HideRequestForURL(GURL(non_sensitive_urls[i]))) |
1519 TestURLRequest request(non_sensitive_url, NULL, &context); | 1514 << non_sensitive_urls[i]; |
1520 EXPECT_FALSE(helpers::HideRequest(&request)) << non_sensitive_urls[i]; | |
1521 } | |
1522 // Check that requests are rejected if their first party url is sensitive. | |
1523 ASSERT_GE(arraysize(non_sensitive_urls), 1u); | |
1524 GURL non_sensitive_url(non_sensitive_urls[0]); | |
1525 for (size_t i = 0; i < arraysize(sensitive_urls); ++i) { | |
1526 TestURLRequest request(non_sensitive_url, NULL, &context); | |
1527 GURL sensitive_url(sensitive_urls[i]); | |
1528 request.set_first_party_for_cookies(sensitive_url); | |
1529 EXPECT_TRUE(helpers::HideRequest(&request)) << sensitive_urls[i]; | |
1530 } | 1515 } |
1531 } | 1516 } |
OLD | NEW |