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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 ui_test_utils::WaitForNewTab(browser()); | 159 ui_test_utils::WaitForNewTab(browser()); |
160 | 160 |
161 // Opens in new tab. | 161 // Opens in new tab. |
162 EXPECT_EQ(2, browser()->tab_count()); | 162 EXPECT_EQ(2, browser()->tab_count()); |
163 EXPECT_EQ(1, browser()->active_index()); | 163 EXPECT_EQ(1, browser()->active_index()); |
164 EXPECT_EQ("/files/title2.html", | 164 EXPECT_EQ("/files/title2.html", |
165 browser()->GetSelectedWebContents()->GetURL().path()); | 165 browser()->GetSelectedWebContents()->GetURL().path()); |
166 | 166 |
167 // Wait for the cross-site transition in the new tab to finish. | 167 // Wait for the cross-site transition in the new tab to finish. |
168 ui_test_utils::WaitForLoadStop(browser()->GetSelectedWebContents()); | 168 ui_test_utils::WaitForLoadStop(browser()->GetSelectedWebContents()); |
169 TabContents* tab_contents = static_cast<TabContents*>( | 169 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
170 browser()->GetSelectedWebContents()); | 170 browser()->GetSelectedWebContents()); |
171 EXPECT_FALSE(tab_contents->GetRenderManagerForTesting()-> | 171 EXPECT_FALSE(web_contents->GetRenderManagerForTesting()-> |
172 pending_render_view_host()); | 172 pending_render_view_host()); |
173 | 173 |
174 // Should have a new SiteInstance. | 174 // Should have a new SiteInstance. |
175 scoped_refptr<SiteInstance> noref_blank_site_instance( | 175 scoped_refptr<SiteInstance> noref_blank_site_instance( |
176 browser()->GetSelectedWebContents()->GetSiteInstance()); | 176 browser()->GetSelectedWebContents()->GetSiteInstance()); |
177 EXPECT_NE(orig_site_instance, noref_blank_site_instance); | 177 EXPECT_NE(orig_site_instance, noref_blank_site_instance); |
178 } | 178 } |
179 | 179 |
180 // As of crbug.com/69267, we create a new BrowsingInstance (and SiteInstance) | 180 // As of crbug.com/69267, we create a new BrowsingInstance (and SiteInstance) |
181 // for rel=noreferrer links in new windows, even to same site pages and named | 181 // for rel=noreferrer links in new windows, even to same site pages and named |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 ui_test_utils::WaitForNewTab(browser()); | 217 ui_test_utils::WaitForNewTab(browser()); |
218 | 218 |
219 // Opens in new tab. | 219 // Opens in new tab. |
220 EXPECT_EQ(2, browser()->tab_count()); | 220 EXPECT_EQ(2, browser()->tab_count()); |
221 EXPECT_EQ(1, browser()->active_index()); | 221 EXPECT_EQ(1, browser()->active_index()); |
222 EXPECT_EQ("/files/title2.html", | 222 EXPECT_EQ("/files/title2.html", |
223 browser()->GetSelectedWebContents()->GetURL().path()); | 223 browser()->GetSelectedWebContents()->GetURL().path()); |
224 | 224 |
225 // Wait for the cross-site transition in the new tab to finish. | 225 // Wait for the cross-site transition in the new tab to finish. |
226 ui_test_utils::WaitForLoadStop(browser()->GetSelectedWebContents()); | 226 ui_test_utils::WaitForLoadStop(browser()->GetSelectedWebContents()); |
227 TabContents* tab_contents = static_cast<TabContents*>( | 227 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
228 browser()->GetSelectedWebContents()); | 228 browser()->GetSelectedWebContents()); |
229 EXPECT_FALSE(tab_contents->GetRenderManagerForTesting()-> | 229 EXPECT_FALSE(web_contents->GetRenderManagerForTesting()-> |
230 pending_render_view_host()); | 230 pending_render_view_host()); |
231 | 231 |
232 // Should have a new SiteInstance (in a new BrowsingInstance). | 232 // Should have a new SiteInstance (in a new BrowsingInstance). |
233 scoped_refptr<SiteInstance> noref_blank_site_instance( | 233 scoped_refptr<SiteInstance> noref_blank_site_instance( |
234 browser()->GetSelectedWebContents()->GetSiteInstance()); | 234 browser()->GetSelectedWebContents()->GetSiteInstance()); |
235 EXPECT_NE(orig_site_instance, noref_blank_site_instance); | 235 EXPECT_NE(orig_site_instance, noref_blank_site_instance); |
236 } | 236 } |
237 | 237 |
238 // Test for crbug.com/24447. Following a cross-site link with just | 238 // Test for crbug.com/24447. Following a cross-site link with just |
239 // target=_blank should not create a new SiteInstance. | 239 // target=_blank should not create a new SiteInstance. |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 // Now navigate to a different instance so that we swap out again. | 776 // Now navigate to a different instance so that we swap out again. |
777 ui_test_utils::NavigateToURL(browser(), | 777 ui_test_utils::NavigateToURL(browser(), |
778 https_server.GetURL("files/title2.html")); | 778 https_server.GetURL("files/title2.html")); |
779 rvh_observers.AddObserverToRVH(browser()->GetSelectedWebContents()-> | 779 rvh_observers.AddObserverToRVH(browser()->GetSelectedWebContents()-> |
780 GetRenderViewHost()); | 780 GetRenderViewHost()); |
781 | 781 |
782 // This used to leak a render view host. | 782 // This used to leak a render view host. |
783 browser()->CloseTabContents(browser()->GetSelectedWebContents()); | 783 browser()->CloseTabContents(browser()->GetSelectedWebContents()); |
784 EXPECT_EQ(0U, rvh_observers.GetNumObservers()); | 784 EXPECT_EQ(0U, rvh_observers.GetNumObservers()); |
785 } | 785 } |
OLD | NEW |