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

Side by Side Diff: content/public/test/browser_test_utils.cc

Issue 1297713004: Fix flakiness in postMessage-related SitePerProcessBrowserTests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Charlie's comments (and rebase) Created 5 years, 4 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
« no previous file with comments | « content/browser/site_per_process_browsertest.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) 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 "content/public/test/browser_test_utils.h" 5 #include "content/public/test/browser_test_utils.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 registrar_.Add(this, NOTIFICATION_DOM_OPERATION_RESPONSE, 68 registrar_.Add(this, NOTIFICATION_DOM_OPERATION_RESPONSE,
69 Source<WebContents>(web_contents())); 69 Source<WebContents>(web_contents()));
70 message_loop_runner_ = new MessageLoopRunner; 70 message_loop_runner_ = new MessageLoopRunner;
71 } 71 }
72 72
73 void Observe(int type, 73 void Observe(int type,
74 const NotificationSource& source, 74 const NotificationSource& source,
75 const NotificationDetails& details) override { 75 const NotificationDetails& details) override {
76 DCHECK(type == NOTIFICATION_DOM_OPERATION_RESPONSE); 76 DCHECK(type == NOTIFICATION_DOM_OPERATION_RESPONSE);
77 Details<DomOperationNotificationDetails> dom_op_details(details); 77 Details<DomOperationNotificationDetails> dom_op_details(details);
78 response_ = dom_op_details->json; 78 if (!did_respond_) {
79 did_respond_ = true; 79 response_ = dom_op_details->json;
80 message_loop_runner_->Quit(); 80 did_respond_ = true;
81 message_loop_runner_->Quit();
82 }
81 } 83 }
82 84
83 // Overridden from WebContentsObserver: 85 // Overridden from WebContentsObserver:
84 void RenderProcessGone(base::TerminationStatus status) override { 86 void RenderProcessGone(base::TerminationStatus status) override {
85 message_loop_runner_->Quit(); 87 message_loop_runner_->Quit();
86 } 88 }
87 89
88 bool WaitAndGetResponse(std::string* response) WARN_UNUSED_RESULT { 90 bool WaitAndGetResponse(std::string* response) WARN_UNUSED_RESULT {
89 message_loop_runner_->Run(); 91 message_loop_runner_->Run();
90 *response = response_; 92 *response = response_;
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 void FrameWatcher::WaitFrames(int frames_to_wait) { 987 void FrameWatcher::WaitFrames(int frames_to_wait) {
986 if (frames_to_wait <= 0) 988 if (frames_to_wait <= 0)
987 return; 989 return;
988 base::RunLoop run_loop; 990 base::RunLoop run_loop;
989 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); 991 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure());
990 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); 992 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait);
991 run_loop.Run(); 993 run_loop.Run();
992 } 994 }
993 995
994 } // namespace content 996 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/site_per_process_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698