OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "net/base/mock_host_resolver.h" | 43 #include "net/base/mock_host_resolver.h" |
44 #include "net/url_request/url_request_context.h" | 44 #include "net/url_request/url_request_context.h" |
45 #include "net/url_request/url_request_context_getter.h" | 45 #include "net/url_request/url_request_context_getter.h" |
46 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
47 | 47 |
48 using content::BrowserThread; | 48 using content::BrowserThread; |
49 using content::DevToolsAgentHost; | 49 using content::DevToolsAgentHost; |
50 using content::DevToolsAgentHostRegistry; | 50 using content::DevToolsAgentHostRegistry; |
51 using content::DevToolsClientHost; | 51 using content::DevToolsClientHost; |
52 using content::DevToolsManager; | 52 using content::DevToolsManager; |
| 53 using content::NavigationController; |
53 using content::OpenURLParams; | 54 using content::OpenURLParams; |
54 using content::Referrer; | 55 using content::Referrer; |
55 using content::WebContents; | 56 using content::WebContents; |
56 | 57 |
57 // Prerender tests work as follows: | 58 // Prerender tests work as follows: |
58 // | 59 // |
59 // A page with a prefetch link to the test page is loaded. Once prerendered, | 60 // A page with a prefetch link to the test page is loaded. Once prerendered, |
60 // its Javascript function DidPrerenderPass() is called, which returns true if | 61 // its Javascript function DidPrerenderPass() is called, which returns true if |
61 // the page behaves as expected when prerendered. | 62 // the page behaves as expected when prerendered. |
62 // | 63 // |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 | 581 |
581 // Goes back to the page that was active before the prerender was swapped | 582 // Goes back to the page that was active before the prerender was swapped |
582 // in. This must be called when the prerendered page is the current page | 583 // in. This must be called when the prerendered page is the current page |
583 // in the active tab. | 584 // in the active tab. |
584 void GoBackToPageBeforePrerender(Browser* browser) { | 585 void GoBackToPageBeforePrerender(Browser* browser) { |
585 WebContents* tab = browser->GetSelectedWebContents(); | 586 WebContents* tab = browser->GetSelectedWebContents(); |
586 ASSERT_TRUE(tab); | 587 ASSERT_TRUE(tab); |
587 EXPECT_FALSE(tab->IsLoading()); | 588 EXPECT_FALSE(tab->IsLoading()); |
588 ui_test_utils::WindowedNotificationObserver back_nav_observer( | 589 ui_test_utils::WindowedNotificationObserver back_nav_observer( |
589 content::NOTIFICATION_LOAD_STOP, | 590 content::NOTIFICATION_LOAD_STOP, |
590 content::Source<content::NavigationController>(&tab->GetController())); | 591 content::Source<NavigationController>(&tab->GetController())); |
591 browser->GoBack(CURRENT_TAB); | 592 browser->GoBack(CURRENT_TAB); |
592 back_nav_observer.Wait(); | 593 back_nav_observer.Wait(); |
593 bool js_result; | 594 bool js_result; |
594 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 595 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
595 tab->GetRenderViewHost(), L"", | 596 tab->GetRenderViewHost(), L"", |
596 L"window.domAutomationController.send(DidBackToOriginalPagePass())", | 597 L"window.domAutomationController.send(DidBackToOriginalPagePass())", |
597 &js_result)); | 598 &js_result)); |
598 EXPECT_TRUE(js_result); | 599 EXPECT_TRUE(js_result); |
599 } | 600 } |
600 | 601 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 | 760 |
760 // In the case of zero loads, need to wait for the page load to complete | 761 // In the case of zero loads, need to wait for the page load to complete |
761 // before running any Javascript. | 762 // before running any Javascript. |
762 scoped_ptr<ui_test_utils::WindowedNotificationObserver> page_load_observer; | 763 scoped_ptr<ui_test_utils::WindowedNotificationObserver> page_load_observer; |
763 TabContents* tab_contents = | 764 TabContents* tab_contents = |
764 GetPrerenderContents()->prerender_contents()->tab_contents(); | 765 GetPrerenderContents()->prerender_contents()->tab_contents(); |
765 if (GetPrerenderContents()->number_of_loads() == 0) { | 766 if (GetPrerenderContents()->number_of_loads() == 0) { |
766 page_load_observer.reset( | 767 page_load_observer.reset( |
767 new ui_test_utils::WindowedNotificationObserver( | 768 new ui_test_utils::WindowedNotificationObserver( |
768 content::NOTIFICATION_LOAD_STOP, | 769 content::NOTIFICATION_LOAD_STOP, |
769 content::Source<content::NavigationController>( | 770 content::Source<NavigationController>( |
770 &tab_contents->GetController()))); | 771 &tab_contents->GetController()))); |
771 } | 772 } |
772 | 773 |
773 // ui_test_utils::NavigateToURL waits until DidStopLoading is called on | 774 // ui_test_utils::NavigateToURL waits until DidStopLoading is called on |
774 // the current tab. As that tab is going to end up deleted, and may never | 775 // the current tab. As that tab is going to end up deleted, and may never |
775 // finish loading before that happens, exit the message loop on the deletion | 776 // finish loading before that happens, exit the message loop on the deletion |
776 // of the used prerender contents instead. | 777 // of the used prerender contents instead. |
777 // | 778 // |
778 // As PrerenderTestURL waits until the prerendered page has completely | 779 // As PrerenderTestURL waits until the prerendered page has completely |
779 // loaded, there is no race between loading |dest_url| and swapping the | 780 // loaded, there is no race between loading |dest_url| and swapping the |
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1901 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderSessionStorage) { | 1902 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderSessionStorage) { |
1902 set_loader_path("files/prerender/prerender_loader_with_session_storage.html"); | 1903 set_loader_path("files/prerender/prerender_loader_with_session_storage.html"); |
1903 PrerenderTestURL(GetCrossDomainTestUrl("files/prerender/prerender_page.html"), | 1904 PrerenderTestURL(GetCrossDomainTestUrl("files/prerender/prerender_page.html"), |
1904 FINAL_STATUS_USED, | 1905 FINAL_STATUS_USED, |
1905 1); | 1906 1); |
1906 NavigateToDestURL(); | 1907 NavigateToDestURL(); |
1907 GoBackToPageBeforePrerender(browser()); | 1908 GoBackToPageBeforePrerender(browser()); |
1908 } | 1909 } |
1909 | 1910 |
1910 } // namespace prerender | 1911 } // namespace prerender |
OLD | NEW |