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

Side by Side Diff: chrome/browser/referrer_policy_browsertest.cc

Issue 10479018: Add base::RunLoop and update ui_test_utils to use it to reduce flakiness (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added printfs to debug timeout which doesn't happen locally Created 8 years, 6 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
OLDNEW
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/bind.h" 5 #include "base/bind.h"
6 #include "base/string_number_conversions.h" 6 #include "base/string_number_conversions.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/tab_contents/render_view_context_menu.h" 9 #include "chrome/browser/tab_contents/render_view_context_menu.h"
10 #include "chrome/browser/tab_contents/render_view_context_menu_browsertest_util. h" 10 #include "chrome/browser/tab_contents/render_view_context_menu_browsertest_util. h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 155 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
156 mouse_event.type = WebKit::WebInputEvent::MouseUp; 156 mouse_event.type = WebKit::WebInputEvent::MouseUp;
157 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 157 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
158 } 158 }
159 159
160 if (opens_new_tab) { 160 if (opens_new_tab) {
161 tab_added_observer.Wait(); 161 tab_added_observer.Wait();
162 tab = tab_added_observer.GetTab(); 162 tab = tab_added_observer.GetTab();
163 EXPECT_TRUE(tab); 163 EXPECT_TRUE(tab);
164 ui_test_utils::WaitForLoadStop(tab); 164 ui_test_utils::WaitForLoadStop(tab);
165 ui_test_utils::RunAllPendingInMessageLoop();
165 EXPECT_EQ(expected_title, tab->GetTitle()); 166 EXPECT_EQ(expected_title, tab->GetTitle());
166 } else { 167 } else {
167 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 168 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
168 } 169 }
169 170
170 return start_url; 171 return start_url;
171 } 172 }
172 173
173 scoped_ptr<net::TestServer> test_server_; 174 scoped_ptr<net::TestServer> test_server_;
174 scoped_ptr<net::TestServer> ssl_test_server_; 175 scoped_ptr<net::TestServer> ssl_test_server_;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // User initiated navigation, middle click, target blank, from HTTPS to HTTP. 248 // User initiated navigation, middle click, target blank, from HTTPS to HTTP.
248 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickTargetBlankOrigin) { 249 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickTargetBlankOrigin) {
249 RunReferrerTest("origin", true, true, false, true, 250 RunReferrerTest("origin", true, true, false, true,
250 WebKit::WebMouseEvent::ButtonMiddle, 251 WebKit::WebMouseEvent::ButtonMiddle,
251 EXPECT_ORIGIN_AS_REFERRER); 252 EXPECT_ORIGIN_AS_REFERRER);
252 } 253 }
253 254
254 // Context menu, from HTTP to HTTP. 255 // Context menu, from HTTP to HTTP.
255 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_ContextMenuOrigin) { 256 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_ContextMenuOrigin) {
256 ContextMenuNotificationObserver context_menu_observer( 257 ContextMenuNotificationObserver context_menu_observer(
257 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 258 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB);
jar (doing other things) 2012/06/14 04:50:29 nit: Is wrap needed?
jbates 2012/06/15 02:20:38 wrap still needed (here and below).
258 chrome::NOTIFICATION_TAB_ADDED);
259 RunReferrerTest("origin", false, false, false, true, 259 RunReferrerTest("origin", false, false, false, true,
260 WebKit::WebMouseEvent::ButtonRight, 260 WebKit::WebMouseEvent::ButtonRight,
261 EXPECT_ORIGIN_AS_REFERRER); 261 EXPECT_ORIGIN_AS_REFERRER);
262 } 262 }
263 263
264 // Context menu, from HTTPS to HTTP. 264 // Context menu, from HTTPS to HTTP.
265 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_HttpsContextMenuOrigin) { 265 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_HttpsContextMenuOrigin) {
266 ContextMenuNotificationObserver context_menu_observer( 266 ContextMenuNotificationObserver context_menu_observer(
267 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 267 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB);
jar (doing other things) 2012/06/14 04:50:29 nit: wrap needed?
268 chrome::NOTIFICATION_TAB_ADDED);
269 RunReferrerTest("origin", true, false, false, true, 268 RunReferrerTest("origin", true, false, false, true,
270 WebKit::WebMouseEvent::ButtonRight, 269 WebKit::WebMouseEvent::ButtonRight,
271 EXPECT_ORIGIN_AS_REFERRER); 270 EXPECT_ORIGIN_AS_REFERRER);
272 } 271 }
273 272
274 // Content initiated navigation, from HTTP to HTTP via server redirect. 273 // Content initiated navigation, from HTTP to HTTP via server redirect.
275 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Redirect) { 274 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Redirect) {
276 RunReferrerTest("origin", false, false, true, false, 275 RunReferrerTest("origin", false, false, true, false,
277 WebKit::WebMouseEvent::ButtonNone, 276 WebKit::WebMouseEvent::ButtonNone,
278 EXPECT_ORIGIN_AS_REFERRER); 277 EXPECT_ORIGIN_AS_REFERRER);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, 343 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest,
345 HttpsMiddleClickTargetBlankRedirect) { 344 HttpsMiddleClickTargetBlankRedirect) {
346 RunReferrerTest("origin", true, true, true, true, 345 RunReferrerTest("origin", true, true, true, true,
347 WebKit::WebMouseEvent::ButtonMiddle, 346 WebKit::WebMouseEvent::ButtonMiddle,
348 EXPECT_ORIGIN_AS_REFERRER); 347 EXPECT_ORIGIN_AS_REFERRER);
349 } 348 }
350 349
351 // Context menu, from HTTP to HTTP via server redirect. 350 // Context menu, from HTTP to HTTP via server redirect.
352 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_ContextMenuRedirect) { 351 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_ContextMenuRedirect) {
353 ContextMenuNotificationObserver context_menu_observer( 352 ContextMenuNotificationObserver context_menu_observer(
354 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 353 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB);
jar (doing other things) 2012/06/14 04:50:29 nit: wrap?
355 chrome::NOTIFICATION_TAB_ADDED);
356 RunReferrerTest("origin", false, false, true, true, 354 RunReferrerTest("origin", false, false, true, true,
357 WebKit::WebMouseEvent::ButtonRight, 355 WebKit::WebMouseEvent::ButtonRight,
358 EXPECT_ORIGIN_AS_REFERRER); 356 EXPECT_ORIGIN_AS_REFERRER);
359 } 357 }
360 358
361 // Context menu, from HTTPS to HTTP via server redirect. 359 // Context menu, from HTTPS to HTTP via server redirect.
362 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_HttpsContextMenuRedirect) { 360 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_HttpsContextMenuRedirect) {
363 ContextMenuNotificationObserver context_menu_observer( 361 ContextMenuNotificationObserver context_menu_observer(
364 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 362 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB);
jar (doing other things) 2012/06/14 04:50:29 nit: wrap?
365 chrome::NOTIFICATION_TAB_ADDED);
366 RunReferrerTest("origin", true, false, true, true, 363 RunReferrerTest("origin", true, false, true, true,
367 WebKit::WebMouseEvent::ButtonRight, 364 WebKit::WebMouseEvent::ButtonRight,
368 EXPECT_ORIGIN_AS_REFERRER); 365 EXPECT_ORIGIN_AS_REFERRER);
369 } 366 }
370 367
371 // Tests history navigation actions: Navigate from A to B with a referrer 368 // Tests history navigation actions: Navigate from A to B with a referrer
372 // policy, then navigate to C, back to B, and reload. 369 // policy, then navigate to C, back to B, and reload.
373 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, History) { 370 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, History) {
374 // Navigate from A to B. 371 // Navigate from A to B.
375 GURL start_url = RunReferrerTest("origin", true, false, true, false, 372 GURL start_url = RunReferrerTest("origin", true, false, true, false,
(...skipping 23 matching lines...) Expand all
399 browser()->Reload(CURRENT_TAB); 396 browser()->Reload(CURRENT_TAB);
400 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); 397 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle());
401 398
402 title_watcher.reset(new ui_test_utils::TitleWatcher(tab, expected_title)); 399 title_watcher.reset(new ui_test_utils::TitleWatcher(tab, expected_title));
403 AddAllPossibleTitles(start_url, title_watcher.get()); 400 AddAllPossibleTitles(start_url, title_watcher.get());
404 401
405 // Shift-reload to B. 402 // Shift-reload to B.
406 browser()->ReloadIgnoringCache(CURRENT_TAB); 403 browser()->ReloadIgnoringCache(CURRENT_TAB);
407 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); 404 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle());
408 } 405 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698