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

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

Issue 252743006: Revert of Prepare browser_tests for data: urls being async (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
137 void RenderViewTest::LoadHTML(const char* html) { 116 void RenderViewTest::LoadHTML(const char* html) {
138 std::string url_str = "data:text/html;charset=utf-8,"; 117 std::string url_str = "data:text/html;charset=utf-8,";
139 url_str.append(html); 118 url_str.append(html);
140 GURL url(url_str); 119 GURL url(url_str);
141 FrameLoadWaiter waiter(view_, &msg_loop_); 120
142 GetMainFrame()->loadRequest(WebURLRequest(url)); 121 GetMainFrame()->loadRequest(WebURLRequest(url));
122
143 // The load actually happens asynchronously, so we pump messages to process 123 // The load actually happens asynchronously, so we pump messages to process
144 // the pending continuation. 124 // the pending continuation.
145 waiter.Wait(); 125 ProcessPendingMessages();
146 } 126 }
147 127
148 void RenderViewTest::GoBack(const blink::WebHistoryItem& item) { 128 void RenderViewTest::GoBack(const blink::WebHistoryItem& item) {
149 GoToOffset(-1, item); 129 GoToOffset(-1, item);
150 } 130 }
151 131
152 void RenderViewTest::GoForward(const blink::WebHistoryItem& item) { 132 void RenderViewTest::GoForward(const blink::WebHistoryItem& item) {
153 GoToOffset(1, item); 133 GoToOffset(1, item);
154 } 134 }
155 135
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 FrameMsg_Navigate navigate_message(impl->main_render_frame()->GetRoutingID(), 421 FrameMsg_Navigate navigate_message(impl->main_render_frame()->GetRoutingID(),
442 navigate_params); 422 navigate_params);
443 impl->main_render_frame()->OnMessageReceived(navigate_message); 423 impl->main_render_frame()->OnMessageReceived(navigate_message);
444 424
445 // The load actually happens asynchronously, so we pump messages to process 425 // The load actually happens asynchronously, so we pump messages to process
446 // the pending continuation. 426 // the pending continuation.
447 ProcessPendingMessages(); 427 ProcessPendingMessages();
448 } 428 }
449 429
450 } // namespace content 430 } // 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