| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/json/json_reader.h" | 5 #include "base/json/json_reader.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "content/browser/renderer_host/render_view_host_impl.h" | 10 #include "content/browser/renderer_host/render_view_host_impl.h" |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 EXPECT_EQ(1u, Shell::windows().size()); | 312 EXPECT_EQ(1u, Shell::windows().size()); |
| 313 EXPECT_EQ("/files/title2.html", | 313 EXPECT_EQ("/files/title2.html", |
| 314 shell()->web_contents()->GetLastCommittedURL().path()); | 314 shell()->web_contents()->GetLastCommittedURL().path()); |
| 315 | 315 |
| 316 // Should have the same SiteInstance. | 316 // Should have the same SiteInstance. |
| 317 scoped_refptr<SiteInstance> noref_site_instance( | 317 scoped_refptr<SiteInstance> noref_site_instance( |
| 318 shell()->web_contents()->GetSiteInstance()); | 318 shell()->web_contents()->GetSiteInstance()); |
| 319 EXPECT_EQ(orig_site_instance, noref_site_instance); | 319 EXPECT_EQ(orig_site_instance, noref_site_instance); |
| 320 } | 320 } |
| 321 | 321 |
| 322 namespace { | |
| 323 | |
| 324 class WebContentsDestroyedObserver : public WebContentsObserver { | |
| 325 public: | |
| 326 WebContentsDestroyedObserver(WebContents* web_contents, | |
| 327 const base::Closure& callback) | |
| 328 : WebContentsObserver(web_contents), | |
| 329 callback_(callback) { | |
| 330 } | |
| 331 | |
| 332 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE { | |
| 333 callback_.Run(); | |
| 334 } | |
| 335 | |
| 336 private: | |
| 337 base::Closure callback_; | |
| 338 | |
| 339 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedObserver); | |
| 340 }; | |
| 341 | |
| 342 } // namespace | |
| 343 | |
| 344 // Test for crbug.com/116192. Targeted links should still work after the | 322 // Test for crbug.com/116192. Targeted links should still work after the |
| 345 // named target window has swapped processes. | 323 // named target window has swapped processes. |
| 346 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, | 324 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, |
| 347 AllowTargetedNavigationsAfterSwap) { | 325 AllowTargetedNavigationsAfterSwap) { |
| 348 // Start two servers with different sites. | 326 // Start two servers with different sites. |
| 349 ASSERT_TRUE(test_server()->Start()); | 327 ASSERT_TRUE(test_server()->Start()); |
| 350 net::SpawnedTestServer https_server( | 328 net::SpawnedTestServer https_server( |
| 351 net::SpawnedTestServer::TYPE_HTTPS, | 329 net::SpawnedTestServer::TYPE_HTTPS, |
| 352 net::SpawnedTestServer::kLocalhost, | 330 net::SpawnedTestServer::kLocalhost, |
| 353 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); | 331 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 // Should have swapped back and shown the new window again. | 382 // Should have swapped back and shown the new window again. |
| 405 scoped_refptr<SiteInstance> revisit_site_instance( | 383 scoped_refptr<SiteInstance> revisit_site_instance( |
| 406 new_shell->web_contents()->GetSiteInstance()); | 384 new_shell->web_contents()->GetSiteInstance()); |
| 407 EXPECT_EQ(orig_site_instance, revisit_site_instance); | 385 EXPECT_EQ(orig_site_instance, revisit_site_instance); |
| 408 | 386 |
| 409 // If it navigates away to another process, the original window should | 387 // If it navigates away to another process, the original window should |
| 410 // still be able to close it (using a cross-process close message). | 388 // still be able to close it (using a cross-process close message). |
| 411 NavigateToURL(new_shell, https_server.GetURL("files/title1.html")); | 389 NavigateToURL(new_shell, https_server.GetURL("files/title1.html")); |
| 412 EXPECT_EQ(new_site_instance, | 390 EXPECT_EQ(new_site_instance, |
| 413 new_shell->web_contents()->GetSiteInstance()); | 391 new_shell->web_contents()->GetSiteInstance()); |
| 414 scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner); | 392 WebContentsDestroyedWatcher close_watcher(new_shell->web_contents()); |
| 415 WebContentsDestroyedObserver close_observer(new_shell->web_contents(), | |
| 416 loop_runner->QuitClosure()); | |
| 417 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 393 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 418 shell()->web_contents(), | 394 shell()->web_contents(), |
| 419 "window.domAutomationController.send(testCloseWindow());", | 395 "window.domAutomationController.send(testCloseWindow());", |
| 420 &success)); | 396 &success)); |
| 421 EXPECT_TRUE(success); | 397 EXPECT_TRUE(success); |
| 422 loop_runner->Run(); | 398 close_watcher.Wait(); |
| 423 } | 399 } |
| 424 | 400 |
| 425 // Test that setting the opener to null in a window affects cross-process | 401 // Test that setting the opener to null in a window affects cross-process |
| 426 // navigations, including those to existing entries. http://crbug.com/156669. | 402 // navigations, including those to existing entries. http://crbug.com/156669. |
| 427 // Flaky on windows: http://crbug.com/291249 | 403 // Flaky on windows: http://crbug.com/291249 |
| 428 #if defined(OS_WIN) | 404 #if defined(OS_WIN) |
| 429 #define MAYBE_DisownOpener DISABLED_DisownOpener | 405 #define MAYBE_DisownOpener DISABLED_DisownOpener |
| 430 #else | 406 #else |
| 431 #define MAYBE_DisownOpener DisownOpener | 407 #define MAYBE_DisownOpener DisownOpener |
| 432 #endif | 408 #endif |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1291 NavigateToURL(shell(), https_server.GetURL("files/title1.html")); | 1267 NavigateToURL(shell(), https_server.GetURL("files/title1.html")); |
| 1292 | 1268 |
| 1293 // Make sure it ends up at the right page. | 1269 // Make sure it ends up at the right page. |
| 1294 WaitForLoadStop(shell()->web_contents()); | 1270 WaitForLoadStop(shell()->web_contents()); |
| 1295 EXPECT_EQ(https_server.GetURL("files/title1.html"), | 1271 EXPECT_EQ(https_server.GetURL("files/title1.html"), |
| 1296 shell()->web_contents()->GetLastCommittedURL()); | 1272 shell()->web_contents()->GetLastCommittedURL()); |
| 1297 EXPECT_EQ(new_site_instance, shell()->web_contents()->GetSiteInstance()); | 1273 EXPECT_EQ(new_site_instance, shell()->web_contents()->GetSiteInstance()); |
| 1298 } | 1274 } |
| 1299 | 1275 |
| 1300 } // namespace content | 1276 } // namespace content |
| OLD | NEW |