OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <map> | 5 #include <map> |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 // Disable blacklist checks (tested elsewhere) so that we only see the | 345 // Disable blacklist checks (tested elsewhere) so that we only see the |
346 // update HTTP request. | 346 // update HTTP request. |
347 updater.set_blacklist_checks_enabled(false); | 347 updater.set_blacklist_checks_enabled(false); |
348 | 348 |
349 // Tell the update that it's time to do update checks. | 349 // Tell the update that it's time to do update checks. |
350 SimulateTimerFired(&updater); | 350 SimulateTimerFired(&updater); |
351 | 351 |
352 // Get the url our mock fetcher was asked to fetch. | 352 // Get the url our mock fetcher was asked to fetch. |
353 TestURLFetcher* fetcher = | 353 TestURLFetcher* fetcher = |
354 factory.GetFetcherByID(ExtensionUpdater::kManifestFetcherId); | 354 factory.GetFetcherByID(ExtensionUpdater::kManifestFetcherId); |
355 const GURL& url = fetcher->GetOriginalUrl(); | 355 const GURL& url = fetcher->GetOriginalURL(); |
356 EXPECT_FALSE(url.is_empty()); | 356 EXPECT_FALSE(url.is_empty()); |
357 EXPECT_TRUE(url.is_valid()); | 357 EXPECT_TRUE(url.is_valid()); |
358 EXPECT_TRUE(url.SchemeIs("http")); | 358 EXPECT_TRUE(url.SchemeIs("http")); |
359 EXPECT_EQ("foo.com", url.host()); | 359 EXPECT_EQ("foo.com", url.host()); |
360 EXPECT_EQ("/bar", url.path()); | 360 EXPECT_EQ("/bar", url.path()); |
361 | 361 |
362 // Validate the extension request parameters in the query. It should | 362 // Validate the extension request parameters in the query. It should |
363 // look something like "?x=id%3D<id>%26v%3D<version>%26uc". | 363 // look something like "?x=id%3D<id>%26v%3D<version>%26uc". |
364 EXPECT_TRUE(url.has_query()); | 364 EXPECT_TRUE(url.has_query()); |
365 std::vector<std::string> parts; | 365 std::vector<std::string> parts; |
(...skipping 29 matching lines...) Expand all Loading... |
395 service.profile(), 60*60*24); | 395 service.profile(), 60*60*24); |
396 updater.Start(); | 396 updater.Start(); |
397 | 397 |
398 // Tell the updater that it's time to do update checks. | 398 // Tell the updater that it's time to do update checks. |
399 SimulateTimerFired(&updater); | 399 SimulateTimerFired(&updater); |
400 | 400 |
401 // Get the url our mock fetcher was asked to fetch. | 401 // Get the url our mock fetcher was asked to fetch. |
402 TestURLFetcher* fetcher = | 402 TestURLFetcher* fetcher = |
403 factory.GetFetcherByID(ExtensionUpdater::kManifestFetcherId); | 403 factory.GetFetcherByID(ExtensionUpdater::kManifestFetcherId); |
404 ASSERT_FALSE(fetcher == NULL); | 404 ASSERT_FALSE(fetcher == NULL); |
405 const GURL& url = fetcher->GetOriginalUrl(); | 405 const GURL& url = fetcher->GetOriginalURL(); |
406 | 406 |
407 EXPECT_FALSE(url.is_empty()); | 407 EXPECT_FALSE(url.is_empty()); |
408 EXPECT_TRUE(url.is_valid()); | 408 EXPECT_TRUE(url.is_valid()); |
409 EXPECT_TRUE(url.SchemeIs("https")); | 409 EXPECT_TRUE(url.SchemeIs("https")); |
410 EXPECT_EQ("clients2.google.com", url.host()); | 410 EXPECT_EQ("clients2.google.com", url.host()); |
411 EXPECT_EQ("/service/update2/crx", url.path()); | 411 EXPECT_EQ("/service/update2/crx", url.path()); |
412 | 412 |
413 // Validate the extension request parameters in the query. It should | 413 // Validate the extension request parameters in the query. It should |
414 // look something like "?x=id%3D<id>%26v%3D<version>%26uc". | 414 // look something like "?x=id%3D<id>%26v%3D<version>%26uc". |
415 EXPECT_TRUE(url.has_query()); | 415 EXPECT_TRUE(url.has_query()); |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 updater.Start(); | 981 updater.Start(); |
982 updater.set_blacklist_checks_enabled(false); | 982 updater.set_blacklist_checks_enabled(false); |
983 | 983 |
984 // Make the updater do manifest fetching, and note the urls it tries to | 984 // Make the updater do manifest fetching, and note the urls it tries to |
985 // fetch. | 985 // fetch. |
986 std::vector<GURL> fetched_urls; | 986 std::vector<GURL> fetched_urls; |
987 updater.CheckNow(); | 987 updater.CheckNow(); |
988 TestURLFetcher* fetcher = | 988 TestURLFetcher* fetcher = |
989 factory.GetFetcherByID(ExtensionUpdater::kManifestFetcherId); | 989 factory.GetFetcherByID(ExtensionUpdater::kManifestFetcherId); |
990 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); | 990 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); |
991 fetched_urls.push_back(fetcher->GetOriginalUrl()); | 991 fetched_urls.push_back(fetcher->GetOriginalURL()); |
992 | 992 |
993 fetcher->set_url(fetched_urls[0]); | 993 fetcher->set_url(fetched_urls[0]); |
994 fetcher->set_status(net::URLRequestStatus()); | 994 fetcher->set_status(net::URLRequestStatus()); |
995 fetcher->set_response_code(500); | 995 fetcher->set_response_code(500); |
996 fetcher->SetResponseString(""); | 996 fetcher->SetResponseString(""); |
997 fetcher->delegate()->OnURLFetchComplete(fetcher); | 997 fetcher->delegate()->OnURLFetchComplete(fetcher); |
998 | 998 |
999 fetcher = factory.GetFetcherByID(ExtensionUpdater::kManifestFetcherId); | 999 fetcher = factory.GetFetcherByID(ExtensionUpdater::kManifestFetcherId); |
1000 fetched_urls.push_back(fetcher->GetOriginalUrl()); | 1000 fetched_urls.push_back(fetcher->GetOriginalURL()); |
1001 | 1001 |
1002 // The urls could have been fetched in either order, so use the host to | 1002 // The urls could have been fetched in either order, so use the host to |
1003 // tell them apart and note the query each used. | 1003 // tell them apart and note the query each used. |
1004 std::string url1_query; | 1004 std::string url1_query; |
1005 std::string url2_query; | 1005 std::string url2_query; |
1006 if (fetched_urls[0].host() == url1.host()) { | 1006 if (fetched_urls[0].host() == url1.host()) { |
1007 url1_query = fetched_urls[0].query(); | 1007 url1_query = fetched_urls[0].query(); |
1008 url2_query = fetched_urls[1].query(); | 1008 url2_query = fetched_urls[1].query(); |
1009 } else if (fetched_urls[0].host() == url2.host()) { | 1009 } else if (fetched_urls[0].host() == url2.host()) { |
1010 url1_query = fetched_urls[1].query(); | 1010 url1_query = fetched_urls[1].query(); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 | 1259 |
1260 // TODO(asargent) - (http://crbug.com/12780) add tests for: | 1260 // TODO(asargent) - (http://crbug.com/12780) add tests for: |
1261 // -prodversionmin (shouldn't update if browser version too old) | 1261 // -prodversionmin (shouldn't update if browser version too old) |
1262 // -manifests & updates arriving out of order / interleaved | 1262 // -manifests & updates arriving out of order / interleaved |
1263 // -malformed update url (empty, file://, has query, has a # fragment, etc.) | 1263 // -malformed update url (empty, file://, has query, has a # fragment, etc.) |
1264 // -An extension gets uninstalled while updates are in progress (so it doesn't | 1264 // -An extension gets uninstalled while updates are in progress (so it doesn't |
1265 // "come back from the dead") | 1265 // "come back from the dead") |
1266 // -An extension gets manually updated to v3 while we're downloading v2 (ie | 1266 // -An extension gets manually updated to v3 while we're downloading v2 (ie |
1267 // you don't get downgraded accidentally) | 1267 // you don't get downgraded accidentally) |
1268 // -An update manifest mentions multiple updates | 1268 // -An update manifest mentions multiple updates |
OLD | NEW |