Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2059)

Unified Diff: chrome/browser/prerender/prerender_nostate_prefetch_browsertest.cc

Issue 2514663003: [NoStatePrefetch] Test that history is not written on prefetches (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prerender/prerender_nostate_prefetch_browsertest.cc
diff --git a/chrome/browser/prerender/prerender_nostate_prefetch_browsertest.cc b/chrome/browser/prerender/prerender_nostate_prefetch_browsertest.cc
index eff9f43716dfde3610922d3b95088249236115bd..db5e42f7bf2c91e08ce1a59c3a9dc58bbb5c0a78 100644
--- a/chrome/browser/prerender/prerender_nostate_prefetch_browsertest.cc
+++ b/chrome/browser/prerender/prerender_nostate_prefetch_browsertest.cc
@@ -6,6 +6,8 @@
#include "base/strings/string16.h"
#include "base/strings/string_split.h"
#include "base/task_scheduler/post_task.h"
+#include "chrome/browser/history/history_service_factory.h"
+#include "chrome/browser/history/history_test_utils.h"
#include "chrome/browser/prerender/prerender_handle.h"
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/prerender/prerender_manager_factory.h"
@@ -417,4 +419,35 @@ IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest,
PrefetchFromFile(kPrefetchPage, FINAL_STATUS_SAFE_BROWSING);
}
+// Checks that prefetching a page does not add it to browsing history.
+IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, HistoryUntouchedByPrefetch) {
+ // Initialize.
+ Profile* profile = current_browser()->profile();
+ ASSERT_TRUE(profile);
+ ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile(
+ profile, ServiceAccessType::EXPLICIT_ACCESS));
+
+ // Prefetch a page.
+ GURL prefetched_url = src_server()->GetURL(MakeAbsolute(kPrefetchPage));
+ PrefetchFromFile(kPrefetchPage, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED);
+ WaitForHistoryBackendToRun(profile);
+
+ // Navigate to another page.
+ GURL navigated_url = src_server()->GetURL(MakeAbsolute(kPrefetchPage2));
+ ui_test_utils::NavigateToURL(current_browser(), navigated_url);
+ WaitForHistoryBackendToRun(profile);
+
+ // Check that the URL that was explicitly navigated to is already in history.
+ ui_test_utils::HistoryEnumerator enumerator(profile);
+ std::vector<GURL>& urls = enumerator.urls();
+ EXPECT_TRUE(std::find(urls.begin(), urls.end(), navigated_url) != urls.end());
+
+ // Check that the URL that was prefetched is not in history.
+ EXPECT_TRUE(std::find(urls.begin(), urls.end(), prefetched_url) ==
+ urls.end());
+
+ // The loader URL is the remaining entry.
+ EXPECT_EQ(2U, urls.size());
+}
+
} // namespace prerender
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698