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

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 additional flakiness. 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
« chrome/test/ui_test_utils.h ('K') | « chrome/test/ui_test_utils.cc ('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
75 ui_test_utils::WaitForLoadStop( 75 // Wait for the tab to open.
76 &(browser()->GetSelectedTabContents()->controller())); 76 if (browser()->tab_count() < 2)
77 ui_test_utils::WaitForNewTab(browser());
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());
84
85 // Wait for the cross-site transition in the new tab to finish.
86 ui_test_utils::WaitForLoadStop(browser()->GetSelectedTabContents());
87 EXPECT_FALSE(browser()->GetSelectedTabContents()->render_manager()->
88 pending_render_view_host());
83 89
84 // Should have a new SiteInstance. 90 // Should have a new SiteInstance.
85 scoped_refptr<SiteInstance> noref_blank_site_instance( 91 scoped_refptr<SiteInstance> noref_blank_site_instance(
86 browser()->GetSelectedTabContents()->GetSiteInstance()); 92 browser()->GetSelectedTabContents()->GetSiteInstance());
87 EXPECT_NE(orig_site_instance, noref_blank_site_instance); 93 EXPECT_NE(orig_site_instance, noref_blank_site_instance);
88 } 94 }
89 95
90 // Test for crbug.com/24447. Following a cross-site link with just 96 // Test for crbug.com/24447. Following a cross-site link with just
91 // target=_blank should not create a new SiteInstance. 97 // target=_blank should not create a new SiteInstance.
92 // Disabled, http://crbug.com/67532.
93 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, 98 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
94 DISABLED_DontSwapProcessWithOnlyTargetBlank) { 99 DontSwapProcessWithOnlyTargetBlank) {
95 // Start two servers with different sites. 100 // Start two servers with different sites.
96 ASSERT_TRUE(test_server()->Start()); 101 ASSERT_TRUE(test_server()->Start());
97 net::TestServer https_server_( 102 net::TestServer https_server(
98 net::TestServer::TYPE_HTTPS, 103 net::TestServer::TYPE_HTTPS,
99 FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 104 FilePath(FILE_PATH_LITERAL("chrome/test/data")));
100 ASSERT_TRUE(https_server_.Start()); 105 ASSERT_TRUE(https_server.Start());
101 106
102 // Load a page with links that open in a new window. 107 // Load a page with links that open in a new window.
103 std::string replacement_path; 108 std::string replacement_path;
104 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 109 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
105 "files/click-noreferrer-links.html", 110 "files/click-noreferrer-links.html",
106 https_server_.host_port_pair(), 111 https_server.host_port_pair(),
107 &replacement_path)); 112 &replacement_path));
108 ui_test_utils::NavigateToURL(browser(), 113 ui_test_utils::NavigateToURL(browser(),
109 test_server()->GetURL(replacement_path)); 114 test_server()->GetURL(replacement_path));
110 115
111 // Get the original SiteInstance for later comparison. 116 // Get the original SiteInstance for later comparison.
112 scoped_refptr<SiteInstance> orig_site_instance( 117 scoped_refptr<SiteInstance> orig_site_instance(
113 browser()->GetSelectedTabContents()->GetSiteInstance()); 118 browser()->GetSelectedTabContents()->GetSiteInstance());
114 EXPECT_TRUE(orig_site_instance != NULL); 119 EXPECT_TRUE(orig_site_instance != NULL);
115 120
116 // Test clicking a target=blank link. 121 // Test clicking a target=blank link.
117 bool success = false; 122 bool success = false;
118 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 123 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
119 browser()->GetSelectedTabContents()->render_view_host(), L"", 124 browser()->GetSelectedTabContents()->render_view_host(), L"",
120 L"window.domAutomationController.send(clickTargetBlankLink());", 125 L"window.domAutomationController.send(clickTargetBlankLink());",
121 &success)); 126 &success));
122 EXPECT_TRUE(success); 127 EXPECT_TRUE(success);
123 // Wait for the cross-site transition to finish. 128
124 ui_test_utils::WaitForLoadStop( 129 // Wait for the tab to open.
125 &(browser()->GetSelectedTabContents()->controller())); 130 if (browser()->tab_count() < 2)
131 ui_test_utils::WaitForNewTab(browser());
126 132
127 // Opens in new tab. 133 // Opens in new tab.
128 EXPECT_EQ(2, browser()->tab_count()); 134 EXPECT_EQ(2, browser()->tab_count());
129 EXPECT_EQ(1, browser()->selected_index()); 135 EXPECT_EQ(1, browser()->selected_index());
130 EXPECT_EQ(L"Title Of Awesomeness", 136
131 browser()->GetSelectedTabContents()->GetTitle()); 137 // Wait for the cross-site transition in the new tab to finish.
138 ui_test_utils::WaitForLoadStop(browser()->GetSelectedTabContents());
139 EXPECT_EQ("/files/title2.html",
140 browser()->GetSelectedTabContents()->GetURL().path());
132 141
133 // Should have the same SiteInstance. 142 // Should have the same SiteInstance.
134 scoped_refptr<SiteInstance> blank_site_instance( 143 scoped_refptr<SiteInstance> blank_site_instance(
135 browser()->GetSelectedTabContents()->GetSiteInstance()); 144 browser()->GetSelectedTabContents()->GetSiteInstance());
136 EXPECT_EQ(orig_site_instance, blank_site_instance); 145 EXPECT_EQ(orig_site_instance, blank_site_instance);
137 } 146 }
138 147
139 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer 148 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer
140 // and no target=_blank should not create a new SiteInstance. 149 // and no target=_blank should not create a new SiteInstance.
141 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, 150 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
142 DontSwapProcessWithOnlyRelNoreferrer) { 151 DontSwapProcessWithOnlyRelNoreferrer) {
143 // Start two servers with different sites. 152 // Start two servers with different sites.
144 ASSERT_TRUE(test_server()->Start()); 153 ASSERT_TRUE(test_server()->Start());
145 net::TestServer https_server_( 154 net::TestServer https_server(
146 net::TestServer::TYPE_HTTPS, 155 net::TestServer::TYPE_HTTPS,
147 FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 156 FilePath(FILE_PATH_LITERAL("chrome/test/data")));
148 ASSERT_TRUE(https_server_.Start()); 157 ASSERT_TRUE(https_server.Start());
149 158
150 // Load a page with links that open in a new window. 159 // Load a page with links that open in a new window.
151 std::string replacement_path; 160 std::string replacement_path;
152 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 161 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
153 "files/click-noreferrer-links.html", 162 "files/click-noreferrer-links.html",
154 https_server_.host_port_pair(), 163 https_server.host_port_pair(),
155 &replacement_path)); 164 &replacement_path));
156 ui_test_utils::NavigateToURL(browser(), 165 ui_test_utils::NavigateToURL(browser(),
157 test_server()->GetURL(replacement_path)); 166 test_server()->GetURL(replacement_path));
158 167
159 // Get the original SiteInstance for later comparison. 168 // Get the original SiteInstance for later comparison.
160 scoped_refptr<SiteInstance> orig_site_instance( 169 scoped_refptr<SiteInstance> orig_site_instance(
161 browser()->GetSelectedTabContents()->GetSiteInstance()); 170 browser()->GetSelectedTabContents()->GetSiteInstance());
162 EXPECT_TRUE(orig_site_instance != NULL); 171 EXPECT_TRUE(orig_site_instance != NULL);
163 172
164 // Test clicking a rel=noreferrer link. 173 // Test clicking a rel=noreferrer link.
165 bool success = false; 174 bool success = false;
166 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 175 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
167 browser()->GetSelectedTabContents()->render_view_host(), L"", 176 browser()->GetSelectedTabContents()->render_view_host(), L"",
168 L"window.domAutomationController.send(clickNoRefLink());", 177 L"window.domAutomationController.send(clickNoRefLink());",
169 &success)); 178 &success));
170 EXPECT_TRUE(success); 179 EXPECT_TRUE(success);
171 // Wait for the cross-site transition to finish. 180
172 ui_test_utils::WaitForLoadStop( 181 // Wait for the cross-site transition in the current tab to finish.
173 &(browser()->GetSelectedTabContents()->controller())); 182 ui_test_utils::WaitForLoadStop(browser()->GetSelectedTabContents());
174 183
175 // Opens in same tab. 184 // Opens in same tab.
176 EXPECT_EQ(1, browser()->tab_count()); 185 EXPECT_EQ(1, browser()->tab_count());
177 EXPECT_EQ(0, browser()->selected_index()); 186 EXPECT_EQ(0, browser()->selected_index());
178 EXPECT_EQ(L"Title Of Awesomeness", 187 EXPECT_EQ("/files/title2.html",
179 browser()->GetSelectedTabContents()->GetTitle()); 188 browser()->GetSelectedTabContents()->GetURL().path());
180 189
181 // Should have the same SiteInstance. 190 // Should have the same SiteInstance.
182 scoped_refptr<SiteInstance> noref_site_instance( 191 scoped_refptr<SiteInstance> noref_site_instance(
183 browser()->GetSelectedTabContents()->GetSiteInstance()); 192 browser()->GetSelectedTabContents()->GetSiteInstance());
184 EXPECT_EQ(orig_site_instance, noref_site_instance); 193 EXPECT_EQ(orig_site_instance, noref_site_instance);
185 } 194 }
186 195
187 // Hangs flakily in Win, http://crbug.com/45040. 196 // Hangs flakily in Win, http://crbug.com/45040.
188 #if defined(OS_WIN) 197 #if defined(OS_WIN)
189 #define MAYBE_ChromeURLAfterDownload DISABLED_ChromeURLAfterDownload 198 #define MAYBE_ChromeURLAfterDownload DISABLED_ChromeURLAfterDownload
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 237 }
229 238
230 // NotificationObserver 239 // NotificationObserver
231 virtual void Observe(NotificationType type, 240 virtual void Observe(NotificationType type,
232 const NotificationSource& source, 241 const NotificationSource& source,
233 const NotificationDetails& details) { 242 const NotificationDetails& details) {
234 switch (type.value) { 243 switch (type.value) {
235 case NotificationType::BROWSER_CLOSED: 244 case NotificationType::BROWSER_CLOSED:
236 MessageLoopForUI::current()->Quit(); 245 MessageLoopForUI::current()->Quit();
237 break; 246 break;
247 default:
248 NOTREACHED();
249 break;
238 } 250 }
239 } 251 }
240 252
241 private: 253 private:
242 NotificationRegistrar registrar_; 254 NotificationRegistrar registrar_;
243 }; 255 };
244 256
245 // Test for crbug.com/12745. This tests that if a download is initiated from 257 // 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 258 // a chrome:// page that has registered and onunload handler, the browser
247 // will be able to close. 259 // will be able to close.
(...skipping 20 matching lines...) Expand all
268 &result)); 280 &result));
269 EXPECT_TRUE(result); 281 EXPECT_TRUE(result);
270 ui_test_utils::NavigateToURL(browser(), zip_url); 282 ui_test_utils::NavigateToURL(browser(), zip_url);
271 283
272 ui_test_utils::WaitForDownloadCount( 284 ui_test_utils::WaitForDownloadCount(
273 browser()->profile()->GetDownloadManager(), 1); 285 browser()->profile()->GetDownloadManager(), 1);
274 286
275 browser()->CloseWindow(); 287 browser()->CloseWindow();
276 BrowserClosedObserver wait_for_close(browser()); 288 BrowserClosedObserver wait_for_close(browser());
277 } 289 }
OLDNEW
« chrome/test/ui_test_utils.h ('K') | « chrome/test/ui_test_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698