| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/process/kill.h" | 10 #include "base/process/kill.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // of the script in |result|. Returns true on success. | 89 // of the script in |result|. Returns true on success. |
| 90 bool ExecuteScriptHelper(RenderViewHost* render_view_host, | 90 bool ExecuteScriptHelper(RenderViewHost* render_view_host, |
| 91 const std::string& frame_xpath, | 91 const std::string& frame_xpath, |
| 92 const std::string& original_script, | 92 const std::string& original_script, |
| 93 scoped_ptr<base::Value>* result) { | 93 scoped_ptr<base::Value>* result) { |
| 94 // TODO(jcampan): we should make the domAutomationController not require an | 94 // TODO(jcampan): we should make the domAutomationController not require an |
| 95 // automation id. | 95 // automation id. |
| 96 std::string script = | 96 std::string script = |
| 97 "window.domAutomationController.setAutomationId(0);" + original_script; | 97 "window.domAutomationController.setAutomationId(0);" + original_script; |
| 98 DOMOperationObserver dom_op_observer(render_view_host); | 98 DOMOperationObserver dom_op_observer(render_view_host); |
| 99 render_view_host->ExecuteJavascriptInWebFrame(UTF8ToUTF16(frame_xpath), | 99 render_view_host->ExecuteJavascriptInWebFrame(base::UTF8ToUTF16(frame_xpath), |
| 100 UTF8ToUTF16(script)); | 100 base::UTF8ToUTF16(script)); |
| 101 std::string json; | 101 std::string json; |
| 102 if (!dom_op_observer.WaitAndGetResponse(&json)) { | 102 if (!dom_op_observer.WaitAndGetResponse(&json)) { |
| 103 DLOG(ERROR) << "Cannot communicate with DOMOperationObserver."; | 103 DLOG(ERROR) << "Cannot communicate with DOMOperationObserver."; |
| 104 return false; | 104 return false; |
| 105 } | 105 } |
| 106 | 106 |
| 107 // Nothing more to do for callers that ignore the returned JS value. | 107 // Nothing more to do for callers that ignore the returned JS value. |
| 108 if (!result) | 108 if (!result) |
| 109 return true; | 109 return true; |
| 110 | 110 |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 // The queue should not be empty, unless we were quit because of a timeout. | 634 // The queue should not be empty, unless we were quit because of a timeout. |
| 635 if (message_queue_.empty()) | 635 if (message_queue_.empty()) |
| 636 return false; | 636 return false; |
| 637 if (message) | 637 if (message) |
| 638 *message = message_queue_.front(); | 638 *message = message_queue_.front(); |
| 639 message_queue_.pop(); | 639 message_queue_.pop(); |
| 640 return true; | 640 return true; |
| 641 } | 641 } |
| 642 | 642 |
| 643 } // namespace content | 643 } // namespace content |
| OLD | NEW |