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 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 // the below functions. Returns true on success. | 212 // the below functions. Returns true on success. |
213 bool ExecuteScript(const ToRenderFrameHost& adapter, | 213 bool ExecuteScript(const ToRenderFrameHost& adapter, |
214 const std::string& script) WARN_UNUSED_RESULT; | 214 const std::string& script) WARN_UNUSED_RESULT; |
215 | 215 |
216 // Same as content::ExecuteScript but doesn't send a user gesture to the | 216 // Same as content::ExecuteScript but doesn't send a user gesture to the |
217 // renderer. | 217 // renderer. |
218 bool ExecuteScriptWithoutUserGesture(const ToRenderFrameHost& adapter, | 218 bool ExecuteScriptWithoutUserGesture(const ToRenderFrameHost& adapter, |
219 const std::string& script) | 219 const std::string& script) |
220 WARN_UNUSED_RESULT; | 220 WARN_UNUSED_RESULT; |
221 | 221 |
222 // The following methods execute the passed |script| in the specified frame with | 222 // Kicks off execution of the |script| in the specified frame and returns |
223 // the user gesture and set |result| to the value passed to | 223 // immediately (unlike ExecuteScript above). |
224 // "window.domAutomationController.send" by the executed script. They return | 224 // |
225 // true on success, false if the script execution failed or did not evaluate to | 225 // This function is useful when extra calls to domAutomationController.send |
226 // the expected type. | 226 // are undesirable. |
| 227 // |
| 228 // Returns true on success. |
| 229 void ExecuteUnmodifiedScript(const ToRenderFrameHost& adapter, |
| 230 const std::string& script); |
| 231 |
| 232 // The following methods execute the passed |script| in the specified frame and |
| 233 // sets |result| to the value passed to "window.domAutomationController.send" by |
| 234 // the executed script. They return true on success, false if the script |
| 235 // execution failed or did not evaluate to the expected type. |
227 bool ExecuteScriptAndExtractDouble(const ToRenderFrameHost& adapter, | 236 bool ExecuteScriptAndExtractDouble(const ToRenderFrameHost& adapter, |
228 const std::string& script, | 237 const std::string& script, |
229 double* result) WARN_UNUSED_RESULT; | 238 double* result) WARN_UNUSED_RESULT; |
230 bool ExecuteScriptAndExtractInt(const ToRenderFrameHost& adapter, | 239 bool ExecuteScriptAndExtractInt(const ToRenderFrameHost& adapter, |
231 const std::string& script, | 240 const std::string& script, |
232 int* result) WARN_UNUSED_RESULT; | 241 int* result) WARN_UNUSED_RESULT; |
233 bool ExecuteScriptAndExtractBool(const ToRenderFrameHost& adapter, | 242 bool ExecuteScriptAndExtractBool(const ToRenderFrameHost& adapter, |
234 const std::string& script, | 243 const std::string& script, |
235 bool* result) WARN_UNUSED_RESULT; | 244 bool* result) WARN_UNUSED_RESULT; |
236 bool ExecuteScriptAndExtractString(const ToRenderFrameHost& adapter, | 245 bool ExecuteScriptAndExtractString(const ToRenderFrameHost& adapter, |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 const NotificationSource& source, | 523 const NotificationSource& source, |
515 const NotificationDetails& details) override; | 524 const NotificationDetails& details) override; |
516 | 525 |
517 // Overridden WebContentsObserver methods. | 526 // Overridden WebContentsObserver methods. |
518 void RenderProcessGone(base::TerminationStatus status) override; | 527 void RenderProcessGone(base::TerminationStatus status) override; |
519 | 528 |
520 private: | 529 private: |
521 NotificationRegistrar registrar_; | 530 NotificationRegistrar registrar_; |
522 std::queue<std::string> message_queue_; | 531 std::queue<std::string> message_queue_; |
523 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 532 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 533 bool renderer_crashed_ = false; |
524 | 534 |
525 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); | 535 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); |
526 }; | 536 }; |
527 | 537 |
528 // Used to wait for a new WebContents to be created. Instantiate this object | 538 // Used to wait for a new WebContents to be created. Instantiate this object |
529 // before the operation that will create the window. | 539 // before the operation that will create the window. |
530 class WebContentsAddedObserver { | 540 class WebContentsAddedObserver { |
531 public: | 541 public: |
532 WebContentsAddedObserver(); | 542 WebContentsAddedObserver(); |
533 ~WebContentsAddedObserver(); | 543 ~WebContentsAddedObserver(); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 virtual ~MockOverscrollController() {} | 874 virtual ~MockOverscrollController() {} |
865 | 875 |
866 // Waits until the mock receives a consumed GestureScrollUpdate. | 876 // Waits until the mock receives a consumed GestureScrollUpdate. |
867 virtual void WaitForConsumedScroll() = 0; | 877 virtual void WaitForConsumedScroll() = 0; |
868 }; | 878 }; |
869 #endif // defined(USE_AURA) | 879 #endif // defined(USE_AURA) |
870 | 880 |
871 } // namespace content | 881 } // namespace content |
872 | 882 |
873 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 883 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
OLD | NEW |