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

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

Issue 2656653002: Suppress NEW_NAVIGATION_ENTRY prerenderer failures for ORIGIN_OFFLINE (Closed)
Patch Set: Simple cancel any subresources with unsupported schemes and continue for Offline requests Created 3 years, 10 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_contents.cc » ('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 <stddef.h> 5 #include <stddef.h>
6 #include <deque> 6 #include <deque>
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <unordered_map> 9 #include <unordered_map>
10 #include <utility> 10 #include <utility>
(...skipping 2805 matching lines...) Expand 10 before | Expand all | Expand 10 after
2816 base::StringPairs replacement_text; 2816 base::StringPairs replacement_text;
2817 replacement_text.push_back( 2817 replacement_text.push_back(
2818 std::make_pair("REPLACE_WITH_IMAGE_URL", image_url.spec())); 2818 std::make_pair("REPLACE_WITH_IMAGE_URL", image_url.spec()));
2819 std::string replacement_path; 2819 std::string replacement_path;
2820 net::test_server::GetFilePathWithReplacements( 2820 net::test_server::GetFilePathWithReplacements(
2821 "/prerender/prerender_with_image.html", replacement_text, 2821 "/prerender/prerender_with_image.html", replacement_text,
2822 &replacement_path); 2822 &replacement_path);
2823 PrerenderTestURL(replacement_path, FINAL_STATUS_UNSUPPORTED_SCHEME, 0); 2823 PrerenderTestURL(replacement_path, FINAL_STATUS_UNSUPPORTED_SCHEME, 0);
2824 } 2824 }
2825 2825
2826 // Checks that non-http/https/chrome-extension subresource does not cancel the
2827 // prerender.
2828 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
2829 PrerenderSubresourceUnsupportedSchemeForOffline) {
2830 // Set up a page with unsupported subresource.
2831 GURL image_url = GURL("invalidscheme://www.google.com/test.jpg");
2832 base::StringPairs replacement_text;
2833 replacement_text.push_back(
2834 std::make_pair("REPLACE_WITH_IMAGE_URL", image_url.spec()));
2835 std::string replacement_path;
2836 net::test_server::GetFilePathWithReplacements(
2837 "/prerender/prerender_with_image.html", replacement_text,
2838 &replacement_path);
2839 const GURL url = src_server()->GetURL(MakeAbsolute(replacement_path));
2840
2841 // Navigate to about:blank to get the session storage namespace.
2842 ui_test_utils::NavigateToURL(current_browser(), GURL(url::kAboutBlankURL));
2843 content::SessionStorageNamespace* storage_namespace =
2844 GetActiveWebContents()
2845 ->GetController()
2846 .GetDefaultSessionStorageNamespace();
2847
2848 std::unique_ptr<TestPrerender> test_prerender =
2849 prerender_contents_factory()->ExpectPrerenderContents(
2850 FINAL_STATUS_APP_TERMINATING);
2851
2852 std::unique_ptr<PrerenderHandle> prerender_handle(
2853 GetPrerenderManager()->AddPrerenderForOffline(url, storage_namespace,
2854 gfx::Size(640, 480)));
2855 ASSERT_EQ(prerender_handle->contents(), test_prerender->contents());
2856 test_prerender->WaitForLoads(1);
2857 }
2858
2826 // Ensure that about:blank is permitted for any subresource. 2859 // Ensure that about:blank is permitted for any subresource.
2827 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, 2860 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
2828 PrerenderAllowAboutBlankSubresource) { 2861 PrerenderAllowAboutBlankSubresource) {
2829 GURL image_url = GURL("about:blank"); 2862 GURL image_url = GURL("about:blank");
2830 base::StringPairs replacement_text; 2863 base::StringPairs replacement_text;
2831 replacement_text.push_back( 2864 replacement_text.push_back(
2832 std::make_pair("REPLACE_WITH_IMAGE_URL", image_url.spec())); 2865 std::make_pair("REPLACE_WITH_IMAGE_URL", image_url.spec()));
2833 std::string replacement_path; 2866 std::string replacement_path;
2834 net::test_server::GetFilePathWithReplacements( 2867 net::test_server::GetFilePathWithReplacements(
2835 "/prerender/prerender_with_image.html", replacement_text, 2868 "/prerender/prerender_with_image.html", replacement_text,
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
3103 NavigateToURLWithParams(params, false); 3136 NavigateToURLWithParams(params, false);
3104 } 3137 }
3105 3138
3106 // Checks that the prerendering of a page is canceled correctly when the 3139 // Checks that the prerendering of a page is canceled correctly when the
3107 // prerendered page tries to make a second navigation entry. 3140 // prerendered page tries to make a second navigation entry.
3108 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderNewNavigationEntry) { 3141 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderNewNavigationEntry) {
3109 PrerenderTestURL("/prerender/prerender_new_entry.html", 3142 PrerenderTestURL("/prerender/prerender_new_entry.html",
3110 FINAL_STATUS_NEW_NAVIGATION_ENTRY, 1); 3143 FINAL_STATUS_NEW_NAVIGATION_ENTRY, 1);
3111 } 3144 }
3112 3145
3146 // Checks that the prerendering of a page for ORIGIN_OFFLINE is not canceled
3147 // when the prerendered page tries to make a second navigation entry.
3148 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
3149 PrerenderNewNavigationEntryForOffline) {
3150 // Navigate to about:blank to get the session storage namespace.
3151 ui_test_utils::NavigateToURL(current_browser(), GURL(url::kAboutBlankURL));
3152 content::SessionStorageNamespace* storage_namespace =
3153 GetActiveWebContents()
3154 ->GetController()
3155 .GetDefaultSessionStorageNamespace();
3156
3157 std::unique_ptr<TestPrerender> test_prerender =
3158 prerender_contents_factory()->ExpectPrerenderContents(
3159 FINAL_STATUS_APP_TERMINATING);
3160
3161 const GURL url =
3162 src_server()->GetURL(MakeAbsolute("/prerender/prerender_new_entry.html"));
3163 std::unique_ptr<PrerenderHandle> prerender_handle(
3164 GetPrerenderManager()->AddPrerenderForOffline(url, storage_namespace,
3165 gfx::Size(640, 480)));
3166 ASSERT_EQ(prerender_handle->contents(), test_prerender->contents());
3167 test_prerender->WaitForLoads(2);
3168 ASSERT_EQ(1, GetActiveWebContents()->GetController().GetEntryCount());
3169 }
3170
3113 // Attempt a swap-in in a new tab. The session storage doesn't match, so it 3171 // Attempt a swap-in in a new tab. The session storage doesn't match, so it
3114 // should not swap. 3172 // should not swap.
3115 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPageNewTab) { 3173 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPageNewTab) {
3116 PrerenderTestURL("/prerender/prerender_page.html", 3174 PrerenderTestURL("/prerender/prerender_page.html",
3117 FINAL_STATUS_APP_TERMINATING, 1); 3175 FINAL_STATUS_APP_TERMINATING, 1);
3118 3176
3119 // Open a new tab to navigate in. 3177 // Open a new tab to navigate in.
3120 ui_test_utils::NavigateToURLWithDisposition( 3178 ui_test_utils::NavigateToURLWithDisposition(
3121 current_browser(), GURL(url::kAboutBlankURL), 3179 current_browser(), GURL(url::kAboutBlankURL),
3122 WindowOpenDisposition::NEW_FOREGROUND_TAB, 3180 WindowOpenDisposition::NEW_FOREGROUND_TAB,
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
3757 browser()->tab_strip_model()->GetActiveWebContents(); 3815 browser()->tab_strip_model()->GetActiveWebContents();
3758 bool display_test_result = false; 3816 bool display_test_result = false;
3759 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, 3817 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents,
3760 "DidDisplayReallyPass()", 3818 "DidDisplayReallyPass()",
3761 &display_test_result)); 3819 &display_test_result));
3762 ASSERT_TRUE(display_test_result); 3820 ASSERT_TRUE(display_test_result);
3763 } 3821 }
3764 #endif // !defined(DISABLE_NACL) 3822 #endif // !defined(DISABLE_NACL)
3765 3823
3766 } // namespace prerender 3824 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698