Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: content/browser/renderer_host/render_view_host_manager_browsertest.cc

Issue 10344028: Support cross-process window.close() messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/file_util.h" 5 #include "base/file_util.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 "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/test/base/in_process_browser_test.h" 9 #include "chrome/test/base/in_process_browser_test.h"
10 #include "chrome/test/base/ui_test_utils.h" 10 #include "chrome/test/base/ui_test_utils.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 EXPECT_EQ("/files/navigate_opener.html", 382 EXPECT_EQ("/files/navigate_opener.html",
383 browser()->GetSelectedWebContents()->GetURL().path()); 383 browser()->GetSelectedWebContents()->GetURL().path());
384 EXPECT_EQ(1, browser()->active_index()); 384 EXPECT_EQ(1, browser()->active_index());
385 385
386 // Should have the same SiteInstance. 386 // Should have the same SiteInstance.
387 scoped_refptr<SiteInstance> blank_site_instance( 387 scoped_refptr<SiteInstance> blank_site_instance(
388 browser()->GetSelectedWebContents()->GetSiteInstance()); 388 browser()->GetSelectedWebContents()->GetSiteInstance());
389 EXPECT_EQ(orig_site_instance, blank_site_instance); 389 EXPECT_EQ(orig_site_instance, blank_site_instance);
390 390
391 // Now navigate the new tab to a different site. 391 // Now navigate the new tab to a different site.
392 //browser()->ActivateTabAt(1, true);
393 content::WebContents* new_contents = browser()->GetSelectedWebContents(); 392 content::WebContents* new_contents = browser()->GetSelectedWebContents();
394 ui_test_utils::NavigateToURL(browser(), 393 ui_test_utils::NavigateToURL(browser(),
395 https_server.GetURL("files/title1.html")); 394 https_server.GetURL("files/title1.html"));
396 scoped_refptr<SiteInstance> new_site_instance( 395 scoped_refptr<SiteInstance> new_site_instance(
397 browser()->GetSelectedWebContents()->GetSiteInstance()); 396 browser()->GetSelectedWebContents()->GetSiteInstance());
398 EXPECT_NE(orig_site_instance, new_site_instance); 397 EXPECT_NE(orig_site_instance, new_site_instance);
399 398
400 // Clicking the original link in the first tab should cause us to swap back. 399 // Clicking the original link in the first tab should cause us to swap back.
401 browser()->ActivateTabAt(0, true); 400 browser()->ActivateTabAt(0, true);
402 ui_test_utils::WindowedNotificationObserver navigation_observer( 401 ui_test_utils::WindowedNotificationObserver navigation_observer(
403 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 402 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
404 content::Source<content::NavigationController>( 403 content::Source<content::NavigationController>(
405 &new_contents->GetController())); 404 &new_contents->GetController()));
406 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 405 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
407 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", 406 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"",
408 L"window.domAutomationController.send(clickSameSiteTargetedLink());", 407 L"window.domAutomationController.send(clickSameSiteTargetedLink());",
409 &success)); 408 &success));
410 EXPECT_TRUE(success); 409 EXPECT_TRUE(success);
411 navigation_observer.Wait(); 410 navigation_observer.Wait();
412 411
413 // Should have swapped back and shown the new tab again. 412 // Should have swapped back and shown the new tab again.
414 EXPECT_EQ(1, browser()->active_index()); 413 EXPECT_EQ(1, browser()->active_index());
415 scoped_refptr<SiteInstance> revisit_site_instance( 414 scoped_refptr<SiteInstance> revisit_site_instance(
416 browser()->GetSelectedWebContents()->GetSiteInstance()); 415 browser()->GetSelectedWebContents()->GetSiteInstance());
417 EXPECT_EQ(orig_site_instance, revisit_site_instance); 416 EXPECT_EQ(orig_site_instance, revisit_site_instance);
417
418 // If it navigates away to another process, the original window should
419 // still be able to close it (using a cross-process close message).
420 ui_test_utils::NavigateToURL(browser(),
421 https_server.GetURL("files/title1.html"));
422 EXPECT_EQ(new_site_instance,
423 browser()->GetSelectedWebContents()->GetSiteInstance());
424 browser()->ActivateTabAt(0, true);
425 ui_test_utils::WindowedNotificationObserver close_observer(
426 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
427 content::Source<content::WebContents>(new_contents));
428 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
429 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"",
430 L"window.domAutomationController.send(testCloseWindow());",
431 &success));
432 EXPECT_TRUE(success);
433 close_observer.Wait();
418 } 434 }
419 435
420 // Test for crbug.com/116192. Navigations to a window's opener should 436 // Test for crbug.com/116192. Navigations to a window's opener should
421 // still work after a process swap. 437 // still work after a process swap.
422 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, 438 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
423 AllowTargetedNavigationsInOpenerAfterSwap) { 439 AllowTargetedNavigationsInOpenerAfterSwap) {
424 // Start two servers with different sites. 440 // Start two servers with different sites.
425 ASSERT_TRUE(test_server()->Start()); 441 ASSERT_TRUE(test_server()->Start());
426 net::TestServer https_server( 442 net::TestServer https_server(
427 net::TestServer::TYPE_HTTPS, 443 net::TestServer::TYPE_HTTPS,
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 // Now navigate to a different instance so that we swap out again. 789 // Now navigate to a different instance so that we swap out again.
774 ui_test_utils::NavigateToURL(browser(), 790 ui_test_utils::NavigateToURL(browser(),
775 https_server.GetURL("files/title2.html")); 791 https_server.GetURL("files/title2.html"));
776 rvh_observers.AddObserverToRVH(browser()->GetSelectedWebContents()-> 792 rvh_observers.AddObserverToRVH(browser()->GetSelectedWebContents()->
777 GetRenderViewHost()); 793 GetRenderViewHost());
778 794
779 // This used to leak a render view host. 795 // This used to leak a render view host.
780 browser()->CloseTabContents(browser()->GetSelectedWebContents()); 796 browser()->CloseTabContents(browser()->GetSelectedWebContents());
781 EXPECT_EQ(0U, rvh_observers.GetNumObservers()); 797 EXPECT_EQ(0U, rvh_observers.GetNumObservers());
782 } 798 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.cc ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698