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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // |render_frame_host|. If |result| is not NULL, stores the value that the | 102 // |render_frame_host|. If |result| is not NULL, stores the value that the |
103 // evaluation of the script in |result|. Returns true on success. | 103 // evaluation of the script in |result|. Returns true on success. |
104 bool ExecuteScriptHelper(RenderFrameHost* render_frame_host, | 104 bool ExecuteScriptHelper(RenderFrameHost* render_frame_host, |
105 const std::string& original_script, | 105 const std::string& original_script, |
106 scoped_ptr<base::Value>* result) { | 106 scoped_ptr<base::Value>* result) { |
107 // TODO(jcampan): we should make the domAutomationController not require an | 107 // TODO(jcampan): we should make the domAutomationController not require an |
108 // automation id. | 108 // automation id. |
109 std::string script = | 109 std::string script = |
110 "window.domAutomationController.setAutomationId(0);" + original_script; | 110 "window.domAutomationController.setAutomationId(0);" + original_script; |
111 DOMOperationObserver dom_op_observer(render_frame_host->GetRenderViewHost()); | 111 DOMOperationObserver dom_op_observer(render_frame_host->GetRenderViewHost()); |
112 render_frame_host->ExecuteJavaScript(base::UTF8ToUTF16(script)); | 112 render_frame_host->ExecuteJavaScriptForTests(base::UTF8ToUTF16(script)); |
113 std::string json; | 113 std::string json; |
114 if (!dom_op_observer.WaitAndGetResponse(&json)) { | 114 if (!dom_op_observer.WaitAndGetResponse(&json)) { |
115 DLOG(ERROR) << "Cannot communicate with DOMOperationObserver."; | 115 DLOG(ERROR) << "Cannot communicate with DOMOperationObserver."; |
116 return false; | 116 return false; |
117 } | 117 } |
118 | 118 |
119 // Nothing more to do for callers that ignore the returned JS value. | 119 // Nothing more to do for callers that ignore the returned JS value. |
120 if (!result) | 120 if (!result) |
121 return true; | 121 return true; |
122 | 122 |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 } | 726 } |
727 // The queue should not be empty, unless we were quit because of a timeout. | 727 // The queue should not be empty, unless we were quit because of a timeout. |
728 if (message_queue_.empty()) | 728 if (message_queue_.empty()) |
729 return false; | 729 return false; |
730 *message = message_queue_.front(); | 730 *message = message_queue_.front(); |
731 message_queue_.pop(); | 731 message_queue_.pop(); |
732 return true; | 732 return true; |
733 } | 733 } |
734 | 734 |
735 } // namespace content | 735 } // namespace content |
OLD | NEW |