OLD | NEW |
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 GetMainFrame()->executeScriptAndReturnValue(WebScriptSource(script)); | 107 GetMainFrame()->executeScriptAndReturnValue(WebScriptSource(script)); |
108 if (result.IsEmpty() || !result->IsInt32()) | 108 if (result.IsEmpty() || !result->IsInt32()) |
109 return false; | 109 return false; |
110 | 110 |
111 if (int_result) | 111 if (int_result) |
112 *int_result = result->Int32Value(); | 112 *int_result = result->Int32Value(); |
113 | 113 |
114 return true; | 114 return true; |
115 } | 115 } |
116 | 116 |
| 117 bool RenderViewTest::ExecuteJavaScriptAndReturnStringValue( |
| 118 const base::string16& script, |
| 119 std::string& value) |
| 120 { |
| 121 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
| 122 v8::Handle<v8::Value> result = |
| 123 GetMainFrame()->executeScriptAndReturnValue(WebScriptSource(script)); |
| 124 if (result.IsEmpty() || !result->IsString()) |
| 125 return false; |
| 126 |
| 127 std::string resultStr(*v8::String::Utf8Value(result)); |
| 128 value.swap(resultStr); |
| 129 return true; |
| 130 } |
| 131 |
117 void RenderViewTest::LoadHTML(const char* html) { | 132 void RenderViewTest::LoadHTML(const char* html) { |
118 std::string url_str = "data:text/html;charset=utf-8,"; | 133 std::string url_str = "data:text/html;charset=utf-8,"; |
119 url_str.append(html); | 134 url_str.append(html); |
120 GURL url(url_str); | 135 GURL url(url_str); |
121 GetMainFrame()->loadRequest(WebURLRequest(url)); | 136 GetMainFrame()->loadRequest(WebURLRequest(url)); |
122 // The load actually happens asynchronously, so we pump messages to process | 137 // The load actually happens asynchronously, so we pump messages to process |
123 // the pending continuation. | 138 // the pending continuation. |
124 FrameLoadWaiter(view_->GetMainRenderFrame()).Wait(); | 139 FrameLoadWaiter(view_->GetMainRenderFrame()).Wait(); |
125 } | 140 } |
126 | 141 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 FrameMsg_Navigate navigate_message(impl->main_render_frame()->GetRoutingID(), | 436 FrameMsg_Navigate navigate_message(impl->main_render_frame()->GetRoutingID(), |
422 navigate_params); | 437 navigate_params); |
423 impl->main_render_frame()->OnMessageReceived(navigate_message); | 438 impl->main_render_frame()->OnMessageReceived(navigate_message); |
424 | 439 |
425 // The load actually happens asynchronously, so we pump messages to process | 440 // The load actually happens asynchronously, so we pump messages to process |
426 // the pending continuation. | 441 // the pending continuation. |
427 FrameLoadWaiter(view_->GetMainRenderFrame()).Wait(); | 442 FrameLoadWaiter(view_->GetMainRenderFrame()).Wait(); |
428 } | 443 } |
429 | 444 |
430 } // namespace content | 445 } // namespace content |
OLD | NEW |