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..76164820ba08f5f963d685e3b46c03ca803a9120 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" |
Jeffrey Yasskin
2013/01/24 00:39:17
Instead of extending this test, I'd add a separate
vabr (Chromium)
2013/01/24 18:24:08
Done.
|
" \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n" |
"}"), |
&error); |
@@ -71,29 +71,29 @@ 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()); |
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(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()); |
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(request_data)); |
} |
// Conditions without UrlFilter attributes need to be independent of URL |
@@ -153,22 +153,18 @@ TEST(WebRequestConditionTest, NoUrlAttributes) { |
net::TestURLRequestContext context; |
net::TestURLRequest https_request( |
GURL("https://www.example.com"), NULL, &context); |
- std::set<URLMatcherConditionSet::ID> dummy_match_set; |
// 1. A non-empty condition without UrlFilter attributes is fulfilled iff its |
// attributes are fulfilled. |
EXPECT_FALSE(condition_no_url_false->IsFulfilled( |
- dummy_match_set, |
DeclarativeWebRequestData(&https_request, ON_BEFORE_REQUEST))); |
EXPECT_TRUE(condition_no_url_true->IsFulfilled( |
- dummy_match_set, |
DeclarativeWebRequestData(&https_request, ON_BEFORE_REQUEST))); |
// 2. An empty condition (in particular, without UrlFilter attributes) is |
// always fulfilled. |
EXPECT_TRUE(condition_empty->IsFulfilled( |
- dummy_match_set, |
DeclarativeWebRequestData(&https_request, ON_BEFORE_REQUEST))); |
} |
@@ -210,38 +206,32 @@ TEST(WebRequestConditionTest, CreateConditionSet) { |
result->GetURLMatcherConditionSets(&url_matcher_condition_set); |
matcher.AddConditionSets(url_matcher_condition_set); |
- std::set<URLMatcherConditionSet::ID> url_match_ids; |
- |
// Test that the result is correct and matches http://www.example.com and |
// https://www.example.com |
GURL http_url("http://www.example.com"); |
net::TestURLRequestContext context; |
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 = matcher.MatchURL(http_url); |
+ EXPECT_EQ(1u, request_data.url_match_ids.size()); |
+ EXPECT_TRUE(result->IsFulfilled(*(request_data.url_match_ids.begin()), |
+ request_data)); |
GURL https_url("https://www.example.com"); |
- url_match_ids = matcher.MatchURL(https_url); |
- EXPECT_EQ(1u, url_match_ids.size()); |
+ request_data.url_match_ids = matcher.MatchURL(https_url); |
+ EXPECT_EQ(1u, request_data.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; |
+ EXPECT_TRUE(result->IsFulfilled(*(request_data.url_match_ids.begin()), |
+ 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()); |
+ request_data.url_match_ids = matcher.MatchURL(https_foo_url); |
+ EXPECT_EQ(0u, request_data.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; |
+ EXPECT_FALSE(result->IsFulfilled(-1, request_data)); |
} |
TEST(WebRequestConditionTest, TestPortFilter) { |
@@ -309,10 +299,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( |