OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 IOS_WEB_PUBLIC_TEST_JS_TEST_UTIL_H_ | 5 #ifndef IOS_WEB_PUBLIC_TEST_JS_TEST_UTIL_H_ |
6 #define IOS_WEB_PUBLIC_TEST_JS_TEST_UTIL_H_ | 6 #define IOS_WEB_PUBLIC_TEST_JS_TEST_UTIL_H_ |
7 | 7 |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 #import <WebKit/WebKit.h> | 9 #import <WebKit/WebKit.h> |
10 | 10 |
11 @class CRWJSInjectionManager; | 11 @class CRWJSInjectionManager; |
12 @class CRWJSInjectionReceiver; | 12 @class CRWJSInjectionReceiver; |
13 | 13 |
14 namespace web { | 14 namespace web { |
15 | 15 |
16 // These functions synchronously execute JavaScript and return result as id. | 16 // These functions synchronously execute JavaScript and return result as id. |
17 // id will be backed up by different classes depending on resulting JS type: | 17 // id will be backed up by different classes depending on resulting JS type: |
18 // NSString (string), NSNumber (number or boolean), NSDictionary (object), | 18 // NSString (string), NSNumber (number or boolean), NSDictionary (object), |
19 // NSArray (array), NSNull (null), NSDate (Date), nil (undefined or execution | 19 // NSArray (array), NSNull (null), NSDate (Date), nil (undefined or execution |
20 // exception). | 20 // exception). |
21 | 21 |
22 // Executes JavaScript on the |manager| and returns the result as an id. | 22 // Executes JavaScript on the |manager| and returns the result as an id. |
23 id ExecuteJavaScript(CRWJSInjectionManager* manager, NSString* script); | 23 id ExecuteJavaScript(CRWJSInjectionManager* manager, NSString* script); |
24 | 24 |
25 // Executes JavaScript on the |receiver| and returns the result as an id. | 25 // Executes JavaScript on the |receiver| and returns the result as an id. |
26 id ExecuteJavaScript(CRWJSInjectionReceiver* receiver, NSString* script); | 26 id ExecuteJavaScript(CRWJSInjectionReceiver* receiver, NSString* script); |
27 | 27 |
28 // Executes JavaScript on |web_view| and returns the result as an id. | 28 // Executes JavaScript on |web_view| and returns the result as an id. |
| 29 // |error| can be null and will be updated only if script execution fails. |
| 30 id ExecuteJavaScript(WKWebView* web_view, NSString* script, NSError** error); |
| 31 |
| 32 // Executes JavaScript on |web_view| and returns the result as an id. |
| 33 // Fails if there was an error during script execution. |
29 id ExecuteJavaScript(WKWebView* web_view, NSString* script); | 34 id ExecuteJavaScript(WKWebView* web_view, NSString* script); |
30 | 35 |
31 } // namespace web | 36 } // namespace web |
32 | 37 |
33 #endif // IOS_WEB_PUBLIC_TEST_JS_TEST_UTIL_H_ | 38 #endif // IOS_WEB_PUBLIC_TEST_JS_TEST_UTIL_H_ |
OLD | NEW |