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

Unified Diff: content/public/test/render_view_test.cc

Issue 257723002: Prepare browser_tests for data: urls being async (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more style fixes Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/render_view_test.cc
diff --git a/content/public/test/render_view_test.cc b/content/public/test/render_view_test.cc
index 94d7b63a584a65695b06cddec76d12479580e28e..e498a34409de95d499f37aff67b78b5626108ca9 100644
--- a/content/public/test/render_view_test.cc
+++ b/content/public/test/render_view_test.cc
@@ -113,16 +113,36 @@ bool RenderViewTest::ExecuteJavaScriptAndReturnIntValue(
return true;
}
+class FrameLoadWaiter : public content::RenderViewObserver {
+ public:
+ FrameLoadWaiter(RenderView* view, base::MessageLoop* msg_loop)
+ : content::RenderViewObserver(view),
+ msg_loop_(msg_loop) {}
+
+ virtual void DidFinishLoad(blink::WebLocalFrame* frame) OVERRIDE {
+ msg_loop_->PostTask(FROM_HERE, base::MessageLoop::QuitClosure());
+ }
+
+ void Wait() {
+ // We can't just post a quit message here, blink parses on another
+ // thread and may post additional messages as it parses content.
+ msg_loop_->Run();
+ }
+ private:
+ base::MessageLoop* msg_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(FrameLoadWaiter);
+};
+
void RenderViewTest::LoadHTML(const char* html) {
std::string url_str = "data:text/html;charset=utf-8,";
url_str.append(html);
GURL url(url_str);
-
+ FrameLoadWaiter waiter(view_, &msg_loop_);
GetMainFrame()->loadRequest(WebURLRequest(url));
-
// The load actually happens asynchronously, so we pump messages to process
// the pending continuation.
- ProcessPendingMessages();
+ waiter.Wait();
}
void RenderViewTest::GoBack(const blink::WebHistoryItem& item) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698