| 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 #ifndef IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_ | 5 #ifndef IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_ |
| 6 #define IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_ | 6 #define IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_ |
| 7 | 7 |
| 8 #include "base/ios/block_types.h" | 8 #include "base/ios/block_types.h" |
| 9 #import "base/ios/weak_nsobject.h" | 9 #import "base/ios/weak_nsobject.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // Evaluates JavaScript and returns result as a string. | 50 // Evaluates JavaScript and returns result as a string. |
| 51 // DEPRECATED. TODO(crbug.com/595761): Remove this API. | 51 // DEPRECATED. TODO(crbug.com/595761): Remove this API. |
| 52 NSString* EvaluateJavaScriptAsString(NSString* script); | 52 NSString* EvaluateJavaScriptAsString(NSString* script); |
| 53 // Synchronously executes JavaScript and returns result as id. | 53 // Synchronously executes JavaScript and returns result as id. |
| 54 id ExecuteJavaScript(NSString* script); | 54 id ExecuteJavaScript(NSString* script); |
| 55 | 55 |
| 56 // Returns web state for this web controller. | 56 // Returns web state for this web controller. |
| 57 web::WebState* web_state(); | 57 web::WebState* web_state(); |
| 58 const web::WebState* web_state() const; | 58 const web::WebState* web_state() const; |
| 59 | 59 |
| 60 // The web controller for testing. | |
| 61 // TODO(crbug.com/619076): Remove this ivar. | |
| 62 base::WeakNSObject<CRWWebController> webController_; | |
| 63 // true if a task has been processed. | 60 // true if a task has been processed. |
| 64 bool processed_a_task_; | 61 bool processed_a_task_; |
| 65 | 62 |
| 66 private: | 63 private: |
| 67 // LoadURL() for data URLs sometimes lock up navigation, so if the loaded page | 64 // LoadURL() for data URLs sometimes lock up navigation, so if the loaded page |
| 68 // is not the one expected, reset the web view. In some cases, document or | 65 // is not the one expected, reset the web view. In some cases, document or |
| 69 // document.body does not exist either; also reset in those cases. | 66 // document.body does not exist either; also reset in those cases. |
| 70 // Returns true if a reset occurred. One may want to load the page again. | 67 // Returns true if a reset occurred. One may want to load the page again. |
| 71 bool ResetPageIfNavigationStalled(NSString* load_check); | 68 bool ResetPageIfNavigationStalled(NSString* load_check); |
| 72 // Creates a unique HTML element to look for in | 69 // Creates a unique HTML element to look for in |
| 73 // ResetPageIfNavigationStalled(). | 70 // ResetPageIfNavigationStalled(). |
| 74 NSString* CreateLoadCheck(); | 71 NSString* CreateLoadCheck(); |
| 75 // The web state for testing. | 72 // The web state for testing. |
| 76 std::unique_ptr<WebState> web_state_; | 73 std::unique_ptr<WebState> web_state_; |
| 74 // The web controller for testing. |
| 75 // TODO(crbug.com/619076): Remove this ivar. |
| 76 base::WeakNSObject<CRWWebController> webController_; |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 } // namespace web | 79 } // namespace web |
| 80 | 80 |
| 81 #endif // IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_ | 81 #endif // IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_ |
| OLD | NEW |