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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/ref_counted.h" | 7 #include "base/ref_counted.h" |
8 #include "chrome/browser/download/download_manager.h" | 8 #include "chrome/browser/download/download_manager.h" |
9 #include "chrome/browser/extensions/extension_error_reporter.h" | 9 #include "chrome/browser/extensions/extension_error_reporter.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 &result)); | 268 &result)); |
269 EXPECT_TRUE(result); | 269 EXPECT_TRUE(result); |
270 ui_test_utils::NavigateToURL(browser(), zip_url); | 270 ui_test_utils::NavigateToURL(browser(), zip_url); |
271 | 271 |
272 ui_test_utils::WaitForDownloadCount( | 272 ui_test_utils::WaitForDownloadCount( |
273 browser()->profile()->GetDownloadManager(), 1); | 273 browser()->profile()->GetDownloadManager(), 1); |
274 | 274 |
275 browser()->CloseWindow(); | 275 browser()->CloseWindow(); |
276 BrowserClosedObserver wait_for_close(browser()); | 276 BrowserClosedObserver wait_for_close(browser()); |
277 } | 277 } |
| 278 |
| 279 // Test for crbug.com/76666. A cross-site navigation that fails with a 204 |
| 280 // error should not make us ignore future renderer-initiated navigations. |
| 281 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, ClickLinkAfter204Error) { |
| 282 // Start two servers with different sites. |
| 283 ASSERT_TRUE(test_server()->Start()); |
| 284 net::TestServer https_server( |
| 285 net::TestServer::TYPE_HTTPS, |
| 286 FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
| 287 ASSERT_TRUE(https_server.Start()); |
| 288 |
| 289 // Load a page with links that open in a new window. |
| 290 // The links will point to the HTTPS server. |
| 291 std::string replacement_path; |
| 292 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( |
| 293 "files/click-noreferrer-links.html", |
| 294 https_server.host_port_pair(), |
| 295 &replacement_path)); |
| 296 ui_test_utils::NavigateToURL(browser(), |
| 297 test_server()->GetURL(replacement_path)); |
| 298 |
| 299 // Get the original SiteInstance for later comparison. |
| 300 scoped_refptr<SiteInstance> orig_site_instance( |
| 301 browser()->GetSelectedTabContents()->GetSiteInstance()); |
| 302 EXPECT_TRUE(orig_site_instance != NULL); |
| 303 |
| 304 // Load a cross-site page that fails with a 204 error. |
| 305 ui_test_utils::NavigateToURL(browser(), https_server.GetURL("nocontent")); |
| 306 |
| 307 // We should still be looking at the normal page. |
| 308 scoped_refptr<SiteInstance> post_nav_site_instance( |
| 309 browser()->GetSelectedTabContents()->GetSiteInstance()); |
| 310 EXPECT_EQ(orig_site_instance, post_nav_site_instance); |
| 311 EXPECT_EQ("/files/click-noreferrer-links.html", |
| 312 browser()->GetSelectedTabContents()->GetURL().path()); |
| 313 |
| 314 // Renderer-initiated navigations should work. |
| 315 bool success = false; |
| 316 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 317 browser()->GetSelectedTabContents()->render_view_host(), L"", |
| 318 L"window.domAutomationController.send(clickNoRefLink());", |
| 319 &success)); |
| 320 EXPECT_TRUE(success); |
| 321 |
| 322 // Wait for the cross-site transition in the current tab to finish. |
| 323 ui_test_utils::WaitForLoadStop(browser()->GetSelectedTabContents()); |
| 324 |
| 325 // Opens in same tab. |
| 326 EXPECT_EQ(1, browser()->tab_count()); |
| 327 EXPECT_EQ(0, browser()->selected_index()); |
| 328 EXPECT_EQ("/files/title2.html", |
| 329 browser()->GetSelectedTabContents()->GetURL().path()); |
| 330 |
| 331 // Should have the same SiteInstance. |
| 332 scoped_refptr<SiteInstance> noref_site_instance( |
| 333 browser()->GetSelectedTabContents()->GetSiteInstance()); |
| 334 EXPECT_EQ(orig_site_instance, noref_site_instance); |
| 335 } |
OLD | NEW |