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

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

Issue 6730016: Fix flakiness and enable RenderViewHostManagerTest on Linux/Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comments from other review. Created 9 years, 9 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
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 27 matching lines...) Expand all
38 original_file_path, replacement_text, replacement_path); 38 original_file_path, replacement_text, replacement_path);
39 } 39 }
40 }; 40 };
41 41
42 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer 42 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer
43 // and target=_blank should create a new SiteInstance. 43 // and target=_blank should create a new SiteInstance.
44 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, 44 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
45 SwapProcessWithRelNoreferrerAndTargetBlank) { 45 SwapProcessWithRelNoreferrerAndTargetBlank) {
46 // Start two servers with different sites. 46 // Start two servers with different sites.
47 ASSERT_TRUE(test_server()->Start()); 47 ASSERT_TRUE(test_server()->Start());
48 net::TestServer https_server_( 48 net::TestServer https_server(
49 net::TestServer::TYPE_HTTPS, 49 net::TestServer::TYPE_HTTPS,
50 FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 50 FilePath(FILE_PATH_LITERAL("chrome/test/data")));
51 ASSERT_TRUE(https_server_.Start()); 51 ASSERT_TRUE(https_server.Start());
52 52
53 // Load a page with links that open in a new window. 53 // Load a page with links that open in a new window.
54 std::string replacement_path; 54 std::string replacement_path;
55 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 55 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
56 "files/click-noreferrer-links.html", 56 "files/click-noreferrer-links.html",
57 https_server_.host_port_pair(), 57 https_server.host_port_pair(),
58 &replacement_path)); 58 &replacement_path));
59 ui_test_utils::NavigateToURL(browser(), 59 ui_test_utils::NavigateToURL(browser(),
60 test_server()->GetURL(replacement_path)); 60 test_server()->GetURL(replacement_path));
61 61
62 // Get the original SiteInstance for later comparison. 62 // Get the original SiteInstance for later comparison.
63 scoped_refptr<SiteInstance> orig_site_instance( 63 scoped_refptr<SiteInstance> orig_site_instance(
64 browser()->GetSelectedTabContents()->GetSiteInstance()); 64 browser()->GetSelectedTabContents()->GetSiteInstance());
65 EXPECT_TRUE(orig_site_instance != NULL); 65 EXPECT_TRUE(orig_site_instance != NULL);
66 66
67 // Test clicking a rel=noreferrer + target=blank link. 67 // Test clicking a rel=noreferrer + target=blank link.
68 bool success = false; 68 bool success = false;
69 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 69 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
70 browser()->GetSelectedTabContents()->render_view_host(), L"", 70 browser()->GetSelectedTabContents()->render_view_host(), L"",
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 if (browser()->GetSelectedTabContents()->is_loading())
76 &(browser()->GetSelectedTabContents()->controller())); 76 ui_test_utils::WaitForLoadStop(
Paweł Hajdan Jr. 2011/03/24 17:22:57 Is it possibly a more general problem with WaitFor
Charlie Reis 2011/03/24 17:33:55 Yes, that sounds like a good idea-- I'll give it a
Charlie Reis 2011/03/24 23:15:39 Fixed. I had to also check whether the tab has a
77 &(browser()->GetSelectedTabContents()->controller()));
77 78
78 // Opens in new tab. 79 // Opens in new tab.
79 EXPECT_EQ(2, browser()->tab_count()); 80 EXPECT_EQ(2, browser()->tab_count());
80 EXPECT_EQ(1, browser()->selected_index()); 81 EXPECT_EQ(1, browser()->selected_index());
81 EXPECT_EQ(L"Title Of Awesomeness", 82 EXPECT_EQ("/files/title2.html",
82 browser()->GetSelectedTabContents()->GetTitle()); 83 browser()->GetSelectedTabContents()->GetURL().path());
83 84
84 // Should have a new SiteInstance. 85 // Should have a new SiteInstance.
85 scoped_refptr<SiteInstance> noref_blank_site_instance( 86 scoped_refptr<SiteInstance> noref_blank_site_instance(
86 browser()->GetSelectedTabContents()->GetSiteInstance()); 87 browser()->GetSelectedTabContents()->GetSiteInstance());
87 EXPECT_NE(orig_site_instance, noref_blank_site_instance); 88 EXPECT_NE(orig_site_instance, noref_blank_site_instance);
88 } 89 }
89 90
90 // Test for crbug.com/24447. Following a cross-site link with just 91 // Test for crbug.com/24447. Following a cross-site link with just
91 // target=_blank should not create a new SiteInstance. 92 // target=_blank should not create a new SiteInstance.
92 // Disabled, http://crbug.com/67532.
93 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, 93 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
94 DISABLED_DontSwapProcessWithOnlyTargetBlank) { 94 DontSwapProcessWithOnlyTargetBlank) {
95 // Start two servers with different sites. 95 // Start two servers with different sites.
96 ASSERT_TRUE(test_server()->Start()); 96 ASSERT_TRUE(test_server()->Start());
97 net::TestServer https_server_( 97 net::TestServer https_server(
98 net::TestServer::TYPE_HTTPS, 98 net::TestServer::TYPE_HTTPS,
99 FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 99 FilePath(FILE_PATH_LITERAL("chrome/test/data")));
100 ASSERT_TRUE(https_server_.Start()); 100 ASSERT_TRUE(https_server.Start());
101 101
102 // Load a page with links that open in a new window. 102 // Load a page with links that open in a new window.
103 std::string replacement_path; 103 std::string replacement_path;
104 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 104 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
105 "files/click-noreferrer-links.html", 105 "files/click-noreferrer-links.html",
106 https_server_.host_port_pair(), 106 https_server.host_port_pair(),
107 &replacement_path)); 107 &replacement_path));
108 ui_test_utils::NavigateToURL(browser(), 108 ui_test_utils::NavigateToURL(browser(),
109 test_server()->GetURL(replacement_path)); 109 test_server()->GetURL(replacement_path));
110 110
111 // Get the original SiteInstance for later comparison. 111 // Get the original SiteInstance for later comparison.
112 scoped_refptr<SiteInstance> orig_site_instance( 112 scoped_refptr<SiteInstance> orig_site_instance(
113 browser()->GetSelectedTabContents()->GetSiteInstance()); 113 browser()->GetSelectedTabContents()->GetSiteInstance());
114 EXPECT_TRUE(orig_site_instance != NULL); 114 EXPECT_TRUE(orig_site_instance != NULL);
115 115
116 // Test clicking a target=blank link. 116 // Test clicking a target=blank link.
117 bool success = false; 117 bool success = false;
118 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 118 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
119 browser()->GetSelectedTabContents()->render_view_host(), L"", 119 browser()->GetSelectedTabContents()->render_view_host(), L"",
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 if (browser()->GetSelectedTabContents()->is_loading())
125 &(browser()->GetSelectedTabContents()->controller())); 125 ui_test_utils::WaitForLoadStop(
126 &(browser()->GetSelectedTabContents()->controller()));
126 127
127 // Opens in new tab. 128 // Opens in new tab.
128 EXPECT_EQ(2, browser()->tab_count()); 129 EXPECT_EQ(2, browser()->tab_count());
129 EXPECT_EQ(1, browser()->selected_index()); 130 EXPECT_EQ(1, browser()->selected_index());
130 EXPECT_EQ(L"Title Of Awesomeness", 131 EXPECT_EQ("/files/title2.html",
131 browser()->GetSelectedTabContents()->GetTitle()); 132 browser()->GetSelectedTabContents()->GetURL().path());
132 133
133 // Should have the same SiteInstance. 134 // Should have the same SiteInstance.
134 scoped_refptr<SiteInstance> blank_site_instance( 135 scoped_refptr<SiteInstance> blank_site_instance(
135 browser()->GetSelectedTabContents()->GetSiteInstance()); 136 browser()->GetSelectedTabContents()->GetSiteInstance());
136 EXPECT_EQ(orig_site_instance, blank_site_instance); 137 EXPECT_EQ(orig_site_instance, blank_site_instance);
137 } 138 }
138 139
139 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer 140 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer
140 // and no target=_blank should not create a new SiteInstance. 141 // and no target=_blank should not create a new SiteInstance.
141 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, 142 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
142 DontSwapProcessWithOnlyRelNoreferrer) { 143 DontSwapProcessWithOnlyRelNoreferrer) {
143 // Start two servers with different sites. 144 // Start two servers with different sites.
144 ASSERT_TRUE(test_server()->Start()); 145 ASSERT_TRUE(test_server()->Start());
145 net::TestServer https_server_( 146 net::TestServer https_server(
146 net::TestServer::TYPE_HTTPS, 147 net::TestServer::TYPE_HTTPS,
147 FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 148 FilePath(FILE_PATH_LITERAL("chrome/test/data")));
148 ASSERT_TRUE(https_server_.Start()); 149 ASSERT_TRUE(https_server.Start());
149 150
150 // Load a page with links that open in a new window. 151 // Load a page with links that open in a new window.
151 std::string replacement_path; 152 std::string replacement_path;
152 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 153 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
153 "files/click-noreferrer-links.html", 154 "files/click-noreferrer-links.html",
154 https_server_.host_port_pair(), 155 https_server.host_port_pair(),
155 &replacement_path)); 156 &replacement_path));
156 ui_test_utils::NavigateToURL(browser(), 157 ui_test_utils::NavigateToURL(browser(),
157 test_server()->GetURL(replacement_path)); 158 test_server()->GetURL(replacement_path));
158 159
159 // Get the original SiteInstance for later comparison. 160 // Get the original SiteInstance for later comparison.
160 scoped_refptr<SiteInstance> orig_site_instance( 161 scoped_refptr<SiteInstance> orig_site_instance(
161 browser()->GetSelectedTabContents()->GetSiteInstance()); 162 browser()->GetSelectedTabContents()->GetSiteInstance());
162 EXPECT_TRUE(orig_site_instance != NULL); 163 EXPECT_TRUE(orig_site_instance != NULL);
163 164
164 // Test clicking a rel=noreferrer link. 165 // Test clicking a rel=noreferrer link.
165 bool success = false; 166 bool success = false;
166 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 167 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
167 browser()->GetSelectedTabContents()->render_view_host(), L"", 168 browser()->GetSelectedTabContents()->render_view_host(), L"",
168 L"window.domAutomationController.send(clickNoRefLink());", 169 L"window.domAutomationController.send(clickNoRefLink());",
169 &success)); 170 &success));
170 EXPECT_TRUE(success); 171 EXPECT_TRUE(success);
171 // Wait for the cross-site transition to finish. 172 // Wait for the cross-site transition to finish.
172 ui_test_utils::WaitForLoadStop( 173 if (browser()->GetSelectedTabContents()->is_loading())
173 &(browser()->GetSelectedTabContents()->controller())); 174 ui_test_utils::WaitForLoadStop(
175 &(browser()->GetSelectedTabContents()->controller()));
174 176
175 // Opens in same tab. 177 // Opens in same tab.
176 EXPECT_EQ(1, browser()->tab_count()); 178 EXPECT_EQ(1, browser()->tab_count());
177 EXPECT_EQ(0, browser()->selected_index()); 179 EXPECT_EQ(0, browser()->selected_index());
178 EXPECT_EQ(L"Title Of Awesomeness", 180 EXPECT_EQ("/files/title2.html",
179 browser()->GetSelectedTabContents()->GetTitle()); 181 browser()->GetSelectedTabContents()->GetURL().path());
180 182
181 // Should have the same SiteInstance. 183 // Should have the same SiteInstance.
182 scoped_refptr<SiteInstance> noref_site_instance( 184 scoped_refptr<SiteInstance> noref_site_instance(
183 browser()->GetSelectedTabContents()->GetSiteInstance()); 185 browser()->GetSelectedTabContents()->GetSiteInstance());
184 EXPECT_EQ(orig_site_instance, noref_site_instance); 186 EXPECT_EQ(orig_site_instance, noref_site_instance);
185 } 187 }
186 188
187 // Hangs flakily in Win, http://crbug.com/45040. 189 // Hangs flakily in Win, http://crbug.com/45040.
188 #if defined(OS_WIN) 190 #if defined(OS_WIN)
189 #define MAYBE_ChromeURLAfterDownload DISABLED_ChromeURLAfterDownload 191 #define MAYBE_ChromeURLAfterDownload DISABLED_ChromeURLAfterDownload
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 230 }
229 231
230 // NotificationObserver 232 // NotificationObserver
231 virtual void Observe(NotificationType type, 233 virtual void Observe(NotificationType type,
232 const NotificationSource& source, 234 const NotificationSource& source,
233 const NotificationDetails& details) { 235 const NotificationDetails& details) {
234 switch (type.value) { 236 switch (type.value) {
235 case NotificationType::BROWSER_CLOSED: 237 case NotificationType::BROWSER_CLOSED:
236 MessageLoopForUI::current()->Quit(); 238 MessageLoopForUI::current()->Quit();
237 break; 239 break;
240 default:
241 NOTREACHED();
242 break;
238 } 243 }
239 } 244 }
240 245
241 private: 246 private:
242 NotificationRegistrar registrar_; 247 NotificationRegistrar registrar_;
243 }; 248 };
244 249
245 // Test for crbug.com/12745. This tests that if a download is initiated from 250 // 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 251 // a chrome:// page that has registered and onunload handler, the browser
247 // will be able to close. 252 // will be able to close.
(...skipping 20 matching lines...) Expand all
268 &result)); 273 &result));
269 EXPECT_TRUE(result); 274 EXPECT_TRUE(result);
270 ui_test_utils::NavigateToURL(browser(), zip_url); 275 ui_test_utils::NavigateToURL(browser(), zip_url);
271 276
272 ui_test_utils::WaitForDownloadCount( 277 ui_test_utils::WaitForDownloadCount(
273 browser()->profile()->GetDownloadManager(), 1); 278 browser()->profile()->GetDownloadManager(), 1);
274 279
275 browser()->CloseWindow(); 280 browser()->CloseWindow();
276 BrowserClosedObserver wait_for_close(browser()); 281 BrowserClosedObserver wait_for_close(browser());
277 } 282 }
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698