| 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/browser_test_utils.h" | 5 #include "content/public/test/browser_test_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 : render_frame_host_(render_frame_host) { | 655 : render_frame_host_(render_frame_host) { |
| 656 } | 656 } |
| 657 | 657 |
| 658 bool ExecuteScript(const ToRenderFrameHost& adapter, | 658 bool ExecuteScript(const ToRenderFrameHost& adapter, |
| 659 const std::string& script) { | 659 const std::string& script) { |
| 660 std::string new_script = | 660 std::string new_script = |
| 661 script + ";window.domAutomationController.send(0);"; | 661 script + ";window.domAutomationController.send(0);"; |
| 662 return ExecuteScriptHelper(adapter.render_frame_host(), new_script, NULL); | 662 return ExecuteScriptHelper(adapter.render_frame_host(), new_script, NULL); |
| 663 } | 663 } |
| 664 | 664 |
| 665 bool ExecuteScriptAndExtractDouble(const ToRenderFrameHost& adapter, |
| 666 const std::string& script, double* result) { |
| 667 DCHECK(result); |
| 668 std::unique_ptr<base::Value> value; |
| 669 if (!ExecuteScriptHelper(adapter.render_frame_host(), script, &value) || |
| 670 !value.get()) { |
| 671 return false; |
| 672 } |
| 673 |
| 674 return value->GetAsDouble(result); |
| 675 } |
| 676 |
| 665 bool ExecuteScriptAndExtractInt(const ToRenderFrameHost& adapter, | 677 bool ExecuteScriptAndExtractInt(const ToRenderFrameHost& adapter, |
| 666 const std::string& script, int* result) { | 678 const std::string& script, int* result) { |
| 667 DCHECK(result); | 679 DCHECK(result); |
| 668 std::unique_ptr<base::Value> value; | 680 std::unique_ptr<base::Value> value; |
| 669 if (!ExecuteScriptHelper(adapter.render_frame_host(), script, &value) || | 681 if (!ExecuteScriptHelper(adapter.render_frame_host(), script, &value) || |
| 670 !value.get()) { | 682 !value.get()) { |
| 671 return false; | 683 return false; |
| 672 } | 684 } |
| 673 | 685 |
| 674 return value->GetAsInteger(result); | 686 return value->GetAsInteger(result); |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1241 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1230 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN) | 1242 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN) |
| 1231 return ack_result_; | 1243 return ack_result_; |
| 1232 base::RunLoop run_loop; | 1244 base::RunLoop run_loop; |
| 1233 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); | 1245 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); |
| 1234 run_loop.Run(); | 1246 run_loop.Run(); |
| 1235 return ack_result_; | 1247 return ack_result_; |
| 1236 } | 1248 } |
| 1237 | 1249 |
| 1238 } // namespace content | 1250 } // namespace content |
| OLD | NEW |