Chromium Code Reviews| 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 <deque> | 5 #include <deque> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 #include "chrome/common/chrome_switches.h" | 47 #include "chrome/common/chrome_switches.h" |
| 48 #include "chrome/common/extensions/extension_constants.h" | 48 #include "chrome/common/extensions/extension_constants.h" |
| 49 #include "chrome/common/pref_names.h" | 49 #include "chrome/common/pref_names.h" |
| 50 #include "chrome/test/base/in_process_browser_test.h" | 50 #include "chrome/test/base/in_process_browser_test.h" |
| 51 #include "chrome/test/base/test_switches.h" | 51 #include "chrome/test/base/test_switches.h" |
| 52 #include "chrome/test/base/ui_test_utils.h" | 52 #include "chrome/test/base/ui_test_utils.h" |
| 53 #include "content/public/browser/browser_message_filter.h" | 53 #include "content/public/browser/browser_message_filter.h" |
| 54 #include "content/public/browser/devtools_agent_host.h" | 54 #include "content/public/browser/devtools_agent_host.h" |
| 55 #include "content/public/browser/devtools_client_host.h" | 55 #include "content/public/browser/devtools_client_host.h" |
| 56 #include "content/public/browser/devtools_manager.h" | 56 #include "content/public/browser/devtools_manager.h" |
| 57 #include "content/public/browser/navigation_controller.h" | |
| 58 #include "content/public/browser/navigation_entry.h" | |
| 57 #include "content/public/browser/notification_service.h" | 59 #include "content/public/browser/notification_service.h" |
| 58 #include "content/public/browser/render_process_host.h" | 60 #include "content/public/browser/render_process_host.h" |
| 59 #include "content/public/browser/render_view_host.h" | 61 #include "content/public/browser/render_view_host.h" |
| 60 #include "content/public/browser/site_instance.h" | 62 #include "content/public/browser/site_instance.h" |
| 61 #include "content/public/browser/web_contents.h" | 63 #include "content/public/browser/web_contents.h" |
| 62 #include "content/public/common/url_constants.h" | 64 #include "content/public/common/url_constants.h" |
| 63 #include "content/public/test/browser_test_utils.h" | 65 #include "content/public/test/browser_test_utils.h" |
| 64 #include "content/public/test/test_navigation_observer.h" | 66 #include "content/public/test/test_navigation_observer.h" |
| 65 #include "content/public/test/test_utils.h" | 67 #include "content/public/test/test_utils.h" |
| 66 #include "content/test/net/url_request_mock_http_job.h" | 68 #include "content/test/net/url_request_mock_http_job.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 93 // the page behaves as expected when prerendered. | 95 // the page behaves as expected when prerendered. |
| 94 // | 96 // |
| 95 // The prerendered page is then displayed on a tab. The Javascript function | 97 // The prerendered page is then displayed on a tab. The Javascript function |
| 96 // DidDisplayPass() is called, and returns true if the page behaved as it | 98 // DidDisplayPass() is called, and returns true if the page behaved as it |
| 97 // should while being displayed. | 99 // should while being displayed. |
| 98 | 100 |
| 99 namespace prerender { | 101 namespace prerender { |
| 100 | 102 |
| 101 namespace { | 103 namespace { |
| 102 | 104 |
| 105 const char* kBlankURL = "about:blank"; | |
|
mmenke
2013/12/12 15:52:12
Should probable just use content::kAboutBlankURL (
davidben
2013/12/12 16:58:47
Done.
| |
| 106 | |
| 103 // Constants used in the test HTML files. | 107 // Constants used in the test HTML files. |
| 104 static const char* kReadyTitle = "READY"; | 108 const char* kReadyTitle = "READY"; |
| 105 static const char* kPassTitle = "PASS"; | 109 const char* kPassTitle = "PASS"; |
| 106 | 110 |
| 107 std::string CreateClientRedirect(const std::string& dest_url) { | 111 std::string CreateClientRedirect(const std::string& dest_url) { |
| 108 const char* const kClientRedirectBase = "client-redirect?"; | 112 const char* const kClientRedirectBase = "client-redirect?"; |
| 109 return kClientRedirectBase + net::EscapeQueryParamValue(dest_url, false); | 113 return kClientRedirectBase + net::EscapeQueryParamValue(dest_url, false); |
| 110 } | 114 } |
| 111 | 115 |
| 112 std::string CreateServerRedirect(const std::string& dest_url) { | 116 std::string CreateServerRedirect(const std::string& dest_url) { |
| 113 const char* const kServerRedirectBase = "server-redirect?"; | 117 const char* const kServerRedirectBase = "server-redirect?"; |
| 114 return kServerRedirectBase + net::EscapeQueryParamValue(dest_url, false); | 118 return kServerRedirectBase + net::EscapeQueryParamValue(dest_url, false); |
| 115 } | 119 } |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 822 false); | 826 false); |
| 823 } | 827 } |
| 824 | 828 |
| 825 void NavigateToDestURL() const { | 829 void NavigateToDestURL() const { |
| 826 NavigateToDestURLWithDisposition(CURRENT_TAB, true); | 830 NavigateToDestURLWithDisposition(CURRENT_TAB, true); |
| 827 } | 831 } |
| 828 | 832 |
| 829 void NavigateToDestURLInNewTab() const { | 833 void NavigateToDestURLInNewTab() const { |
| 830 // First, open a new tab. | 834 // First, open a new tab. |
| 831 current_browser()->OpenURL( | 835 current_browser()->OpenURL( |
| 832 content::OpenURLParams(GURL("chrome://blank"), Referrer(), | 836 content::OpenURLParams(GURL(kBlankURL), Referrer(), |
|
Charlie Reis
2013/12/12 02:46:38
This looks like an improvement to me, though it's
davidben
2013/12/12 16:58:47
It gives me ERR_INVALID_URL. But when I tried asse
Charlie Reis
2013/12/12 17:30:35
That could be FilterURL rewriting an illegal URL a
davidben
2013/12/13 01:00:39
(Turns out I'm actually confused and this function
| |
| 833 NEW_FOREGROUND_TAB, | 837 NEW_FOREGROUND_TAB, |
| 834 content::PAGE_TRANSITION_TYPED, false)); | 838 content::PAGE_TRANSITION_TYPED, false)); |
| 835 // Next, navigate to the destination URL. The swap-in will not succeed, | 839 // Next, navigate to the destination URL. The swap-in will not succeed, |
| 836 // due to session storage namespace mismatch. The merge is only kicked off | 840 // due to session storage namespace mismatch. The merge is only kicked off |
| 837 // asynchronously. | 841 // asynchronously. |
| 838 NavigateToDestURLWithDisposition(CURRENT_TAB, false); | 842 NavigateToDestURLWithDisposition(CURRENT_TAB, false); |
| 839 // Run the message loop, waiting for the merge to complete, the swapin to | 843 // Run the message loop, waiting for the merge to complete, the swapin to |
| 840 // be reattempted, and to eventually succeed. | 844 // be reattempted, and to eventually succeed. |
| 841 content::RunMessageLoop(); | 845 content::RunMessageLoop(); |
| 842 } | 846 } |
| (...skipping 2498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3341 1); | 3345 1); |
| 3342 } | 3346 } |
| 3343 | 3347 |
| 3344 // Attempt a swap-in in a new tab, verifying that session storage namespace | 3348 // Attempt a swap-in in a new tab, verifying that session storage namespace |
| 3345 // merging works. | 3349 // merging works. |
| 3346 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPageNewTab) { | 3350 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPageNewTab) { |
| 3347 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | 3351 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); |
| 3348 NavigateToDestURLInNewTab(); | 3352 NavigateToDestURLInNewTab(); |
| 3349 } | 3353 } |
| 3350 | 3354 |
| 3355 // Checks that prerenders honor |should_replace_current_entry|. | |
| 3356 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderReplaceCurrentEntry) { | |
| 3357 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | |
| 3358 | |
| 3359 content::OpenURLParams params(dest_url(), Referrer(), CURRENT_TAB, | |
| 3360 content::PAGE_TRANSITION_TYPED, false); | |
| 3361 params.should_replace_current_entry = true; | |
| 3362 NavigateToURLWithParams(params, false); | |
| 3363 | |
| 3364 WebContents* web_contents = | |
| 3365 current_browser()->tab_strip_model()->GetActiveWebContents(); | |
| 3366 const NavigationController& controller = web_contents->GetController(); | |
| 3367 // First entry is about:blank, second is prerender_page.html. | |
| 3368 EXPECT_TRUE(controller.GetPendingEntry() == NULL); | |
| 3369 EXPECT_EQ(2, controller.GetEntryCount()); | |
| 3370 EXPECT_EQ(GURL(kBlankURL), controller.GetEntryAtIndex(0)->GetURL()); | |
| 3371 EXPECT_EQ(dest_url(), controller.GetEntryAtIndex(1)->GetURL()); | |
| 3372 } | |
| 3373 | |
| 3351 } // namespace prerender | 3374 } // namespace prerender |
| OLD | NEW |