OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import <UIKit/UIKit.h> | 5 #import <UIKit/UIKit.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/ios/block_types.h" | 9 #include "base/ios/block_types.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 | 11 |
12 #import "ios/web/public/web_state/web_state.h" | 12 #import "ios/web/public/web_state/web_state.h" |
13 | 13 |
14 namespace web { | 14 namespace web { |
15 namespace test { | 15 namespace test { |
16 | 16 |
17 // Synchronously returns the result of executed JavaScript. | 17 // Synchronously returns the result of executed JavaScript, returning nullptr |
| 18 // if the JavaScript does not complete. |
18 std::unique_ptr<base::Value> ExecuteJavaScript(web::WebState* web_state, | 19 std::unique_ptr<base::Value> ExecuteJavaScript(web::WebState* web_state, |
19 const std::string& script); | 20 const std::string& script); |
20 | 21 |
21 // Returns the CGRect, in the coordinate system of web_state's view, that | 22 // Returns the CGRect, in the coordinate system of web_state's view, that |
22 // encloses the element with |element_id| in |web_state|'s webview. | 23 // encloses the element with |element_id| in |web_state|'s webview. |
23 // There is no guarantee that the CGRect returned is inside the current window; | 24 // There is no guarantee that the CGRect returned is inside the current window; |
24 // callers should check and act accordingly (scrolling the webview, perhaps). | 25 // callers should check and act accordingly (scrolling the webview, perhaps). |
25 // Returns CGRectNull if no element could be found. | 26 // Returns CGRectNull if no element could be found. |
26 CGRect GetBoundingRectOfElementWithId(web::WebState* web_state, | 27 CGRect GetBoundingRectOfElementWithId(web::WebState* web_state, |
27 const std::string& element_id); | 28 const std::string& element_id); |
28 | 29 |
29 // Returns whether the element with |element_id| in the passed |web_state| has | 30 // Returns whether the element with |element_id| in the passed |web_state| has |
30 // been tapped using a JavaScript click() event. | 31 // been tapped using a JavaScript click() event. |
31 bool TapWebViewElementWithId(web::WebState* web_state, | 32 bool TapWebViewElementWithId(web::WebState* web_state, |
32 const std::string& element_id); | 33 const std::string& element_id); |
33 | 34 |
34 // Returns whether the element with |element_id| in the passed |web_state| has | 35 // Returns whether the element with |element_id| in the passed |web_state| has |
35 // been focused using a JavaScript focus() event. | 36 // been focused using a JavaScript focus() event. |
36 bool FocusWebViewElementWithId(web::WebState* web_state, | 37 bool FocusWebViewElementWithId(web::WebState* web_state, |
37 const std::string& element_id); | 38 const std::string& element_id); |
38 | 39 |
39 // Returns whether the form with |form_id| in the passed |web_state| has been | 40 // Returns whether the form with |form_id| in the passed |web_state| has been |
40 // submitted using a JavaScript submit() event. | 41 // submitted using a JavaScript submit() event. |
41 bool SubmitWebViewFormWithId(web::WebState* web_state, | 42 bool SubmitWebViewFormWithId(web::WebState* web_state, |
42 const std::string& form_id); | 43 const std::string& form_id); |
43 } // namespace test | 44 } // namespace test |
44 } // namespace web | 45 } // namespace web |
OLD | NEW |