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 void ExecuteUnmodifiedScript(const ToRenderFrameHost& adapter, |
| 228 const std::string& script); |
| 229 |
| 230 // The following methods execute the passed |script| in the specified frame and |
| 231 // sets |result| to the value passed to "window.domAutomationController.send" by |
| 232 // the executed script. They return true on success, false if the script |
| 233 // execution failed or did not evaluate to the expected type. |
227 bool ExecuteScriptAndExtractDouble(const ToRenderFrameHost& adapter, | 234 bool ExecuteScriptAndExtractDouble(const ToRenderFrameHost& adapter, |
228 const std::string& script, | 235 const std::string& script, |
229 double* result) WARN_UNUSED_RESULT; | 236 double* result) WARN_UNUSED_RESULT; |
230 bool ExecuteScriptAndExtractInt(const ToRenderFrameHost& adapter, | 237 bool ExecuteScriptAndExtractInt(const ToRenderFrameHost& adapter, |
231 const std::string& script, | 238 const std::string& script, |
232 int* result) WARN_UNUSED_RESULT; | 239 int* result) WARN_UNUSED_RESULT; |
233 bool ExecuteScriptAndExtractBool(const ToRenderFrameHost& adapter, | 240 bool ExecuteScriptAndExtractBool(const ToRenderFrameHost& adapter, |
234 const std::string& script, | 241 const std::string& script, |
235 bool* result) WARN_UNUSED_RESULT; | 242 bool* result) WARN_UNUSED_RESULT; |
236 bool ExecuteScriptAndExtractString(const ToRenderFrameHost& adapter, | 243 bool ExecuteScriptAndExtractString(const ToRenderFrameHost& adapter, |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 const NotificationSource& source, | 521 const NotificationSource& source, |
515 const NotificationDetails& details) override; | 522 const NotificationDetails& details) override; |
516 | 523 |
517 // Overridden WebContentsObserver methods. | 524 // Overridden WebContentsObserver methods. |
518 void RenderProcessGone(base::TerminationStatus status) override; | 525 void RenderProcessGone(base::TerminationStatus status) override; |
519 | 526 |
520 private: | 527 private: |
521 NotificationRegistrar registrar_; | 528 NotificationRegistrar registrar_; |
522 std::queue<std::string> message_queue_; | 529 std::queue<std::string> message_queue_; |
523 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 530 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 531 bool renderer_crashed_ = false; |
524 | 532 |
525 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); | 533 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); |
526 }; | 534 }; |
527 | 535 |
528 // Used to wait for a new WebContents to be created. Instantiate this object | 536 // Used to wait for a new WebContents to be created. Instantiate this object |
529 // before the operation that will create the window. | 537 // before the operation that will create the window. |
530 class WebContentsAddedObserver { | 538 class WebContentsAddedObserver { |
531 public: | 539 public: |
532 WebContentsAddedObserver(); | 540 WebContentsAddedObserver(); |
533 ~WebContentsAddedObserver(); | 541 ~WebContentsAddedObserver(); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 virtual ~MockOverscrollController() {} | 872 virtual ~MockOverscrollController() {} |
865 | 873 |
866 // Waits until the mock receives a consumed GestureScrollUpdate. | 874 // Waits until the mock receives a consumed GestureScrollUpdate. |
867 virtual void WaitForConsumedScroll() = 0; | 875 virtual void WaitForConsumedScroll() = 0; |
868 }; | 876 }; |
869 #endif // defined(USE_AURA) | 877 #endif // defined(USE_AURA) |
870 | 878 |
871 } // namespace content | 879 } // namespace content |
872 | 880 |
873 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 881 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
OLD | NEW |