OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/file_util.h" |
| 6 #include "base/path_service.h" |
| 7 #include "base/ref_counted.h" |
5 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
6 #include "chrome/browser/download/download_manager.h" | 9 #include "chrome/browser/download/download_manager.h" |
7 #include "chrome/browser/extensions/extension_error_reporter.h" | 10 #include "chrome/browser/extensions/extension_error_reporter.h" |
8 #include "chrome/browser/profile.h" | 11 #include "chrome/browser/profile.h" |
9 #include "chrome/browser/renderer_host/site_instance.h" | 12 #include "chrome/browser/renderer_host/site_instance.h" |
10 #include "chrome/browser/tab_contents/tab_contents.h" | 13 #include "chrome/browser/tab_contents/tab_contents.h" |
11 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
12 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/notification_details.h" | 16 #include "chrome/common/notification_details.h" |
14 #include "chrome/common/notification_observer.h" | 17 #include "chrome/common/notification_observer.h" |
15 #include "chrome/common/notification_registrar.h" | 18 #include "chrome/common/notification_registrar.h" |
16 #include "chrome/common/notification_service.h" | 19 #include "chrome/common/notification_service.h" |
17 #include "chrome/common/notification_type.h" | 20 #include "chrome/common/notification_type.h" |
18 #include "chrome/test/in_process_browser_test.h" | 21 #include "chrome/test/in_process_browser_test.h" |
19 #include "chrome/test/ui_test_utils.h" | 22 #include "chrome/test/ui_test_utils.h" |
20 #include "net/base/net_util.h" | 23 #include "net/base/net_util.h" |
| 24 #include "net/test/test_server.h" |
21 | 25 |
22 class RenderViewHostManagerTest : public InProcessBrowserTest { | 26 class RenderViewHostManagerTest : public InProcessBrowserTest { |
23 public: | 27 public: |
24 RenderViewHostManagerTest() { | 28 RenderViewHostManagerTest() { |
25 EnableDOMAutomation(); | 29 EnableDOMAutomation(); |
26 } | 30 } |
27 }; | 31 }; |
28 | 32 |
29 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer | 33 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer |
30 // and target=_blank should create a new SiteInstance. | 34 // and target=_blank should create a new SiteInstance. |
31 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, | 35 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, |
32 SwapProcessWithRelNoreferrerAndTargetBlank) { | 36 SwapProcessWithRelNoreferrerAndTargetBlank) { |
33 // Start two servers with different sites. | 37 // Start two servers with different sites. |
34 const wchar_t kDocRoot[] = L"chrome/test/data"; | 38 const wchar_t kDocRoot[] = L"chrome/test/data"; |
35 scoped_refptr<HTTPTestServer> http_server = | 39 scoped_refptr<net::HTTPTestServer> http_server = |
36 HTTPTestServer::CreateServer(kDocRoot); | 40 net::HTTPTestServer::CreateServer(kDocRoot); |
37 scoped_refptr<HTTPSTestServer> https_server = | 41 scoped_refptr<net::HTTPSTestServer> https_server = |
38 HTTPSTestServer::CreateGoodServer(kDocRoot); | 42 net::HTTPSTestServer::CreateGoodServer(kDocRoot); |
39 | 43 |
40 // Load a page with links that open in a new window. | 44 // Load a page with links that open in a new window. |
41 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPage( | 45 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPage( |
42 "files/click-noreferrer-links.html")); | 46 "files/click-noreferrer-links.html")); |
43 | 47 |
44 // Get the original SiteInstance for later comparison. | 48 // Get the original SiteInstance for later comparison. |
45 scoped_refptr<SiteInstance> orig_site_instance( | 49 scoped_refptr<SiteInstance> orig_site_instance( |
46 browser()->GetSelectedTabContents()->GetSiteInstance()); | 50 browser()->GetSelectedTabContents()->GetSiteInstance()); |
47 EXPECT_TRUE(orig_site_instance != NULL); | 51 EXPECT_TRUE(orig_site_instance != NULL); |
48 | 52 |
(...skipping 19 matching lines...) Expand all Loading... |
68 browser()->GetSelectedTabContents()->GetSiteInstance()); | 72 browser()->GetSelectedTabContents()->GetSiteInstance()); |
69 EXPECT_NE(orig_site_instance, noref_blank_site_instance); | 73 EXPECT_NE(orig_site_instance, noref_blank_site_instance); |
70 } | 74 } |
71 | 75 |
72 // Test for crbug.com/24447. Following a cross-site link with just | 76 // Test for crbug.com/24447. Following a cross-site link with just |
73 // target=_blank should not create a new SiteInstance. | 77 // target=_blank should not create a new SiteInstance. |
74 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, | 78 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, |
75 DontSwapProcessWithOnlyTargetBlank) { | 79 DontSwapProcessWithOnlyTargetBlank) { |
76 // Start two servers with different sites. | 80 // Start two servers with different sites. |
77 const wchar_t kDocRoot[] = L"chrome/test/data"; | 81 const wchar_t kDocRoot[] = L"chrome/test/data"; |
78 scoped_refptr<HTTPTestServer> http_server = | 82 scoped_refptr<net::HTTPTestServer> http_server = |
79 HTTPTestServer::CreateServer(kDocRoot); | 83 net::HTTPTestServer::CreateServer(kDocRoot); |
80 scoped_refptr<HTTPSTestServer> https_server = | 84 scoped_refptr<net::HTTPSTestServer> https_server = |
81 HTTPSTestServer::CreateGoodServer(kDocRoot); | 85 net::HTTPSTestServer::CreateGoodServer(kDocRoot); |
82 | 86 |
83 // Load a page with links that open in a new window. | 87 // Load a page with links that open in a new window. |
84 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPage( | 88 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPage( |
85 "files/click-noreferrer-links.html")); | 89 "files/click-noreferrer-links.html")); |
86 | 90 |
87 // Get the original SiteInstance for later comparison. | 91 // Get the original SiteInstance for later comparison. |
88 scoped_refptr<SiteInstance> orig_site_instance( | 92 scoped_refptr<SiteInstance> orig_site_instance( |
89 browser()->GetSelectedTabContents()->GetSiteInstance()); | 93 browser()->GetSelectedTabContents()->GetSiteInstance()); |
90 EXPECT_TRUE(orig_site_instance != NULL); | 94 EXPECT_TRUE(orig_site_instance != NULL); |
91 | 95 |
(...skipping 19 matching lines...) Expand all Loading... |
111 browser()->GetSelectedTabContents()->GetSiteInstance()); | 115 browser()->GetSelectedTabContents()->GetSiteInstance()); |
112 EXPECT_EQ(orig_site_instance, blank_site_instance); | 116 EXPECT_EQ(orig_site_instance, blank_site_instance); |
113 } | 117 } |
114 | 118 |
115 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer | 119 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer |
116 // and no target=_blank should not create a new SiteInstance. | 120 // and no target=_blank should not create a new SiteInstance. |
117 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, | 121 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, |
118 DontSwapProcessWithOnlyRelNoreferrer) { | 122 DontSwapProcessWithOnlyRelNoreferrer) { |
119 // Start two servers with different sites. | 123 // Start two servers with different sites. |
120 const wchar_t kDocRoot[] = L"chrome/test/data"; | 124 const wchar_t kDocRoot[] = L"chrome/test/data"; |
121 scoped_refptr<HTTPTestServer> http_server = | 125 scoped_refptr<net::HTTPTestServer> http_server = |
122 HTTPTestServer::CreateServer(kDocRoot); | 126 net::HTTPTestServer::CreateServer(kDocRoot); |
123 scoped_refptr<HTTPSTestServer> https_server = | 127 scoped_refptr<net::HTTPSTestServer> https_server = |
124 HTTPSTestServer::CreateGoodServer(kDocRoot); | 128 net::HTTPSTestServer::CreateGoodServer(kDocRoot); |
125 | 129 |
126 // Load a page with links that open in a new window. | 130 // Load a page with links that open in a new window. |
127 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPage( | 131 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPage( |
128 "files/click-noreferrer-links.html")); | 132 "files/click-noreferrer-links.html")); |
129 | 133 |
130 // Get the original SiteInstance for later comparison. | 134 // Get the original SiteInstance for later comparison. |
131 scoped_refptr<SiteInstance> orig_site_instance( | 135 scoped_refptr<SiteInstance> orig_site_instance( |
132 browser()->GetSelectedTabContents()->GetSiteInstance()); | 136 browser()->GetSelectedTabContents()->GetSiteInstance()); |
133 EXPECT_TRUE(orig_site_instance != NULL); | 137 EXPECT_TRUE(orig_site_instance != NULL); |
134 | 138 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 &result)); | 243 &result)); |
240 EXPECT_TRUE(result); | 244 EXPECT_TRUE(result); |
241 ui_test_utils::NavigateToURL(browser(), zip_url); | 245 ui_test_utils::NavigateToURL(browser(), zip_url); |
242 | 246 |
243 ui_test_utils::WaitForDownloadCount( | 247 ui_test_utils::WaitForDownloadCount( |
244 browser()->profile()->GetDownloadManager(), 1); | 248 browser()->profile()->GetDownloadManager(), 1); |
245 | 249 |
246 browser()->CloseWindow(); | 250 browser()->CloseWindow(); |
247 BrowserClosedObserver wait_for_close(browser()); | 251 BrowserClosedObserver wait_for_close(browser()); |
248 } | 252 } |
OLD | NEW |