| Index: net/http/http_server_properties_manager_unittest.cc
|
| diff --git a/net/http/http_server_properties_manager_unittest.cc b/net/http/http_server_properties_manager_unittest.cc
|
| index 32e9e5204c074dfa2139ea92fcc7ff46484a3f97..3c5906323486070dfdb6a2dab66e6b094c824771 100644
|
| --- a/net/http/http_server_properties_manager_unittest.cc
|
| +++ b/net/http/http_server_properties_manager_unittest.cc
|
| @@ -143,7 +143,7 @@ class TestingHttpServerPropertiesManager : public HttpServerPropertiesManager {
|
|
|
| // TODO(rtenneti): After we stop supporting version 3 and everyone has migrated
|
| // to version 4, delete the following code.
|
| -static const int kHttpServerPropertiesVersions[] = {3, 4};
|
| +static const int kHttpServerPropertiesVersions[] = {3, 4, 5};
|
|
|
| class HttpServerPropertiesManagerTest : public testing::TestWithParam<int> {
|
| protected:
|
| @@ -233,15 +233,15 @@ TEST_P(HttpServerPropertiesManagerTest,
|
| // it twice. Only expect a single cache update.
|
|
|
| base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
|
| - // TODO(zhongyi): change scheme to http once Pref data is also migrated
|
| - // SchemeHostPort.
|
| - url::SchemeHostPort google_server("https", "www.google.com", 80);
|
| - url::SchemeHostPort mail_server("https", "mail.google.com", 80);
|
| + url::SchemeHostPort google_server(GetParam() >= 5 ? "http" : "https",
|
| + "www.google.com", 80);
|
| + url::SchemeHostPort mail_server(GetParam() >= 5 ? "http" : "https",
|
| + "mail.google.com", 80);
|
|
|
| - // Set supports_spdy for www.google.com:80.
|
| + // Set supports_spdy for http://www.google.com:80.
|
| server_pref_dict->SetBoolean("supports_spdy", true);
|
|
|
| - // Set up alternative_services for www.google.com:80.
|
| + // Set up alternative_services for http://www.google.com:80.
|
| base::DictionaryValue* alternative_service_dict0 = new base::DictionaryValue;
|
| alternative_service_dict0->SetInteger("port", 443);
|
| alternative_service_dict0->SetString("protocol_str", "npn-h2");
|
| @@ -254,16 +254,18 @@ TEST_P(HttpServerPropertiesManagerTest,
|
| server_pref_dict->SetWithoutPathExpansion("alternative_service",
|
| alternative_service_list0);
|
|
|
| - // Set up ServerNetworkStats for www.google.com:80.
|
| + // Set up ServerNetworkStats for http://www.google.com:80.
|
| base::DictionaryValue* stats = new base::DictionaryValue;
|
| stats->SetInteger("srtt", 10);
|
| server_pref_dict->SetWithoutPathExpansion("network_stats", stats);
|
|
|
| - // Set the server preference for www.google.com:80.
|
| + // Set the server preference for http://www.google.com:80.
|
| base::DictionaryValue* servers_dict = new base::DictionaryValue;
|
| - servers_dict->SetWithoutPathExpansion("www.google.com:80", server_pref_dict);
|
| + servers_dict->SetWithoutPathExpansion(
|
| + GetParam() >= 5 ? "http://www.google.com" : "www.google.com:80",
|
| + server_pref_dict);
|
| base::ListValue* servers_list = nullptr;
|
| - if (GetParam() == 4) {
|
| + if (GetParam() >= 4) {
|
| servers_list = new base::ListValue;
|
| // |servers_list| takes ownership of |servers_dict|.
|
| servers_list->AppendIfNotPresent(servers_dict);
|
| @@ -285,18 +287,25 @@ TEST_P(HttpServerPropertiesManagerTest,
|
| server_pref_dict1->SetWithoutPathExpansion("alternative_service",
|
| alternative_service_list1);
|
|
|
| - // Set up ServerNetworkStats for mail.google.com:80 and it is the MRU server.
|
| + // Set up ServerNetworkStats for http://mail.google.com:80 and it is the MRU
|
| + // server.
|
| base::DictionaryValue* stats1 = new base::DictionaryValue;
|
| stats1->SetInteger("srtt", 20);
|
| server_pref_dict1->SetWithoutPathExpansion("network_stats", stats1);
|
| - // Set the server preference for mail.google.com:80.
|
| - servers_dict->SetWithoutPathExpansion("mail.google.com:80",
|
| - server_pref_dict1);
|
| + // Set the server preference for http://mail.google.com:80.
|
| + servers_dict->SetWithoutPathExpansion(
|
| + GetParam() >= 5 ? "http://mail.google.com" : "mail.google.com:80",
|
| + server_pref_dict1);
|
| base::DictionaryValue http_server_properties_dict;
|
| - if (GetParam() == 4) {
|
| + if (GetParam() >= 4) {
|
| // |servers_list| takes ownership of |servers_dict|.
|
| servers_list->AppendIfNotPresent(servers_dict);
|
| - HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, -1);
|
| + if (GetParam() == 5) {
|
| + HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, -1);
|
| + } else {
|
| + HttpServerPropertiesManager::SetVersion(&http_server_properties_dict,
|
| + GetParam());
|
| + }
|
| http_server_properties_dict.SetWithoutPathExpansion("servers",
|
| servers_list);
|
| } else {
|
| @@ -361,7 +370,7 @@ TEST_P(HttpServerPropertiesManagerTest,
|
| EXPECT_FALSE(http_server_props_manager_->SupportsRequestPriority(foo_server));
|
|
|
| // Verify alternative service.
|
| - if (GetParam() == 4) {
|
| + if (GetParam() >= 4) {
|
| const AlternativeServiceMap& map =
|
| http_server_props_manager_->alternative_service_map();
|
| ASSERT_EQ(2u, map.size());
|
| @@ -463,11 +472,16 @@ TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {
|
| servers_dict->SetWithoutPathExpansion("www.google.com:65536",
|
| server_pref_dict);
|
| base::DictionaryValue http_server_properties_dict;
|
| - if (GetParam() == 4) {
|
| + if (GetParam() >= 4) {
|
| base::ListValue* servers_list = new base::ListValue;
|
| // |servers_list| takes ownership of |servers_dict|.
|
| servers_list->AppendIfNotPresent(servers_dict);
|
| - HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, -1);
|
| + if (GetParam() == 5) {
|
| + HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, -1);
|
| + } else {
|
| + HttpServerPropertiesManager::SetVersion(&http_server_properties_dict,
|
| + GetParam());
|
| + }
|
| http_server_properties_dict.SetWithoutPathExpansion("servers",
|
| servers_list);
|
| } else {
|
| @@ -533,11 +547,16 @@ TEST_P(HttpServerPropertiesManagerTest, BadCachedAltProtocolPort) {
|
| base::DictionaryValue* servers_dict = new base::DictionaryValue;
|
| servers_dict->SetWithoutPathExpansion("www.google.com:80", server_pref_dict);
|
| base::DictionaryValue http_server_properties_dict;
|
| - if (GetParam() == 4) {
|
| + if (GetParam() >= 4) {
|
| base::ListValue* servers_list = new base::ListValue;
|
| // |servers_list| takes ownership of |servers_dict|.
|
| servers_list->AppendIfNotPresent(servers_dict);
|
| - HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, -1);
|
| + if (GetParam() == 5) {
|
| + HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, -1);
|
| + } else {
|
| + HttpServerPropertiesManager::SetVersion(&http_server_properties_dict,
|
| + GetParam());
|
| + }
|
| http_server_properties_dict.SetWithoutPathExpansion("servers",
|
| servers_list);
|
| } else {
|
| @@ -968,7 +987,7 @@ TEST_P(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
|
|
| base::DictionaryValue* servers_dict = new base::DictionaryValue;
|
| base::ListValue* servers_list = nullptr;
|
| - if (GetParam() == 4)
|
| + if (GetParam() >= 4)
|
| servers_list = new base::ListValue;
|
|
|
| for (int i = 1; i <= 200; ++i) {
|
| @@ -981,32 +1000,39 @@ TEST_P(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
| base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
|
| server_pref_dict->SetWithoutPathExpansion("alternative_service",
|
| alternative_service_list);
|
| - if (GetParam() == 4) {
|
| - // TODO(zhongyi): add scheme once disc data is migrated.
|
| + if (GetParam() >= 5) {
|
| + servers_dict->SetWithoutPathExpansion(
|
| + StringPrintf("http://www.google.com:%d", i), server_pref_dict);
|
| + } else {
|
| servers_dict->SetWithoutPathExpansion(
|
| StringPrintf("www.google.com:%d", i), server_pref_dict);
|
| + }
|
| + if (GetParam() >= 4) {
|
| // |servers_list| takes ownership of |servers_dict|.
|
| servers_list->AppendIfNotPresent(servers_dict);
|
| servers_dict = new base::DictionaryValue;
|
| - } else {
|
| - // TODO(zhongyi): add scheme once disc data is migrated.
|
| - servers_dict->SetWithoutPathExpansion(
|
| - StringPrintf("www.google.com:%d", i), server_pref_dict);
|
| }
|
| }
|
|
|
| - // Set the preference for mail.google.com server.
|
| + // Set the server preference for http://mail.google.com server.
|
| base::DictionaryValue* server_pref_dict1 = new base::DictionaryValue;
|
| -
|
| - // Set the server preference for mail.google.com:80.
|
| - // TODO(zhongyi): add scheme once disc data is migrated.
|
| - servers_dict->SetWithoutPathExpansion("mail.google.com:80",
|
| - server_pref_dict1);
|
| + if (GetParam() >= 5) {
|
| + servers_dict->SetWithoutPathExpansion("http://mail.google.com",
|
| + server_pref_dict1);
|
| + } else {
|
| + servers_dict->SetWithoutPathExpansion("mail.google.com:80",
|
| + server_pref_dict1);
|
| + }
|
| base::DictionaryValue http_server_properties_dict;
|
| - if (GetParam() == 4) {
|
| + if (GetParam() >= 4) {
|
| // |servers_list| takes ownership of |servers_dict|.
|
| servers_list->AppendIfNotPresent(servers_dict);
|
| - HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, -1);
|
| + if (GetParam() == 5) {
|
| + HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, -1);
|
| + } else {
|
| + HttpServerPropertiesManager::SetVersion(&http_server_properties_dict,
|
| + GetParam());
|
| + }
|
| http_server_properties_dict.SetWithoutPathExpansion("servers",
|
| servers_list);
|
| } else {
|
| @@ -1031,8 +1057,12 @@ TEST_P(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
|
|
| // Verify alternative service.
|
| for (int i = 1; i <= 200; ++i) {
|
| - // TODO(zhongyi): remove hardcoded scheme once disc data is migrated.
|
| - GURL server_gurl(StringPrintf("https://www.google.com:%d", i));
|
| + GURL server_gurl;
|
| + if (GetParam() >= 5) {
|
| + server_gurl = GURL(StringPrintf("http://www.google.com:%d", i));
|
| + } else {
|
| + server_gurl = GURL(StringPrintf("https://www.google.com:%d", i));
|
| + }
|
| url::SchemeHostPort server(server_gurl);
|
| AlternativeServiceVector alternative_service_vector =
|
| http_server_props_manager_->GetAlternativeServices(server);
|
| @@ -1101,18 +1131,18 @@ TEST_P(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) {
|
| "{\"quic_servers\":{\"https://"
|
| "mail.google.com:80\":{\"server_info\":\"quic_server_info1\"}},"
|
| "\"servers\":["
|
| - "{\"www.google.com:80\":{"
|
| + "{\"http://www.google.com\":{"
|
| "\"alternative_service\":[{\"expiration\":\"13756212000000000\","
|
| "\"port\":443,\"protocol_str\":\"npn-h2\"},"
|
| "{\"expiration\":\"13758804000000000\",\"host\":\"www.google.com\","
|
| "\"port\":1234,\"protocol_str\":\"npn-h2\"}]}},"
|
| - "{\"mail.google.com:80\":{\"alternative_service\":[{"
|
| + "{\"http://mail.google.com\":{\"alternative_service\":[{"
|
| "\"expiration\":\"9223372036854775807\",\"host\":\"foo.google.com\","
|
| "\"port\":444,\"protocol_str\":\"npn-spdy/3.1\"}],"
|
| "\"network_stats\":{\"srtt\":42}}}"
|
| "],"
|
| "\"supports_quic\":{\"address\":\"127.0.0.1\",\"used_quic\":true},"
|
| - "\"version\":4}";
|
| + "\"version\":5}";
|
|
|
| const base::Value* http_server_properties =
|
| &pref_delegate_->GetServerProperties();
|
| @@ -1219,8 +1249,9 @@ TEST_P(HttpServerPropertiesManagerTest,
|
| ASSERT_TRUE((*it)->GetAsDictionary(&server_pref_dict));
|
|
|
| const base::DictionaryValue* example_pref_dict;
|
| +
|
| ASSERT_TRUE(server_pref_dict->GetDictionaryWithoutPathExpansion(
|
| - "www.example.com:443", &example_pref_dict));
|
| + "https://www.example.com", &example_pref_dict));
|
|
|
| const base::ListValue* altsvc_list;
|
| ASSERT_TRUE(example_pref_dict->GetList("alternative_service", &altsvc_list));
|
|
|