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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | 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/render_view_test.h" 5 #include "content/public/test/render_view_test.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "content/common/dom_storage/dom_storage_types.h" 8 #include "content/common/dom_storage/dom_storage_types.h"
9 #include "content/common/frame_messages.h" 9 #include "content/common/frame_messages.h"
10 #include "content/common/input_messages.h" 10 #include "content/common/input_messages.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 GetMainFrame()->executeScriptAndReturnValue(WebScriptSource(script)); 106 GetMainFrame()->executeScriptAndReturnValue(WebScriptSource(script));
107 if (result.IsEmpty() || !result->IsInt32()) 107 if (result.IsEmpty() || !result->IsInt32())
108 return false; 108 return false;
109 109
110 if (int_result) 110 if (int_result)
111 *int_result = result->Int32Value(); 111 *int_result = result->Int32Value();
112 112
113 return true; 113 return true;
114 } 114 }
115 115
116 class FrameLoadWaiter : public content::RenderViewObserver {
117 public:
118 FrameLoadWaiter(RenderView* view, base::MessageLoop* msg_loop)
119 : content::RenderViewObserver(view),
120 msg_loop_(msg_loop) {}
121
122 virtual void DidFinishLoad(blink::WebLocalFrame* frame) OVERRIDE {
123 msg_loop_->PostTask(FROM_HERE, base::MessageLoop::QuitClosure());
124 }
125
126 void Wait() {
127 // We can't just post a quit message here, blink parses on another
128 // thread and may post additional messages as it parses content.
129 msg_loop_->Run();
130 }
131 private:
132 base::MessageLoop* msg_loop_;
133
134 DISALLOW_COPY_AND_ASSIGN(FrameLoadWaiter);
135 };
136
116 void RenderViewTest::LoadHTML(const char* html) { 137 void RenderViewTest::LoadHTML(const char* html) {
117 std::string url_str = "data:text/html;charset=utf-8,"; 138 std::string url_str = "data:text/html;charset=utf-8,";
118 url_str.append(html); 139 url_str.append(html);
119 GURL url(url_str); 140 GURL url(url_str);
120 141 FrameLoadWaiter waiter(view_, &msg_loop_);
121 GetMainFrame()->loadRequest(WebURLRequest(url)); 142 GetMainFrame()->loadRequest(WebURLRequest(url));
122
123 // The load actually happens asynchronously, so we pump messages to process 143 // The load actually happens asynchronously, so we pump messages to process
124 // the pending continuation. 144 // the pending continuation.
125 ProcessPendingMessages(); 145 waiter.Wait();
126 } 146 }
127 147
128 void RenderViewTest::GoBack(const blink::WebHistoryItem& item) { 148 void RenderViewTest::GoBack(const blink::WebHistoryItem& item) {
129 GoToOffset(-1, item); 149 GoToOffset(-1, item);
130 } 150 }
131 151
132 void RenderViewTest::GoForward(const blink::WebHistoryItem& item) { 152 void RenderViewTest::GoForward(const blink::WebHistoryItem& item) {
133 GoToOffset(1, item); 153 GoToOffset(1, item);
134 } 154 }
135 155
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 FrameMsg_Navigate navigate_message(impl->main_render_frame()->GetRoutingID(), 441 FrameMsg_Navigate navigate_message(impl->main_render_frame()->GetRoutingID(),
422 navigate_params); 442 navigate_params);
423 impl->main_render_frame()->OnMessageReceived(navigate_message); 443 impl->main_render_frame()->OnMessageReceived(navigate_message);
424 444
425 // The load actually happens asynchronously, so we pump messages to process 445 // The load actually happens asynchronously, so we pump messages to process
426 // the pending continuation. 446 // the pending continuation.
427 ProcessPendingMessages(); 447 ProcessPendingMessages();
428 } 448 }
429 449
430 } // namespace content 450 } // namespace content
OLDNEW
« 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