Index: chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc |
diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc |
index 2fa6268a3a7b03e66386f9145ef24e6bf5c63da3..2e44bd4fb6dbbe3bf670c0a37153cee976938269 100644 |
--- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc |
+++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc |
@@ -28,7 +28,6 @@ TEST(WebRequestConditionTest, CreateCondition) { |
std::string error; |
scoped_ptr<WebRequestCondition> result; |
- |
// Test wrong condition name passed. |
error.clear(); |
result = WebRequestCondition::Create( |
@@ -62,6 +61,7 @@ TEST(WebRequestConditionTest, CreateCondition) { |
"{ \n" |
" \"resourceType\": [\"main_frame\"], \n" |
" \"url\": { \"hostSuffix\": \"example.com\" }, \n" |
+ " \"firstPartyForCookiesUrl\": { \"hostPrefix\": \"fpfc\"}, \n" |
" \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n" |
"}"), |
&error); |
@@ -71,29 +71,36 @@ TEST(WebRequestConditionTest, CreateCondition) { |
URLMatcherConditionSet::Vector url_matcher_condition_set; |
result->GetURLMatcherConditionSets(&url_matcher_condition_set); |
matcher.AddConditionSets(url_matcher_condition_set); |
- std::set<URLMatcherConditionSet::ID> url_match_ids; |
net::TestURLRequestContext context; |
GURL http_url("http://www.example.com"); |
+ GURL first_party_url("http://fpfc.example.com"); |
net::TestURLRequest match_request(http_url, NULL, &context); |
- url_match_ids = matcher.MatchURL(http_url); |
- EXPECT_EQ(1u, url_match_ids.size()); |
+ DeclarativeWebRequestData request_data(&match_request, ON_BEFORE_REQUEST); |
+ request_data.url_match_ids = matcher.MatchURL(http_url); |
+ EXPECT_EQ(1u, request_data.url_match_ids.size()); |
+ request_data.first_party_url_match_ids = matcher.MatchURL(first_party_url); |
+ EXPECT_EQ(1u, request_data.url_match_ids.size()); |
+ std::set<URLMatcherConditionSet::ID> url_match_ids( |
vabr (Chromium)
2013/01/22 14:54:30
This would go away if we got rid of the now-unused
|
+ request_data.url_match_ids); |
+ url_match_ids.insert(request_data.first_party_url_match_ids.begin(), |
+ request_data.first_party_url_match_ids.end()); |
content::ResourceRequestInfo::AllocateForTesting(&match_request, |
ResourceType::MAIN_FRAME, NULL, -1, -1); |
- EXPECT_TRUE(result->IsFulfilled( |
- url_match_ids, |
- DeclarativeWebRequestData(&match_request, ON_BEFORE_REQUEST))); |
+ EXPECT_TRUE(result->IsFulfilled(url_match_ids, request_data)); |
GURL https_url("https://www.example.com"); |
net::TestURLRequest wrong_resource_type(https_url, NULL, &context); |
- url_match_ids = matcher.MatchURL(https_url); |
+ request_data.request = &wrong_resource_type; |
+ request_data.url_match_ids = matcher.MatchURL(http_url); |
// Make sure IsFulfilled does not fail because of URL matching. |
- EXPECT_EQ(1u, url_match_ids.size()); |
+ EXPECT_EQ(1u, request_data.url_match_ids.size()); |
+ url_match_ids = request_data.url_match_ids; |
+ url_match_ids.insert(request_data.first_party_url_match_ids.begin(), |
+ request_data.first_party_url_match_ids.end()); |
content::ResourceRequestInfo::AllocateForTesting(&wrong_resource_type, |
ResourceType::SUB_FRAME, NULL, -1, -1); |
- EXPECT_FALSE(result->IsFulfilled( |
- url_match_ids, |
- DeclarativeWebRequestData(&wrong_resource_type, ON_BEFORE_REQUEST))); |
+ EXPECT_FALSE(result->IsFulfilled(url_match_ids, request_data)); |
} |
// Conditions without UrlFilter attributes need to be independent of URL |
@@ -219,29 +226,28 @@ TEST(WebRequestConditionTest, CreateConditionSet) { |
net::TestURLRequest http_request(http_url, NULL, &context); |
url_match_ids = matcher.MatchURL(http_url); |
EXPECT_EQ(1u, url_match_ids.size()); |
- EXPECT_TRUE(result->IsFulfilled( |
- *(url_match_ids.begin()), |
- url_match_ids, |
- DeclarativeWebRequestData(&http_request, ON_BEFORE_REQUEST))); |
+ DeclarativeWebRequestData request_data(&http_request, ON_BEFORE_REQUEST); |
+ request_data.url_match_ids = url_match_ids; |
+ EXPECT_TRUE(result->IsFulfilled(*(url_match_ids.begin()), url_match_ids, |
+ request_data)); |
GURL https_url("https://www.example.com"); |
url_match_ids = matcher.MatchURL(https_url); |
EXPECT_EQ(1u, url_match_ids.size()); |
net::TestURLRequest https_request(https_url, NULL, &context); |
- EXPECT_TRUE(result->IsFulfilled( |
- *(url_match_ids.begin()), |
- url_match_ids, |
- DeclarativeWebRequestData(&https_request, ON_BEFORE_REQUEST))); |
+ request_data.request = &https_request; |
+ request_data.url_match_ids = url_match_ids; |
+ EXPECT_TRUE(result->IsFulfilled(*(url_match_ids.begin()), url_match_ids, |
+ request_data)); |
// Check that both, hostPrefix and hostSuffix are evaluated. |
GURL https_foo_url("https://foo.example.com"); |
url_match_ids = matcher.MatchURL(https_foo_url); |
EXPECT_EQ(0u, url_match_ids.size()); |
net::TestURLRequest https_foo_request(https_foo_url, NULL, &context); |
- EXPECT_FALSE(result->IsFulfilled( |
- -1, |
- url_match_ids, |
- DeclarativeWebRequestData(&https_foo_request, ON_BEFORE_REQUEST))); |
+ request_data.request = &https_foo_request; |
+ request_data.url_match_ids = url_match_ids; |
+ EXPECT_FALSE(result->IsFulfilled(-1, url_match_ids, request_data)); |
} |
TEST(WebRequestConditionTest, TestPortFilter) { |
@@ -309,10 +315,6 @@ TEST(WebRequestConditionTest, ConditionsWithConflictingStages) { |
std::string error; |
scoped_ptr<WebRequestCondition> result; |
- DictionaryValue condition_value; |
- condition_value.SetString(keys::kInstanceTypeKey, keys::kRequestMatcherType); |
- |
- |
// Test error on incompatible application stages for involved attributes. |
error.clear(); |
result = WebRequestCondition::Create( |