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/input_messages.h" | 9 #include "content/common/input_messages.h" |
10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 return view_->GetWebView()->mainFrame(); | 86 return view_->GetWebView()->mainFrame(); |
87 } | 87 } |
88 | 88 |
89 void RenderViewTest::ExecuteJavaScript(const char* js) { | 89 void RenderViewTest::ExecuteJavaScript(const char* js) { |
90 GetMainFrame()->executeScript(WebScriptSource(WebString::fromUTF8(js))); | 90 GetMainFrame()->executeScript(WebScriptSource(WebString::fromUTF8(js))); |
91 } | 91 } |
92 | 92 |
93 bool RenderViewTest::ExecuteJavaScriptAndReturnIntValue( | 93 bool RenderViewTest::ExecuteJavaScriptAndReturnIntValue( |
94 const string16& script, | 94 const string16& script, |
95 int* int_result) { | 95 int* int_result) { |
96 v8::HandleScope handle_scope; | 96 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
97 v8::Handle<v8::Value> result = | 97 v8::Handle<v8::Value> result = |
98 GetMainFrame()->executeScriptAndReturnValue(WebScriptSource(script)); | 98 GetMainFrame()->executeScriptAndReturnValue(WebScriptSource(script)); |
99 if (result.IsEmpty() || !result->IsInt32()) | 99 if (result.IsEmpty() || !result->IsInt32()) |
100 return false; | 100 return false; |
101 | 101 |
102 if (int_result) | 102 if (int_result) |
103 *int_result = result->Int32Value(); | 103 *int_result = result->Int32Value(); |
104 | 104 |
105 return true; | 105 return true; |
106 } | 106 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 " bounds[2] = elem.offsetWidth;" | 248 " bounds[2] = elem.offsetWidth;" |
249 " bounds[3] = elem.offsetHeight;" | 249 " bounds[3] = elem.offsetHeight;" |
250 " return bounds;" | 250 " return bounds;" |
251 "})();"; | 251 "})();"; |
252 gfx::Rect RenderViewTest::GetElementBounds(const std::string& element_id) { | 252 gfx::Rect RenderViewTest::GetElementBounds(const std::string& element_id) { |
253 std::vector<std::string> params; | 253 std::vector<std::string> params; |
254 params.push_back(element_id); | 254 params.push_back(element_id); |
255 std::string script = | 255 std::string script = |
256 ReplaceStringPlaceholders(kGetCoordinatesScript, params, NULL); | 256 ReplaceStringPlaceholders(kGetCoordinatesScript, params, NULL); |
257 | 257 |
258 v8::HandleScope handle_scope; | 258 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
259 v8::Handle<v8::Value> value = GetMainFrame()->executeScriptAndReturnValue( | 259 v8::Handle<v8::Value> value = GetMainFrame()->executeScriptAndReturnValue( |
260 WebScriptSource(WebString::fromUTF8(script))); | 260 WebScriptSource(WebString::fromUTF8(script))); |
261 if (value.IsEmpty() || !value->IsArray()) | 261 if (value.IsEmpty() || !value->IsArray()) |
262 return gfx::Rect(); | 262 return gfx::Rect(); |
263 | 263 |
264 v8::Handle<v8::Array> array = value.As<v8::Array>(); | 264 v8::Handle<v8::Array> array = value.As<v8::Array>(); |
265 if (array->Length() != 4) | 265 if (array->Length() != 4) |
266 return gfx::Rect(); | 266 return gfx::Rect(); |
267 std::vector<int> coords; | 267 std::vector<int> coords; |
268 for (int i = 0; i < 4; ++i) { | 268 for (int i = 0; i < 4; ++i) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 372 |
373 ViewMsg_Navigate navigate_message(impl->GetRoutingID(), navigate_params); | 373 ViewMsg_Navigate navigate_message(impl->GetRoutingID(), navigate_params); |
374 OnMessageReceived(navigate_message); | 374 OnMessageReceived(navigate_message); |
375 | 375 |
376 // The load actually happens asynchronously, so we pump messages to process | 376 // The load actually happens asynchronously, so we pump messages to process |
377 // the pending continuation. | 377 // the pending continuation. |
378 ProcessPendingMessages(); | 378 ProcessPendingMessages(); |
379 } | 379 } |
380 | 380 |
381 } // namespace content | 381 } // namespace content |
OLD | NEW |