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

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

Issue 2615883003: [NoStatePrefetch] Implement FINAL_STATUS_SAFEBROWSING (Closed)
Patch Set: main resource only Created 3 years, 11 months 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 | « chrome/browser/loader/safe_browsing_resource_throttle.cc ('k') | 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 a14ad92b52bd494d7856eab917ba6c61e43d3f8b..18990baa7d61316eea2f5597f5f1e3a0cf72c1d3 100644
--- a/chrome/browser/prerender/prerender_nostate_prefetch_browsertest.cc
+++ b/chrome/browser/prerender/prerender_nostate_prefetch_browsertest.cc
@@ -467,23 +467,45 @@ IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, Jpeg) {
counter.WaitForCount(1);
}
-// Checks that nothing is prefetched from malware sites.
-// TODO(mattcary): disabled as prefetch process teardown is racey with prerender
-// contents destruction, can fix when prefetch prerenderers are destroyed
-// deterministically.
+// If the main resource is unsafe, the whole prefetch is cancelled.
IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest,
- DISABLED_PrerenderSafeBrowsingTopLevel) {
+ PrerenderSafeBrowsingTopLevel) {
GURL url = src_server()->GetURL(MakeAbsolute(kPrefetchPage));
GetFakeSafeBrowsingDatabaseManager()->SetThreatTypeForUrl(
url, safe_browsing::SB_THREAT_TYPE_URL_MALWARE);
- // Prefetch resources are blocked, but the prerender is not killed in any
- // special way.
- // TODO(mattcary): since the prerender will count itself as loaded even if the
- // fetch of the main resource fails, the test doesn't actually confirm what we
- // want it to confirm. This may be fixed by planned changes to the prerender
- // lifecycle.
+
+ RequestCounter main_counter;
+ CountRequestFor(kPrefetchPage, &main_counter);
+ RequestCounter script_counter;
+ CountRequestFor(kPrefetchScript, &script_counter);
+
std::unique_ptr<TestPrerender> prerender =
PrefetchFromFile(kPrefetchPage, FINAL_STATUS_SAFE_BROWSING);
+
+ main_counter.WaitForCount(0);
+ script_counter.WaitForCount(0);
+
+ // Verify that the page load did not happen.
+ prerender->WaitForLoads(0);
+}
+
+// If a subresource is unsafe, the corresponding request is cancelled.
+IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest,
+ PrerenderSafeBrowsingSubresource) {
+ GURL url = src_server()->GetURL(MakeAbsolute(kPrefetchScript));
+ GetFakeSafeBrowsingDatabaseManager()->SetThreatTypeForUrl(
+ url, safe_browsing::SB_THREAT_TYPE_URL_MALWARE);
+
+ RequestCounter main_counter;
+ CountRequestFor(kPrefetchPage, &main_counter);
+ RequestCounter script_counter;
+ CountRequestFor(kPrefetchScript, &script_counter);
+
+ std::unique_ptr<TestPrerender> prerender =
+ PrefetchFromFile(kPrefetchPage, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED);
+
+ main_counter.WaitForCount(1);
+ script_counter.WaitForCount(0);
}
// Checks that prefetching a page does not add it to browsing history.
« no previous file with comments | « chrome/browser/loader/safe_browsing_resource_throttle.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698