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 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/browser_list.h" | 26 #include "chrome/browser/ui/browser_list.h" |
27 #include "chrome/browser/ui/browser_window.h" | 27 #include "chrome/browser/ui/browser_window.h" |
28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
29 #include "chrome/common/chrome_notification_types.h" | 29 #include "chrome/common/chrome_notification_types.h" |
30 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
31 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
32 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
33 #include "chrome/test/base/in_process_browser_test.h" | 33 #include "chrome/test/base/in_process_browser_test.h" |
34 #include "chrome/test/base/ui_test_utils.h" | 34 #include "chrome/test/base/ui_test_utils.h" |
35 #include "content/browser/debugger/devtools_client_host.h" | |
36 #include "content/browser/debugger/devtools_manager.h" | |
37 #include "content/browser/renderer_host/render_view_host.h" | 35 #include "content/browser/renderer_host/render_view_host.h" |
38 #include "content/browser/tab_contents/tab_contents.h" | 36 #include "content/browser/tab_contents/tab_contents.h" |
| 37 #include "content/public/browser/devtools_agent_host_registry.h" |
| 38 #include "content/public/browser/devtools_client_host.h" |
| 39 #include "content/public/browser/devtools_manager.h" |
39 #include "content/public/browser/notification_service.h" | 40 #include "content/public/browser/notification_service.h" |
40 #include "content/public/common/url_constants.h" | 41 #include "content/public/common/url_constants.h" |
41 #include "grit/generated_resources.h" | 42 #include "grit/generated_resources.h" |
42 #include "net/base/mock_host_resolver.h" | 43 #include "net/base/mock_host_resolver.h" |
43 #include "net/url_request/url_request_context.h" | 44 #include "net/url_request/url_request_context.h" |
44 #include "net/url_request/url_request_context_getter.h" | 45 #include "net/url_request/url_request_context_getter.h" |
45 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
46 | 47 |
47 using content::BrowserThread; | 48 using content::BrowserThread; |
| 49 using content::DevToolsAgentHost; |
| 50 using content::DevToolsAgentHostRegistry; |
| 51 using content::DevToolsClientHost; |
| 52 using content::DevToolsManager; |
48 | 53 |
49 // Prerender tests work as follows: | 54 // Prerender tests work as follows: |
50 // | 55 // |
51 // A page with a prefetch link to the test page is loaded. Once prerendered, | 56 // A page with a prefetch link to the test page is loaded. Once prerendered, |
52 // its Javascript function DidPrerenderPass() is called, which returns true if | 57 // its Javascript function DidPrerenderPass() is called, which returns true if |
53 // the page behaves as expected when prerendered. | 58 // the page behaves as expected when prerendered. |
54 // | 59 // |
55 // The prerendered page is then displayed on a tab. The Javascript function | 60 // The prerendered page is then displayed on a tab. The Javascript function |
56 // DidDisplayPass() is called, and returns true if the page behaved as it | 61 // DidDisplayPass() is called, and returns true if the page behaved as it |
57 // should while being displayed. | 62 // should while being displayed. |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 } | 393 } |
389 | 394 |
390 private: | 395 private: |
391 FakeSafeBrowsingService* most_recent_service_; | 396 FakeSafeBrowsingService* most_recent_service_; |
392 }; | 397 }; |
393 #endif | 398 #endif |
394 | 399 |
395 class FakeDevToolsClientHost : public DevToolsClientHost { | 400 class FakeDevToolsClientHost : public DevToolsClientHost { |
396 public: | 401 public: |
397 FakeDevToolsClientHost() {} | 402 FakeDevToolsClientHost() {} |
398 virtual ~FakeDevToolsClientHost() { | 403 virtual ~FakeDevToolsClientHost() {} |
399 NotifyCloseListener(); | |
400 } | |
401 virtual void InspectedTabClosing() OVERRIDE {} | 404 virtual void InspectedTabClosing() OVERRIDE {} |
402 virtual void FrameNavigating(const std::string& url) OVERRIDE {} | 405 virtual void FrameNavigating(const std::string& url) OVERRIDE {} |
403 virtual void SendMessageToClient(const IPC::Message& msg) OVERRIDE {} | 406 virtual void DispatchOnInspectorFrontend(const std::string& msg) OVERRIDE {} |
404 virtual void TabReplaced(TabContents* new_tab) OVERRIDE {} | 407 virtual void TabReplaced(TabContents* new_tab) OVERRIDE {} |
405 }; | 408 }; |
406 | 409 |
407 } // namespace | 410 } // namespace |
408 | 411 |
409 class PrerenderBrowserTest : public InProcessBrowserTest { | 412 class PrerenderBrowserTest : public InProcessBrowserTest { |
410 public: | 413 public: |
411 PrerenderBrowserTest() | 414 PrerenderBrowserTest() |
412 : prerender_contents_factory_(NULL), | 415 : prerender_contents_factory_(NULL), |
413 #if defined(ENABLE_SAFE_BROWSING) | 416 #if defined(ENABLE_SAFE_BROWSING) |
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 PrerenderTestURL("files/prerender/prerender_page_with_link.html", | 1832 PrerenderTestURL("files/prerender/prerender_page_with_link.html", |
1830 FINAL_STATUS_SESSION_STORAGE_NAMESPACE_MISMATCH, | 1833 FINAL_STATUS_SESSION_STORAGE_NAMESPACE_MISMATCH, |
1831 1); | 1834 1); |
1832 OpenDestURLViaClickNewBackgroundTab(); | 1835 OpenDestURLViaClickNewBackgroundTab(); |
1833 } | 1836 } |
1834 | 1837 |
1835 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 1838 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
1836 NavigateToPrerenderedPageWhenDevToolsAttached) { | 1839 NavigateToPrerenderedPageWhenDevToolsAttached) { |
1837 DisableJavascriptCalls(); | 1840 DisableJavascriptCalls(); |
1838 TabContents* tab_contents = browser()->GetSelectedTabContents(); | 1841 TabContents* tab_contents = browser()->GetSelectedTabContents(); |
1839 RenderViewHost* inspected_rvh = tab_contents->render_view_host(); | 1842 DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost( |
| 1843 tab_contents->render_view_host()); |
1840 DevToolsManager* manager = DevToolsManager::GetInstance(); | 1844 DevToolsManager* manager = DevToolsManager::GetInstance(); |
1841 FakeDevToolsClientHost client_host; | 1845 FakeDevToolsClientHost client_host; |
1842 manager->RegisterDevToolsClientHostFor(inspected_rvh, &client_host); | 1846 manager->RegisterDevToolsClientHostFor(agent, &client_host); |
1843 const char* url = "files/prerender/prerender_page.html"; | 1847 const char* url = "files/prerender/prerender_page.html"; |
1844 PrerenderTestURL(url, FINAL_STATUS_DEVTOOLS_ATTACHED, 1); | 1848 PrerenderTestURL(url, FINAL_STATUS_DEVTOOLS_ATTACHED, 1); |
1845 NavigateToURL(url); | 1849 NavigateToURL(url); |
| 1850 manager->ClientHostClosing(&client_host); |
1846 } | 1851 } |
1847 | 1852 |
1848 // Validate that the sessionStorage namespace remains the same when swapping | 1853 // Validate that the sessionStorage namespace remains the same when swapping |
1849 // in a prerendered page. | 1854 // in a prerendered page. |
1850 // http://crbug.com/103563 | 1855 // http://crbug.com/103563 |
1851 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderSessionStorage) { | 1856 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderSessionStorage) { |
1852 set_loader_path("files/prerender/prerender_loader_with_session_storage.html"); | 1857 set_loader_path("files/prerender/prerender_loader_with_session_storage.html"); |
1853 PrerenderTestURL(GetCrossDomainTestUrl("files/prerender/prerender_page.html"), | 1858 PrerenderTestURL(GetCrossDomainTestUrl("files/prerender/prerender_page.html"), |
1854 FINAL_STATUS_USED, | 1859 FINAL_STATUS_USED, |
1855 1); | 1860 1); |
1856 NavigateToDestURL(); | 1861 NavigateToDestURL(); |
1857 GoBackToPageBeforePrerender(browser()); | 1862 GoBackToPageBeforePrerender(browser()); |
1858 } | 1863 } |
1859 | 1864 |
1860 } // namespace prerender | 1865 } // namespace prerender |
OLD | NEW |