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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 L"window.domAutomationController.send(clickNoRefTargetBlankLink());", | 71 L"window.domAutomationController.send(clickNoRefTargetBlankLink());", |
72 &success)); | 72 &success)); |
73 EXPECT_TRUE(success); | 73 EXPECT_TRUE(success); |
74 // Wait for the cross-site transition to finish. | 74 // Wait for the cross-site transition to finish. |
75 ui_test_utils::WaitForLoadStop( | 75 ui_test_utils::WaitForLoadStop( |
76 &(browser()->GetSelectedTabContents()->controller())); | 76 &(browser()->GetSelectedTabContents()->controller())); |
77 | 77 |
78 // Opens in new tab. | 78 // Opens in new tab. |
79 EXPECT_EQ(2, browser()->tab_count()); | 79 EXPECT_EQ(2, browser()->tab_count()); |
80 EXPECT_EQ(1, browser()->selected_index()); | 80 EXPECT_EQ(1, browser()->selected_index()); |
81 EXPECT_EQ(L"Title Of Awesomeness", | 81 EXPECT_EQ(ASCIIToUTF16("Title Of Awesomeness"), |
82 browser()->GetSelectedTabContents()->GetTitle()); | 82 browser()->GetSelectedTabContents()->GetTitle()); |
83 | 83 |
84 // Should have a new SiteInstance. | 84 // Should have a new SiteInstance. |
85 scoped_refptr<SiteInstance> noref_blank_site_instance( | 85 scoped_refptr<SiteInstance> noref_blank_site_instance( |
86 browser()->GetSelectedTabContents()->GetSiteInstance()); | 86 browser()->GetSelectedTabContents()->GetSiteInstance()); |
87 EXPECT_NE(orig_site_instance, noref_blank_site_instance); | 87 EXPECT_NE(orig_site_instance, noref_blank_site_instance); |
88 } | 88 } |
89 | 89 |
90 // Test for crbug.com/24447. Following a cross-site link with just | 90 // Test for crbug.com/24447. Following a cross-site link with just |
91 // target=_blank should not create a new SiteInstance. | 91 // target=_blank should not create a new SiteInstance. |
(...skipping 28 matching lines...) Expand all Loading... | |
120 L"window.domAutomationController.send(clickTargetBlankLink());", | 120 L"window.domAutomationController.send(clickTargetBlankLink());", |
121 &success)); | 121 &success)); |
122 EXPECT_TRUE(success); | 122 EXPECT_TRUE(success); |
123 // Wait for the cross-site transition to finish. | 123 // Wait for the cross-site transition to finish. |
124 ui_test_utils::WaitForLoadStop( | 124 ui_test_utils::WaitForLoadStop( |
125 &(browser()->GetSelectedTabContents()->controller())); | 125 &(browser()->GetSelectedTabContents()->controller())); |
126 | 126 |
127 // Opens in new tab. | 127 // Opens in new tab. |
128 EXPECT_EQ(2, browser()->tab_count()); | 128 EXPECT_EQ(2, browser()->tab_count()); |
129 EXPECT_EQ(1, browser()->selected_index()); | 129 EXPECT_EQ(1, browser()->selected_index()); |
130 EXPECT_EQ(L"Title Of Awesomeness", | 130 EXPECT_EQ(ASCIIToUTF16("Title Of Awesomeness"), |
131 browser()->GetSelectedTabContents()->GetTitle()); | 131 browser()->GetSelectedTabContents()->GetTitle()); |
132 | 132 |
133 // Should have the same SiteInstance. | 133 // Should have the same SiteInstance. |
134 scoped_refptr<SiteInstance> blank_site_instance( | 134 scoped_refptr<SiteInstance> blank_site_instance( |
135 browser()->GetSelectedTabContents()->GetSiteInstance()); | 135 browser()->GetSelectedTabContents()->GetSiteInstance()); |
136 EXPECT_EQ(orig_site_instance, blank_site_instance); | 136 EXPECT_EQ(orig_site_instance, blank_site_instance); |
137 } | 137 } |
138 | 138 |
139 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer | 139 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer |
140 // and no target=_blank should not create a new SiteInstance. | 140 // and no target=_blank should not create a new SiteInstance. |
(...skipping 27 matching lines...) Expand all Loading... | |
168 L"window.domAutomationController.send(clickNoRefLink());", | 168 L"window.domAutomationController.send(clickNoRefLink());", |
169 &success)); | 169 &success)); |
170 EXPECT_TRUE(success); | 170 EXPECT_TRUE(success); |
171 // Wait for the cross-site transition to finish. | 171 // Wait for the cross-site transition to finish. |
172 ui_test_utils::WaitForLoadStop( | 172 ui_test_utils::WaitForLoadStop( |
173 &(browser()->GetSelectedTabContents()->controller())); | 173 &(browser()->GetSelectedTabContents()->controller())); |
174 | 174 |
175 // Opens in same tab. | 175 // Opens in same tab. |
176 EXPECT_EQ(1, browser()->tab_count()); | 176 EXPECT_EQ(1, browser()->tab_count()); |
177 EXPECT_EQ(0, browser()->selected_index()); | 177 EXPECT_EQ(0, browser()->selected_index()); |
178 EXPECT_EQ(L"Title Of Awesomeness", | 178 EXPECT_EQ(ASCIIToUTF16("Title Of Awesomeness"), |
179 browser()->GetSelectedTabContents()->GetTitle()); | 179 browser()->GetSelectedTabContents()->GetTitle()); |
180 | 180 |
181 // Should have the same SiteInstance. | 181 // Should have the same SiteInstance. |
182 scoped_refptr<SiteInstance> noref_site_instance( | 182 scoped_refptr<SiteInstance> noref_site_instance( |
183 browser()->GetSelectedTabContents()->GetSiteInstance()); | 183 browser()->GetSelectedTabContents()->GetSiteInstance()); |
184 EXPECT_EQ(orig_site_instance, noref_site_instance); | 184 EXPECT_EQ(orig_site_instance, noref_site_instance); |
185 } | 185 } |
186 | 186 |
187 // Hangs flakily in Win, http://crbug.com/45040. | 187 // Hangs flakily in Win, http://crbug.com/45040. |
188 #if defined(OS_WIN) | 188 #if defined(OS_WIN) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 } | 228 } |
229 | 229 |
230 // NotificationObserver | 230 // NotificationObserver |
231 virtual void Observe(NotificationType type, | 231 virtual void Observe(NotificationType type, |
232 const NotificationSource& source, | 232 const NotificationSource& source, |
233 const NotificationDetails& details) { | 233 const NotificationDetails& details) { |
234 switch (type.value) { | 234 switch (type.value) { |
235 case NotificationType::BROWSER_CLOSED: | 235 case NotificationType::BROWSER_CLOSED: |
236 MessageLoopForUI::current()->Quit(); | 236 MessageLoopForUI::current()->Quit(); |
237 break; | 237 break; |
238 default: | |
Paweł Hajdan Jr.
2011/03/24 16:37:22
Do you want NOTREACHED in the default case?
Charlie Reis
2011/03/24 22:46:03
Sure. I've also fixed it as part of http://codere
| |
239 break; | |
238 } | 240 } |
239 } | 241 } |
240 | 242 |
241 private: | 243 private: |
242 NotificationRegistrar registrar_; | 244 NotificationRegistrar registrar_; |
243 }; | 245 }; |
244 | 246 |
245 // Test for crbug.com/12745. This tests that if a download is initiated from | 247 // Test for crbug.com/12745. This tests that if a download is initiated from |
246 // a chrome:// page that has registered and onunload handler, the browser | 248 // a chrome:// page that has registered and onunload handler, the browser |
247 // will be able to close. | 249 // will be able to close. |
(...skipping 20 matching lines...) Expand all Loading... | |
268 &result)); | 270 &result)); |
269 EXPECT_TRUE(result); | 271 EXPECT_TRUE(result); |
270 ui_test_utils::NavigateToURL(browser(), zip_url); | 272 ui_test_utils::NavigateToURL(browser(), zip_url); |
271 | 273 |
272 ui_test_utils::WaitForDownloadCount( | 274 ui_test_utils::WaitForDownloadCount( |
273 browser()->profile()->GetDownloadManager(), 1); | 275 browser()->profile()->GetDownloadManager(), 1); |
274 | 276 |
275 browser()->CloseWindow(); | 277 browser()->CloseWindow(); |
276 BrowserClosedObserver wait_for_close(browser()); | 278 BrowserClosedObserver wait_for_close(browser()); |
277 } | 279 } |
280 | |
281 // Test for crbug.com/76666. A cross-site navigation that fails with a 204 | |
282 // error should not make us ignore future renderer-initiated navigations. | |
283 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, ClickLinkAfter204Error) { | |
284 // Start two servers with different sites. | |
285 ASSERT_TRUE(test_server()->Start()); | |
286 net::TestServer https_server_( | |
Paweł Hajdan Jr.
2011/03/24 16:37:22
nit: Remove underscore from the end of variable na
Charlie Reis
2011/03/24 22:46:03
Done.
| |
287 net::TestServer::TYPE_HTTPS, | |
288 FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | |
289 ASSERT_TRUE(https_server_.Start()); | |
290 | |
291 // Load a page with links that open in a new window. | |
292 // The links will point to the HTTPS server. | |
293 std::string replacement_path; | |
294 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | |
295 "files/click-noreferrer-links.html", | |
296 https_server_.host_port_pair(), | |
297 &replacement_path)); | |
298 ui_test_utils::NavigateToURL(browser(), | |
299 test_server()->GetURL(replacement_path)); | |
300 | |
301 // Get the original SiteInstance for later comparison. | |
302 scoped_refptr<SiteInstance> orig_site_instance( | |
303 browser()->GetSelectedTabContents()->GetSiteInstance()); | |
304 EXPECT_TRUE(orig_site_instance != NULL); | |
305 | |
306 // Load a cross-site page that fails with a 204 error. | |
307 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL("nocontent")); | |
308 | |
309 // We should still be looking at the normal page. | |
310 scoped_refptr<SiteInstance> post_nav_site_instance( | |
311 browser()->GetSelectedTabContents()->GetSiteInstance()); | |
312 EXPECT_EQ(orig_site_instance, post_nav_site_instance); | |
313 EXPECT_EQ(ASCIIToUTF16("Click noreferrer links"), | |
314 browser()->GetSelectedTabContents()->GetTitle()); | |
315 | |
316 // Renderer-initiated navigations should work. | |
317 bool success = false; | |
318 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | |
319 browser()->GetSelectedTabContents()->render_view_host(), L"", | |
320 L"window.domAutomationController.send(clickNoRefLink());", | |
321 &success)); | |
322 EXPECT_TRUE(success); | |
323 // Wait for the cross-site transition to finish. | |
324 ui_test_utils::WaitForLoadStop( | |
325 &(browser()->GetSelectedTabContents()->controller())); | |
326 | |
327 // Opens in same tab. | |
328 EXPECT_EQ(1, browser()->tab_count()); | |
329 EXPECT_EQ(0, browser()->selected_index()); | |
330 EXPECT_EQ(ASCIIToUTF16("Title Of Awesomeness"), | |
331 browser()->GetSelectedTabContents()->GetTitle()); | |
Charlie Reis
2011/03/24 22:46:03
I've now fixed the flakiness around this, too (as
| |
332 | |
333 // Should have the same SiteInstance. | |
334 scoped_refptr<SiteInstance> noref_site_instance( | |
335 browser()->GetSelectedTabContents()->GetSiteInstance()); | |
336 EXPECT_EQ(orig_site_instance, noref_site_instance); | |
337 } | |
OLD | NEW |