| 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 "chrome/browser/browser.h" | 5 #include "chrome/browser/browser.h" |
| 6 #include "chrome/browser/download/download_manager.h" | 6 #include "chrome/browser/download/download_manager.h" |
| 7 #include "chrome/browser/extensions/extension_error_reporter.h" | 7 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 8 #include "chrome/browser/profile.h" | 8 #include "chrome/browser/profile.h" |
| 9 #include "chrome/browser/renderer_host/site_instance.h" | 9 #include "chrome/browser/renderer_host/site_instance.h" |
| 10 #include "chrome/browser/tab_contents/tab_contents.h" | 10 #include "chrome/browser/tab_contents/tab_contents.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 } | 26 } |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer | 29 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer |
| 30 // and target=_blank should create a new SiteInstance. | 30 // and target=_blank should create a new SiteInstance. |
| 31 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, | 31 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, |
| 32 SwapProcessWithRelNoreferrerAndTargetBlank) { | 32 SwapProcessWithRelNoreferrerAndTargetBlank) { |
| 33 // Start two servers with different sites. | 33 // Start two servers with different sites. |
| 34 const wchar_t kDocRoot[] = L"chrome/test/data"; | 34 const wchar_t kDocRoot[] = L"chrome/test/data"; |
| 35 scoped_refptr<HTTPTestServer> http_server = | 35 scoped_refptr<HTTPTestServer> http_server = |
| 36 HTTPTestServer::CreateServer(kDocRoot, NULL); | 36 HTTPTestServer::CreateServer(kDocRoot); |
| 37 scoped_refptr<HTTPSTestServer> https_server = | 37 scoped_refptr<HTTPSTestServer> https_server = |
| 38 HTTPSTestServer::CreateGoodServer(kDocRoot); | 38 HTTPSTestServer::CreateGoodServer(kDocRoot); |
| 39 | 39 |
| 40 // Load a page with links that open in a new window. | 40 // Load a page with links that open in a new window. |
| 41 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPage( | 41 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPage( |
| 42 "files/click-noreferrer-links.html")); | 42 "files/click-noreferrer-links.html")); |
| 43 | 43 |
| 44 // Get the original SiteInstance for later comparison. | 44 // Get the original SiteInstance for later comparison. |
| 45 scoped_refptr<SiteInstance> orig_site_instance( | 45 scoped_refptr<SiteInstance> orig_site_instance( |
| 46 browser()->GetSelectedTabContents()->GetSiteInstance()); | 46 browser()->GetSelectedTabContents()->GetSiteInstance()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 69 EXPECT_NE(orig_site_instance, noref_blank_site_instance); | 69 EXPECT_NE(orig_site_instance, noref_blank_site_instance); |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Test for crbug.com/24447. Following a cross-site link with just | 72 // Test for crbug.com/24447. Following a cross-site link with just |
| 73 // target=_blank should not create a new SiteInstance. | 73 // target=_blank should not create a new SiteInstance. |
| 74 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, | 74 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, |
| 75 DontSwapProcessWithOnlyTargetBlank) { | 75 DontSwapProcessWithOnlyTargetBlank) { |
| 76 // Start two servers with different sites. | 76 // Start two servers with different sites. |
| 77 const wchar_t kDocRoot[] = L"chrome/test/data"; | 77 const wchar_t kDocRoot[] = L"chrome/test/data"; |
| 78 scoped_refptr<HTTPTestServer> http_server = | 78 scoped_refptr<HTTPTestServer> http_server = |
| 79 HTTPTestServer::CreateServer(kDocRoot, NULL); | 79 HTTPTestServer::CreateServer(kDocRoot); |
| 80 scoped_refptr<HTTPSTestServer> https_server = | 80 scoped_refptr<HTTPSTestServer> https_server = |
| 81 HTTPSTestServer::CreateGoodServer(kDocRoot); | 81 HTTPSTestServer::CreateGoodServer(kDocRoot); |
| 82 | 82 |
| 83 // Load a page with links that open in a new window. | 83 // Load a page with links that open in a new window. |
| 84 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPage( | 84 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPage( |
| 85 "files/click-noreferrer-links.html")); | 85 "files/click-noreferrer-links.html")); |
| 86 | 86 |
| 87 // Get the original SiteInstance for later comparison. | 87 // Get the original SiteInstance for later comparison. |
| 88 scoped_refptr<SiteInstance> orig_site_instance( | 88 scoped_refptr<SiteInstance> orig_site_instance( |
| 89 browser()->GetSelectedTabContents()->GetSiteInstance()); | 89 browser()->GetSelectedTabContents()->GetSiteInstance()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 112 EXPECT_EQ(orig_site_instance, blank_site_instance); | 112 EXPECT_EQ(orig_site_instance, blank_site_instance); |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer | 115 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer |
| 116 // and no target=_blank should not create a new SiteInstance. | 116 // and no target=_blank should not create a new SiteInstance. |
| 117 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, | 117 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, |
| 118 DontSwapProcessWithOnlyRelNoreferrer) { | 118 DontSwapProcessWithOnlyRelNoreferrer) { |
| 119 // Start two servers with different sites. | 119 // Start two servers with different sites. |
| 120 const wchar_t kDocRoot[] = L"chrome/test/data"; | 120 const wchar_t kDocRoot[] = L"chrome/test/data"; |
| 121 scoped_refptr<HTTPTestServer> http_server = | 121 scoped_refptr<HTTPTestServer> http_server = |
| 122 HTTPTestServer::CreateServer(kDocRoot, NULL); | 122 HTTPTestServer::CreateServer(kDocRoot); |
| 123 scoped_refptr<HTTPSTestServer> https_server = | 123 scoped_refptr<HTTPSTestServer> https_server = |
| 124 HTTPSTestServer::CreateGoodServer(kDocRoot); | 124 HTTPSTestServer::CreateGoodServer(kDocRoot); |
| 125 | 125 |
| 126 // Load a page with links that open in a new window. | 126 // Load a page with links that open in a new window. |
| 127 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPage( | 127 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPage( |
| 128 "files/click-noreferrer-links.html")); | 128 "files/click-noreferrer-links.html")); |
| 129 | 129 |
| 130 // Get the original SiteInstance for later comparison. | 130 // Get the original SiteInstance for later comparison. |
| 131 scoped_refptr<SiteInstance> orig_site_instance( | 131 scoped_refptr<SiteInstance> orig_site_instance( |
| 132 browser()->GetSelectedTabContents()->GetSiteInstance()); | 132 browser()->GetSelectedTabContents()->GetSiteInstance()); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 &result)); | 239 &result)); |
| 240 EXPECT_TRUE(result); | 240 EXPECT_TRUE(result); |
| 241 ui_test_utils::NavigateToURL(browser(), zip_url); | 241 ui_test_utils::NavigateToURL(browser(), zip_url); |
| 242 | 242 |
| 243 ui_test_utils::WaitForDownloadCount( | 243 ui_test_utils::WaitForDownloadCount( |
| 244 browser()->profile()->GetDownloadManager(), 1); | 244 browser()->profile()->GetDownloadManager(), 1); |
| 245 | 245 |
| 246 browser()->CloseWindow(); | 246 browser()->CloseWindow(); |
| 247 BrowserClosedObserver wait_for_close(browser()); | 247 BrowserClosedObserver wait_for_close(browser()); |
| 248 } | 248 } |
| OLD | NEW |