| 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/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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 &replacement_path)); | 60 &replacement_path)); |
| 61 ui_test_utils::NavigateToURL(browser(), | 61 ui_test_utils::NavigateToURL(browser(), |
| 62 test_server()->GetURL(replacement_path)); | 62 test_server()->GetURL(replacement_path)); |
| 63 | 63 |
| 64 // Get the original SiteInstance for later comparison. | 64 // Get the original SiteInstance for later comparison. |
| 65 scoped_refptr<SiteInstance> orig_site_instance( | 65 scoped_refptr<SiteInstance> orig_site_instance( |
| 66 browser()->GetSelectedWebContents()->GetSiteInstance()); | 66 browser()->GetSelectedWebContents()->GetSiteInstance()); |
| 67 EXPECT_TRUE(orig_site_instance != NULL); | 67 EXPECT_TRUE(orig_site_instance != NULL); |
| 68 | 68 |
| 69 // Open a same-site link in a new tab. | 69 // Open a same-site link in a new tab. |
| 70 ui_test_utils::WindowedNotificationObserver new_tab_observer( | 70 ui_test_utils::WindowedTabAddedNotificationObserver new_tab_observer(( |
| 71 content::NOTIFICATION_TAB_ADDED, | 71 content::Source<content::WebContentsDelegate>(browser()))); |
| 72 content::Source<content::WebContentsDelegate>(browser())); | |
| 73 bool success = false; | 72 bool success = false; |
| 74 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 73 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 75 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", | 74 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", |
| 76 L"window.domAutomationController.send(clickSameSiteTargetedLink());", | 75 L"window.domAutomationController.send(clickSameSiteTargetedLink());", |
| 77 &success)); | 76 &success)); |
| 78 EXPECT_TRUE(success); | 77 EXPECT_TRUE(success); |
| 79 new_tab_observer.Wait(); | 78 new_tab_observer.Wait(); |
| 80 | 79 |
| 81 // Opens in new tab. | 80 // Opens in new tab. |
| 82 EXPECT_EQ(2, browser()->tab_count()); | 81 EXPECT_EQ(2, browser()->tab_count()); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 &replacement_path)); | 356 &replacement_path)); |
| 358 ui_test_utils::NavigateToURL(browser(), | 357 ui_test_utils::NavigateToURL(browser(), |
| 359 test_server()->GetURL(replacement_path)); | 358 test_server()->GetURL(replacement_path)); |
| 360 | 359 |
| 361 // Get the original SiteInstance for later comparison. | 360 // Get the original SiteInstance for later comparison. |
| 362 scoped_refptr<SiteInstance> orig_site_instance( | 361 scoped_refptr<SiteInstance> orig_site_instance( |
| 363 browser()->GetSelectedWebContents()->GetSiteInstance()); | 362 browser()->GetSelectedWebContents()->GetSiteInstance()); |
| 364 EXPECT_TRUE(orig_site_instance != NULL); | 363 EXPECT_TRUE(orig_site_instance != NULL); |
| 365 | 364 |
| 366 // Test clicking a target=foo link. | 365 // Test clicking a target=foo link. |
| 367 ui_test_utils::WindowedNotificationObserver new_tab_observer( | 366 ui_test_utils::WindowedTabAddedNotificationObserver new_tab_observer(( |
| 368 content::NOTIFICATION_TAB_ADDED, | 367 content::Source<content::WebContentsDelegate>(browser()))); |
| 369 content::Source<content::WebContentsDelegate>(browser())); | |
| 370 bool success = false; | 368 bool success = false; |
| 371 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 369 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 372 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", | 370 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", |
| 373 L"window.domAutomationController.send(clickSameSiteTargetedLink());", | 371 L"window.domAutomationController.send(clickSameSiteTargetedLink());", |
| 374 &success)); | 372 &success)); |
| 375 EXPECT_TRUE(success); | 373 EXPECT_TRUE(success); |
| 376 new_tab_observer.Wait(); | 374 new_tab_observer.Wait(); |
| 377 | 375 |
| 378 // Opens in new tab. | 376 // Opens in new tab. |
| 379 EXPECT_EQ(2, browser()->tab_count()); | 377 EXPECT_EQ(2, browser()->tab_count()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 ui_test_utils::NavigateToURL(browser(), | 438 ui_test_utils::NavigateToURL(browser(), |
| 441 test_server()->GetURL(replacement_path)); | 439 test_server()->GetURL(replacement_path)); |
| 442 | 440 |
| 443 // Get the original tab and SiteInstance for later comparison. | 441 // Get the original tab and SiteInstance for later comparison. |
| 444 content::WebContents* orig_contents = browser()->GetSelectedWebContents(); | 442 content::WebContents* orig_contents = browser()->GetSelectedWebContents(); |
| 445 scoped_refptr<SiteInstance> orig_site_instance( | 443 scoped_refptr<SiteInstance> orig_site_instance( |
| 446 browser()->GetSelectedWebContents()->GetSiteInstance()); | 444 browser()->GetSelectedWebContents()->GetSiteInstance()); |
| 447 EXPECT_TRUE(orig_site_instance != NULL); | 445 EXPECT_TRUE(orig_site_instance != NULL); |
| 448 | 446 |
| 449 // Test clicking a target=foo link. | 447 // Test clicking a target=foo link. |
| 450 ui_test_utils::WindowedNotificationObserver new_tab_observer( | 448 ui_test_utils::WindowedTabAddedNotificationObserver new_tab_observer(( |
| 451 content::NOTIFICATION_TAB_ADDED, | 449 content::Source<content::WebContentsDelegate>(browser()))); |
| 452 content::Source<content::WebContentsDelegate>(browser())); | |
| 453 bool success = false; | 450 bool success = false; |
| 454 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 451 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 455 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", | 452 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", |
| 456 L"window.domAutomationController.send(clickSameSiteTargetedLink());", | 453 L"window.domAutomationController.send(clickSameSiteTargetedLink());", |
| 457 &success)); | 454 &success)); |
| 458 EXPECT_TRUE(success); | 455 EXPECT_TRUE(success); |
| 459 new_tab_observer.Wait(); | 456 new_tab_observer.Wait(); |
| 460 | 457 |
| 461 // Opens in new tab. | 458 // Opens in new tab. |
| 462 EXPECT_EQ(2, browser()->tab_count()); | 459 EXPECT_EQ(2, browser()->tab_count()); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 // Now navigate to a different instance so that we swap out again. | 773 // Now navigate to a different instance so that we swap out again. |
| 777 ui_test_utils::NavigateToURL(browser(), | 774 ui_test_utils::NavigateToURL(browser(), |
| 778 https_server.GetURL("files/title2.html")); | 775 https_server.GetURL("files/title2.html")); |
| 779 rvh_observers.AddObserverToRVH(browser()->GetSelectedWebContents()-> | 776 rvh_observers.AddObserverToRVH(browser()->GetSelectedWebContents()-> |
| 780 GetRenderViewHost()); | 777 GetRenderViewHost()); |
| 781 | 778 |
| 782 // This used to leak a render view host. | 779 // This used to leak a render view host. |
| 783 browser()->CloseTabContents(browser()->GetSelectedWebContents()); | 780 browser()->CloseTabContents(browser()->GetSelectedWebContents()); |
| 784 EXPECT_EQ(0U, rvh_observers.GetNumObservers()); | 781 EXPECT_EQ(0U, rvh_observers.GetNumObservers()); |
| 785 } | 782 } |
| OLD | NEW |