| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/strings/string16.h" | 6 #include "base/strings/string16.h" |
| 7 #include "base/strings/string_split.h" | 7 #include "base/strings/string_split.h" |
| 8 #include "base/task_scheduler/post_task.h" | 8 #include "base/task_scheduler/post_task.h" |
| 9 #include "chrome/browser/history/history_service_factory.h" |
| 10 #include "chrome/browser/history/history_test_utils.h" |
| 9 #include "chrome/browser/prerender/prerender_handle.h" | 11 #include "chrome/browser/prerender/prerender_handle.h" |
| 10 #include "chrome/browser/prerender/prerender_manager.h" | 12 #include "chrome/browser/prerender/prerender_manager.h" |
| 11 #include "chrome/browser/prerender/prerender_manager_factory.h" | 13 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 12 #include "chrome/browser/prerender/prerender_test_utils.h" | 14 #include "chrome/browser/prerender/prerender_test_utils.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | 16 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" |
| 15 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_commands.h" | 18 #include "chrome/browser/ui/browser_commands.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 // Prefetch resources are blocked, but the prerender is not killed in any | 412 // Prefetch resources are blocked, but the prerender is not killed in any |
| 411 // special way. | 413 // special way. |
| 412 // TODO(mattcary): since the prerender will count itself as loaded even if the | 414 // TODO(mattcary): since the prerender will count itself as loaded even if the |
| 413 // fetch of the main resource fails, the test doesn't actually confirm what we | 415 // fetch of the main resource fails, the test doesn't actually confirm what we |
| 414 // want it to confirm. This may be fixed by planned changes to the prerender | 416 // want it to confirm. This may be fixed by planned changes to the prerender |
| 415 // lifecycle. | 417 // lifecycle. |
| 416 std::unique_ptr<TestPrerender> prerender = | 418 std::unique_ptr<TestPrerender> prerender = |
| 417 PrefetchFromFile(kPrefetchPage, FINAL_STATUS_SAFE_BROWSING); | 419 PrefetchFromFile(kPrefetchPage, FINAL_STATUS_SAFE_BROWSING); |
| 418 } | 420 } |
| 419 | 421 |
| 422 // Checks that prefetching a page does not add it to browsing history. |
| 423 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, HistoryUntouchedByPrefetch) { |
| 424 // Initialize. |
| 425 Profile* profile = current_browser()->profile(); |
| 426 ASSERT_TRUE(profile); |
| 427 ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile( |
| 428 profile, ServiceAccessType::EXPLICIT_ACCESS)); |
| 429 |
| 430 // Prefetch a page. |
| 431 GURL prefetched_url = src_server()->GetURL(MakeAbsolute(kPrefetchPage)); |
| 432 PrefetchFromFile(kPrefetchPage, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); |
| 433 WaitForHistoryBackendToRun(profile); |
| 434 |
| 435 // Navigate to another page. |
| 436 GURL navigated_url = src_server()->GetURL(MakeAbsolute(kPrefetchPage2)); |
| 437 ui_test_utils::NavigateToURL(current_browser(), navigated_url); |
| 438 WaitForHistoryBackendToRun(profile); |
| 439 |
| 440 // Check that the URL that was explicitly navigated to is already in history. |
| 441 ui_test_utils::HistoryEnumerator enumerator(profile); |
| 442 std::vector<GURL>& urls = enumerator.urls(); |
| 443 EXPECT_TRUE(std::find(urls.begin(), urls.end(), navigated_url) != urls.end()); |
| 444 |
| 445 // Check that the URL that was prefetched is not in history. |
| 446 EXPECT_TRUE(std::find(urls.begin(), urls.end(), prefetched_url) == |
| 447 urls.end()); |
| 448 |
| 449 // The loader URL is the remaining entry. |
| 450 EXPECT_EQ(2U, urls.size()); |
| 451 } |
| 452 |
| 420 } // namespace prerender | 453 } // namespace prerender |
| OLD | NEW |