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

Side by Side Diff: chrome/browser/prerender/prerender_nostate_prefetch_browsertest.cc

Issue 2819523002: Prerender: Disable prefetch if there's an appcache (unflaked tests) (Closed)
Patch Set: comments Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_test_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/memory/ptr_util.h"
7 #include "base/memory/ref_counted.h"
6 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
7 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
9 #include "base/task_scheduler/post_task.h" 12 #include "base/task_scheduler/post_task.h"
13 #include "base/test/simple_test_tick_clock.h"
10 #include "chrome/browser/history/history_service_factory.h" 14 #include "chrome/browser/history/history_service_factory.h"
11 #include "chrome/browser/history/history_test_utils.h" 15 #include "chrome/browser/history/history_test_utils.h"
12 #include "chrome/browser/prerender/prerender_handle.h" 16 #include "chrome/browser/prerender/prerender_handle.h"
13 #include "chrome/browser/prerender/prerender_manager.h" 17 #include "chrome/browser/prerender/prerender_manager.h"
14 #include "chrome/browser/prerender/prerender_manager_factory.h" 18 #include "chrome/browser/prerender/prerender_manager_factory.h"
15 #include "chrome/browser/prerender/prerender_test_utils.h" 19 #include "chrome/browser/prerender/prerender_test_utils.h"
16 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" 21 #include "chrome/browser/task_manager/task_manager_browsertest_util.h"
18 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_commands.h" 23 #include "chrome/browser/ui/browser_commands.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" 24 #include "chrome/browser/ui/tabs/tab_strip_model.h"
21 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
22 #include "chrome/grit/generated_resources.h" 26 #include "chrome/grit/generated_resources.h"
23 #include "chrome/test/base/ui_test_utils.h" 27 #include "chrome/test/base/ui_test_utils.h"
28 #include "content/public/browser/appcache_service.h"
24 #include "content/public/browser/render_process_host.h" 29 #include "content/public/browser/render_process_host.h"
30 #include "content/public/browser/storage_partition.h"
25 #include "content/public/common/result_codes.h" 31 #include "content/public/common/result_codes.h"
26 #include "content/public/common/url_constants.h" 32 #include "content/public/common/url_constants.h"
27 #include "content/public/test/browser_test_utils.h" 33 #include "content/public/test/browser_test_utils.h"
28 #include "net/base/escape.h" 34 #include "net/base/escape.h"
29 #include "net/base/load_flags.h" 35 #include "net/base/load_flags.h"
30 #include "net/dns/mock_host_resolver.h" 36 #include "net/dns/mock_host_resolver.h"
31 #include "net/test/embedded_test_server/request_handler_util.h" 37 #include "net/test/embedded_test_server/request_handler_util.h"
32 #include "testing/gtest/include/gtest/gtest.h" 38 #include "testing/gtest/include/gtest/gtest.h"
33 #include "ui/base/l10n/l10n_util.h" 39 #include "ui/base/l10n/l10n_util.h"
34 40
35 using prerender::test_utils::DestructionWaiter; 41 using prerender::test_utils::DestructionWaiter;
36 using prerender::test_utils::RequestCounter; 42 using prerender::test_utils::RequestCounter;
37 using prerender::test_utils::TestPrerender; 43 using prerender::test_utils::TestPrerender;
38 44
39 namespace prerender { 45 namespace prerender {
40 46
41 // These URLs used for test resources must be relative with the exception of 47 // These URLs used for test resources must be relative with the exception of
42 // |kPrefetchLoaderPath|. 48 // |kPrefetchLoaderPath|.
49 const char kPrefetchAppcache[] = "prerender/prefetch_appcache.html";
50 const char kPrefetchAppcacheManifest[] = "prerender/appcache.manifest";
43 const char kPrefetchImagePage[] = "prerender/prefetch_image.html"; 51 const char kPrefetchImagePage[] = "prerender/prefetch_image.html";
44 const char kPrefetchJpeg[] = "prerender/image.jpeg"; 52 const char kPrefetchJpeg[] = "prerender/image.jpeg";
45 const char kPrefetchLoaderPath[] = "/prerender/prefetch_loader.html"; 53 const char kPrefetchLoaderPath[] = "/prerender/prefetch_loader.html";
46 const char kPrefetchLoopPage[] = "prerender/prefetch_loop.html"; 54 const char kPrefetchLoopPage[] = "prerender/prefetch_loop.html";
47 const char kPrefetchMetaCSP[] = "prerender/prefetch_meta_csp.html"; 55 const char kPrefetchMetaCSP[] = "prerender/prefetch_meta_csp.html";
48 const char kPrefetchPage[] = "prerender/prefetch_page.html"; 56 const char kPrefetchPage[] = "prerender/prefetch_page.html";
49 const char kPrefetchPage2[] = "prerender/prefetch_page2.html"; 57 const char kPrefetchPage2[] = "prerender/prefetch_page2.html";
50 const char kPrefetchPng[] = "prerender/image.png"; 58 const char kPrefetchPng[] = "prerender/image.png";
51 const char kPrefetchResponseHeaderCSP[] = 59 const char kPrefetchResponseHeaderCSP[] =
52 "prerender/prefetch_response_csp.html"; 60 "prerender/prefetch_response_csp.html";
(...skipping 29 matching lines...) Expand all
82 const std::string& path_str, 90 const std::string& path_str,
83 RequestCounter* counter) { 91 RequestCounter* counter) {
84 base::FilePath url_file = ui_test_utils::GetTestFilePath( 92 base::FilePath url_file = ui_test_utils::GetTestFilePath(
85 base::FilePath(), base::FilePath::FromUTF8Unsafe(path_str)); 93 base::FilePath(), base::FilePath::FromUTF8Unsafe(path_str));
86 content::BrowserThread::PostTask( 94 content::BrowserThread::PostTask(
87 content::BrowserThread::IO, FROM_HERE, 95 content::BrowserThread::IO, FROM_HERE,
88 base::Bind(&prerender::test_utils::CreateCountingInterceptorOnIO, url, 96 base::Bind(&prerender::test_utils::CreateCountingInterceptorOnIO, url,
89 url_file, counter->AsWeakPtr())); 97 url_file, counter->AsWeakPtr()));
90 } 98 }
91 99
100 base::SimpleTestTickClock* OverridePrerenderManagerTimeTicks() {
101 auto clock = base::MakeUnique<base::SimpleTestTickClock>();
102 auto* clock_ptr = clock.get();
103 // The default zero time causes the prerender manager to do strange things.
104 clock->Advance(base::TimeDelta::FromSeconds(1));
105 GetPrerenderManager()->SetTickClockForTesting(std::move(clock));
106 return clock_ptr;
107 }
108
109 // Block until an AppCache exists for |manifest_url|.
110 void WaitForAppcache(const GURL& manifest_url) {
111 bool found_manifest = false;
112 content::AppCacheService* appcache_service =
113 content::BrowserContext::GetDefaultStoragePartition(
114 current_browser()->profile())
115 ->GetAppCacheService();
116 do {
117 base::RunLoop wait_loop;
118 content::BrowserThread::PostTask(
119 content::BrowserThread::IO, FROM_HERE,
120 base::Bind(WaitForAppcacheOnIO, manifest_url, appcache_service,
121 wait_loop.QuitClosure(), &found_manifest));
122 wait_loop.Run();
123 } while (!found_manifest);
droger 2017/04/13 13:40:29 Can we remove the while loop and just EXPECT_TRUE(
mattcary 2017/04/13 14:05:53 No, it sometimes takes a while for the manifest to
124 }
125
92 protected: 126 protected:
93 std::unique_ptr<TestPrerender> PrefetchFromURL( 127 std::unique_ptr<TestPrerender> PrefetchFromURL(
94 const GURL& target_url, 128 const GURL& target_url,
95 FinalStatus expected_final_status) { 129 FinalStatus expected_final_status) {
96 GURL loader_url = ServeLoaderURL( 130 GURL loader_url = ServeLoaderURL(
97 kPrefetchLoaderPath, "REPLACE_WITH_PREFETCH_URL", target_url, ""); 131 kPrefetchLoaderPath, "REPLACE_WITH_PREFETCH_URL", target_url, "");
98 std::vector<FinalStatus> expected_final_status_queue(1, 132 std::vector<FinalStatus> expected_final_status_queue(1,
99 expected_final_status); 133 expected_final_status);
100 std::vector<std::unique_ptr<TestPrerender>> prerenders = 134 std::vector<std::unique_ptr<TestPrerender>> prerenders =
101 NavigateWithPrerenders(loader_url, expected_final_status_queue); 135 NavigateWithPrerenders(loader_url, expected_final_status_queue);
102 prerenders[0]->WaitForStop(); 136 prerenders[0]->WaitForStop();
103 return std::move(prerenders[0]); 137 return std::move(prerenders[0]);
104 } 138 }
105 139
106 std::unique_ptr<TestPrerender> PrefetchFromFile( 140 std::unique_ptr<TestPrerender> PrefetchFromFile(
107 const std::string& html_file, 141 const std::string& html_file,
108 FinalStatus expected_final_status) { 142 FinalStatus expected_final_status) {
109 return PrefetchFromURL(src_server()->GetURL(MakeAbsolute(html_file)), 143 return PrefetchFromURL(src_server()->GetURL(MakeAbsolute(html_file)),
110 expected_final_status); 144 expected_final_status);
111 } 145 }
112 146
113 private: 147 private:
148 // Schedule a task to retrieve AppCacheInfo from |appcache_service|. This sets
149 // |found_manifest| if an appcache exists for |manifest_url|. |callback| will
150 // be called on the UI thread after the info is retrieved, whether or not the
151 // manifest exists.
152 static void WaitForAppcacheOnIO(const GURL& manifest_url,
153 content::AppCacheService* appcache_service,
154 base::Closure callback,
155 bool* found_manifest) {
156 scoped_refptr<content::AppCacheInfoCollection> info_collection =
157 new content::AppCacheInfoCollection();
158 appcache_service->GetAllAppCacheInfo(
159 info_collection.get(),
160 base::Bind(ProcessAppCacheInfo, manifest_url, callback, found_manifest,
161 info_collection));
162 }
163
164 // Look through |info_collection| for an entry matching |target_manifest|,
165 // setting |found_manifest| appropriately. Then |callback| will be invoked on
166 // the UI thread.
167 static void ProcessAppCacheInfo(
168 const GURL& target_manifest,
169 base::Closure callback,
170 bool* found_manifest,
171 scoped_refptr<content::AppCacheInfoCollection> info_collection,
172 int status) {
173 if (status == net::OK) {
174 for (const auto& origin_pair : info_collection->infos_by_origin) {
175 for (const auto& info : origin_pair.second) {
176 if (info.manifest_url == target_manifest) {
177 *found_manifest = true;
178 break;
179 }
180 }
181 }
182 }
183 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
184 callback);
185 }
186
114 DISALLOW_COPY_AND_ASSIGN(NoStatePrefetchBrowserTest); 187 DISALLOW_COPY_AND_ASSIGN(NoStatePrefetchBrowserTest);
115 }; 188 };
116 189
117 // Checks that a page is correctly prefetched in the case of a 190 // Checks that a page is correctly prefetched in the case of a
118 // <link rel=prerender> tag and the JavaScript on the page is not executed. 191 // <link rel=prerender> tag and the JavaScript on the page is not executed.
119 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, PrefetchSimple) { 192 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, PrefetchSimple) {
120 RequestCounter main_counter; 193 RequestCounter main_counter;
121 CountRequestFor(kPrefetchPage, &main_counter); 194 CountRequestFor(kPrefetchPage, &main_counter);
122 RequestCounter script_counter; 195 RequestCounter script_counter;
123 CountRequestFor(kPrefetchScript, &script_counter); 196 CountRequestFor(kPrefetchScript, &script_counter);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 "Prerender.websame_PrefetchTTFCP.Warm.Cacheable.Visible", 1); 251 "Prerender.websame_PrefetchTTFCP.Warm.Cacheable.Visible", 1);
179 histogram_tester().ExpectTotalCount( 252 histogram_tester().ExpectTotalCount(
180 "Prerender.websame_NoStatePrefetchResponseTypes", 2); 253 "Prerender.websame_NoStatePrefetchResponseTypes", 2);
181 histogram_tester().ExpectTotalCount("Prerender.websame_PrefetchAge", 1); 254 histogram_tester().ExpectTotalCount("Prerender.websame_PrefetchAge", 1);
182 } 255 }
183 256
184 // Checks the prefetch of an img tag. 257 // Checks the prefetch of an img tag.
185 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, PrefetchImage) { 258 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, PrefetchImage) {
186 RequestCounter image_counter; 259 RequestCounter image_counter;
187 CountRequestFor(kPrefetchJpeg, &image_counter); 260 CountRequestFor(kPrefetchJpeg, &image_counter);
188 base::StringPairs replacement_text; 261 GURL main_page_url =
189 replacement_text.push_back( 262 GetURLWithReplacement(kPrefetchImagePage, "REPLACE_WITH_IMAGE_URL",
190 std::make_pair("REPLACE_WITH_IMAGE_URL", MakeAbsolute(kPrefetchJpeg))); 263 MakeAbsolute(kPrefetchJpeg));
191 std::string main_page_path; 264 PrefetchFromURL(main_page_url, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED);
192 net::test_server::GetFilePathWithReplacements(
193 kPrefetchImagePage, replacement_text, &main_page_path);
194 // Note CountRequestFor cannot be used on the main page as the test server
195 // must handling the image url replacement.
196 PrefetchFromFile(main_page_path, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED);
197 image_counter.WaitForCount(1); 265 image_counter.WaitForCount(1);
198 } 266 }
199 267
200 // Checks that a cross-domain prefetching works correctly. 268 // Checks that a cross-domain prefetching works correctly.
201 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, PrefetchCrossDomain) { 269 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, PrefetchCrossDomain) {
202 static const std::string secondary_domain = "www.foo.com"; 270 static const std::string secondary_domain = "www.foo.com";
203 host_resolver()->AddRule(secondary_domain, "127.0.0.1"); 271 host_resolver()->AddRule(secondary_domain, "127.0.0.1");
204 GURL cross_domain_url(base::StringPrintf( 272 GURL cross_domain_url(base::StringPrintf(
205 "http://%s:%d/%s", secondary_domain.c_str(), 273 "http://%s:%d/%s", secondary_domain.c_str(),
206 embedded_test_server()->host_port_pair().port(), kPrefetchPage)); 274 embedded_test_server()->host_port_pair().port(), kPrefetchPage));
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, SSLSubresourceError) { 466 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, SSLSubresourceError) {
399 // First confirm that the image loads as expected. 467 // First confirm that the image loads as expected.
400 468
401 // A separate HTTPS server is started for the subresource; src_server() is 469 // A separate HTTPS server is started for the subresource; src_server() is
402 // non-HTTPS. 470 // non-HTTPS.
403 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); 471 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
404 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_MISMATCHED_NAME); 472 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_MISMATCHED_NAME);
405 https_server.ServeFilesFromSourceDirectory("chrome/test/data"); 473 https_server.ServeFilesFromSourceDirectory("chrome/test/data");
406 ASSERT_TRUE(https_server.Start()); 474 ASSERT_TRUE(https_server.Start());
407 GURL https_url = https_server.GetURL("/prerender/image.jpeg"); 475 GURL https_url = https_server.GetURL("/prerender/image.jpeg");
408 base::StringPairs replacement_text; 476 GURL main_page_url = GetURLWithReplacement(
409 replacement_text.push_back( 477 kPrefetchImagePage, "REPLACE_WITH_IMAGE_URL", https_url.spec());
410 std::make_pair("REPLACE_WITH_IMAGE_URL", https_url.spec()));
411 std::string main_page_path;
412 net::test_server::GetFilePathWithReplacements(
413 kPrefetchImagePage, replacement_text, &main_page_path);
414 RequestCounter script_counter; 478 RequestCounter script_counter;
415 CountRequestFor(kPrefetchScript, &script_counter); 479 CountRequestFor(kPrefetchScript, &script_counter);
416 480
417 std::unique_ptr<TestPrerender> prerender = 481 std::unique_ptr<TestPrerender> prerender =
418 PrefetchFromFile(main_page_path, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); 482 PrefetchFromURL(main_page_url, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED);
419 // Checks that the presumed failure of the image load didn't affect the script 483 // Checks that the presumed failure of the image load didn't affect the script
420 // fetch. This assumes waiting for the script load is enough to see any error 484 // fetch. This assumes waiting for the script load is enough to see any error
421 // from the image load. 485 // from the image load.
422 script_counter.WaitForCount(1); 486 script_counter.WaitForCount(1);
423 } 487 }
424 488
425 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, Loop) { 489 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, Loop) {
426 RequestCounter script_counter; 490 RequestCounter script_counter;
427 CountRequestFor(kPrefetchScript, &script_counter); 491 CountRequestFor(kPrefetchScript, &script_counter);
428 RequestCounter main_counter; 492 RequestCounter main_counter;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 660
597 // The SW intercepts kPrefetchPage and replaces it with a body that contains 661 // The SW intercepts kPrefetchPage and replaces it with a body that contains
598 // an <img> tage for kPrefetchPng. This verifies that the SW ran correctly by 662 // an <img> tage for kPrefetchPng. This verifies that the SW ran correctly by
599 // observing the fetch of the image. 663 // observing the fetch of the image.
600 RequestCounter image_counter; 664 RequestCounter image_counter;
601 CountRequestFor(kPrefetchPng, &image_counter); 665 CountRequestFor(kPrefetchPng, &image_counter);
602 PrefetchFromFile(kPrefetchPage, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); 666 PrefetchFromFile(kPrefetchPage, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED);
603 image_counter.WaitForCount(1); 667 image_counter.WaitForCount(1);
604 } 668 }
605 669
670 // Checks that prefetching happens if an appcache is mentioned in the html tag
671 // but is uninitialized.
672 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, AppCacheHtmlUninitialized) {
673 RequestCounter image_counter;
674 CountRequestFor(kPrefetchPng, &image_counter);
675 PrefetchFromFile(kPrefetchAppcache, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED);
676 image_counter.WaitForCount(1);
677 }
678
679 // Checks that prefetching does not if an initialized appcache is mentioned in
680 // the html tag.
681 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, AppCacheHtmlInitialized) {
682 base::TimeTicks current_time = GetPrerenderManager()->GetCurrentTimeTicks();
683 auto* clock = OverridePrerenderManagerTimeTicks();
684 // Some navigations have already occurred in test setup. In order to track
685 // duplicate prefetches correctly the test clock needs to be beyond those
686 // navigations.
687 clock->SetNowTicks(current_time);
688 clock->Advance(base::TimeDelta::FromSeconds(600));
689
690 // Fill manifest with the image url. The main resource will be cached
691 // implicitly.
692 GURL image_url = src_server()->GetURL(MakeAbsolute(kPrefetchPng));
693 GURL manifest_url = GetURLWithReplacement(
694 kPrefetchAppcacheManifest, "REPLACE_WITH_URL", image_url.spec());
695 GURL appcache_page_url = GetURLWithReplacement(
696 kPrefetchAppcache, "REPLACE_WITH_MANIFEST", manifest_url.spec());
697
698 // Load the page into the appcache.
699 ui_test_utils::NavigateToURL(current_browser(), appcache_page_url);
700
701 WaitForAppcache(manifest_url);
702
703 // If a page is prefetch shortly after being loading, the prefetch is
704 // canceled. Advancing the clock prevents the cancelation.
705 clock->Advance(base::TimeDelta::FromSeconds(6000));
706
707 RequestCounter script_counter;
708 CountRequestFor(kPrefetchScript, &script_counter);
709 // While the prefetch stops when it sees the AppCache manifest, from the point
710 // of view of the prerender manager the prefetch stops normally.
711 PrefetchFromURL(appcache_page_url, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED);
712
713 // The prefetch should have been canceled before the script in
714 // kPrefetchAppcache is loaded (note the script is not mentioned in the
715 // manifest).
716 script_counter.WaitForCount(0);
717 }
718
719 // If a page has been cached by another AppCache, the prefetch should be
720 // canceled.
721 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, AppCacheRegistered) {
722 base::TimeTicks current_time = GetPrerenderManager()->GetCurrentTimeTicks();
723 auto* clock = OverridePrerenderManagerTimeTicks();
724 // Some navigations have already occurred in test setup. In order to track
725 // duplicate prefetches correctly the test clock needs to be beyond those
726 // navigations.
727 clock->SetNowTicks(current_time);
728 clock->Advance(base::TimeDelta::FromSeconds(600));
729
730 // Fill manifest with kPrefetchPage so that it is cached without explicitly
731 // listing a manifest.
732 GURL prefetch_page_url = src_server()->GetURL(MakeAbsolute(kPrefetchPage));
733 GURL manifest_url = GetURLWithReplacement(
734 kPrefetchAppcacheManifest, "REPLACE_WITH_URL", prefetch_page_url.spec());
735
736 GURL appcache_page_url = GetURLWithReplacement(
737 kPrefetchAppcache, "REPLACE_WITH_MANIFEST", manifest_url.spec());
738
739 // Load the page into the appcache.
740 ui_test_utils::NavigateToURL(current_browser(), appcache_page_url);
741 // Load the prefetch page so it can be cached.
742 ui_test_utils::NavigateToURL(current_browser(), prefetch_page_url);
743
744 WaitForAppcache(manifest_url);
745
746 // If a page is prefetch shortly after being loading, the prefetch is
747 // canceled. Advancing the clock prevents the cancelation.
748 clock->Advance(base::TimeDelta::FromSeconds(6000));
749
750 RequestCounter page_counter;
751 CountRequestFor(kPrefetchPage, &page_counter);
752 RequestCounter script_counter;
753 CountRequestFor(kPrefetchScript, &script_counter);
754 PrefetchFromURL(prefetch_page_url, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED);
755 // Neither the page nor the script should be prefetched.
756 script_counter.WaitForCount(0);
757 page_counter.WaitForCount(0);
758 }
759
606 } // namespace prerender 760 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698