Chromium Code Reviews| 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. | 29 // |error| can be null and will be updated only if script execution fails. |
| 30 id ExecuteJavaScript(WKWebView* web_view, NSString* script, NSError** error); | 30 // TODO(crbug.com/730062): Remove __unsafe_unretained when all callers are |
| 31 // are converted to ARC. | |
|
baxley
2017/06/06 17:16:48
Here's an example where this was done in another f
| |
| 32 id ExecuteJavaScript(WKWebView* web_view, | |
| 33 NSString* script, | |
| 34 NSError* __unsafe_unretained* error); | |
| 31 | 35 |
| 32 // Executes JavaScript on |web_view| and returns the result as an id. | 36 // Executes JavaScript on |web_view| and returns the result as an id. |
| 33 // Fails if there was an error during script execution. | 37 // Fails if there was an error during script execution. |
| 34 id ExecuteJavaScript(WKWebView* web_view, NSString* script); | 38 id ExecuteJavaScript(WKWebView* web_view, NSString* script); |
| 35 | 39 |
| 36 } // namespace web | 40 } // namespace web |
| 37 | 41 |
| 38 #endif // IOS_WEB_PUBLIC_TEST_JS_TEST_UTIL_H_ | 42 #endif // IOS_WEB_PUBLIC_TEST_JS_TEST_UTIL_H_ |
| OLD | NEW |