Chromium Code Reviews| Index: chrome/browser/net/predictor_browsertest.cc |
| diff --git a/chrome/browser/net/predictor_browsertest.cc b/chrome/browser/net/predictor_browsertest.cc |
| index 9b0e12d7c3500376d9b758e078cb4a7eb1306db4..35d4c46f4d25efa527f790ca0877c70b4cca4e43 100644 |
| --- a/chrome/browser/net/predictor_browsertest.cc |
| +++ b/chrome/browser/net/predictor_browsertest.cc |
| @@ -23,6 +23,9 @@ |
| #include "base/threading/thread_task_runner_handle.h" |
| #include "build/build_config.h" |
| #include "chrome/browser/browser_process.h" |
| +#include "chrome/browser/browsing_data/browsing_data_helper.h" |
| +#include "chrome/browser/browsing_data/browsing_data_remover.h" |
| +#include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| #include "chrome/browser/net/predictor.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/browser.h" |
| @@ -1362,28 +1365,49 @@ IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, |
| } |
| IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, ShutdownStartupCyclePreresolve) { |
| - // Make sure that the Preferences file is actually wiped of all DNS prefetch |
| - // related data after start-up. |
| + // Make sure this data has been loaded into the Predictor, by inspecting that |
| + // the Predictor starts making the expected hostname requests. |
| + PrepareFrameSubresources(referring_url_); |
| + observer()->WaitUntilHostLookedUp(target_url_); |
| + |
| + // Verify that both urls were requested by the predictor. Note that the |
| + // startup URL may be requested before the observer attaches itself. |
| + ExpectUrlRequestedFromPredictor(startup_url_); |
| + EXPECT_FALSE(observer()->HostFound(target_url_)); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, PRE_ClearData) { |
| + // The target url will have a expected connection count of 2 after this call. |
|
eroman
2016/06/25 01:12:53
nit: url --> URL, and "a expected" --> "an expecte
|
| + InstallPredictorObserver(referring_url_, target_url_); |
| + LearnFromNavigation(referring_url_, target_url_); |
| +} |
| + |
| +// Ensure predictive data is cleared when the history is cleared. |
| +IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, ClearData) { |
| std::string cleared_startup_list; |
| std::string cleared_referral_list; |
| + |
| + // The pref should persist after startup. |
| GetListFromPrefsAsString(prefs::kDnsPrefetchingStartupList, |
| &cleared_startup_list); |
| GetListFromPrefsAsString(prefs::kDnsPrefetchingHostReferralList, |
| &cleared_referral_list); |
| + EXPECT_THAT(cleared_referral_list, HasSubstr(referring_url_.host())); |
| + EXPECT_THAT(cleared_referral_list, HasSubstr(target_url_.host())); |
| + |
| + // Clear cache which should clear all prefs. |
| + BrowsingDataRemover* remover = |
| + BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile()); |
| + remover->Remove(BrowsingDataRemover::Unbounded(), |
| + BrowsingDataRemover::REMOVE_HISTORY, |
| + BrowsingDataHelper::UNPROTECTED_WEB); |
| - EXPECT_THAT(cleared_startup_list, Not(HasSubstr(startup_url_.host()))); |
| + GetListFromPrefsAsString(prefs::kDnsPrefetchingStartupList, |
| + &cleared_startup_list); |
| + GetListFromPrefsAsString(prefs::kDnsPrefetchingHostReferralList, |
| + &cleared_referral_list); |
| EXPECT_THAT(cleared_referral_list, Not(HasSubstr(referring_url_.host()))); |
| EXPECT_THAT(cleared_referral_list, Not(HasSubstr(target_url_.host()))); |
| - |
| - // But also make sure this data has been first loaded into the Predictor, by |
| - // inspecting that the Predictor starts making the expected hostname requests. |
| - PrepareFrameSubresources(referring_url_); |
| - observer()->WaitUntilHostLookedUp(target_url_); |
| - |
| - // Verify that both urls were requested by the predictor. Note that the |
| - // startup URL may be requested before the observer attaches itself. |
| - ExpectUrlRequestedFromPredictor(startup_url_); |
| - EXPECT_FALSE(observer()->HostFound(target_url_)); |
| } |
| // The predictor should not evict recently used (navigated to) referrers. |