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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 RenderFrameHost* render_frame_host_; | 202 RenderFrameHost* render_frame_host_; |
203 }; | 203 }; |
204 | 204 |
205 RenderFrameHost* ConvertToRenderFrameHost(RenderViewHost* render_view_host); | 205 RenderFrameHost* ConvertToRenderFrameHost(RenderViewHost* render_view_host); |
206 RenderFrameHost* ConvertToRenderFrameHost(RenderFrameHost* render_view_host); | 206 RenderFrameHost* ConvertToRenderFrameHost(RenderFrameHost* render_view_host); |
207 RenderFrameHost* ConvertToRenderFrameHost(WebContents* web_contents); | 207 RenderFrameHost* ConvertToRenderFrameHost(WebContents* web_contents); |
208 | 208 |
209 // Executes the passed |script| in the specified frame with the user gesture. | 209 // Executes the passed |script| in the specified frame with the user gesture. |
210 // The |script| should not invoke domAutomationController.send(); otherwise, | 210 // The |script| should not invoke domAutomationController.send(); otherwise, |
211 // your test will hang or be flaky. If you want to extract a result, use one of | 211 // your test will hang or be flaky. If you want to extract a result, use one of |
212 // the below functions. Returns true on success. | 212 // the below functions. Returns true on success. |
mmenke
2017/07/06 16:10:34
While you're here, mind documenting what "success"
Łukasz Anforowicz
2017/07/06 16:46:56
Done.
| |
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). |
mmenke
2017/07/06 16:10:34
I guess ExecuteScript waits for completion? That
Łukasz Anforowicz
2017/07/06 16:46:56
Done.
| |
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, | |
mmenke
2017/07/06 16:10:34
ExecuteUnmodifiedScript? Does ExecuteScript modif
Łukasz Anforowicz
2017/07/06 16:46:56
Done.
| |
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 |