| 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_TEST_WEB_TEST_H_ | 5 #ifndef IOS_WEB_TEST_WEB_TEST_H_ |
| 6 #define IOS_WEB_TEST_WEB_TEST_H_ | 6 #define IOS_WEB_TEST_WEB_TEST_H_ |
| 7 | 7 |
| 8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
| 9 | 9 |
| 10 #import "base/ios/block_types.h" | 10 #import "base/ios/block_types.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 void WaitForCondition(ConditionBlock condition); | 77 void WaitForCondition(ConditionBlock condition); |
| 78 // Evaluates JavaScript and returns result as a string. | 78 // Evaluates JavaScript and returns result as a string. |
| 79 // DEPRECATED. TODO(crbug.com/595761): Remove this API. | 79 // DEPRECATED. TODO(crbug.com/595761): Remove this API. |
| 80 NSString* EvaluateJavaScriptAsString(NSString* script); | 80 NSString* EvaluateJavaScriptAsString(NSString* script); |
| 81 // Synchronously executes JavaScript and returns result as id. | 81 // Synchronously executes JavaScript and returns result as id. |
| 82 id ExecuteJavaScript(NSString* script); | 82 id ExecuteJavaScript(NSString* script); |
| 83 // TaskObserver methods (used when waiting for background tasks). | 83 // TaskObserver methods (used when waiting for background tasks). |
| 84 void WillProcessTask(const base::PendingTask& pending_task) override; | 84 void WillProcessTask(const base::PendingTask& pending_task) override; |
| 85 void DidProcessTask(const base::PendingTask& pending_task) override; | 85 void DidProcessTask(const base::PendingTask& pending_task) override; |
| 86 | 86 |
| 87 // Returns web state for this web controller. |
| 88 web::WebState* web_state(); |
| 89 |
| 87 // The web controller for testing. | 90 // The web controller for testing. |
| 88 base::WeakNSObject<CRWWebController> webController_; | 91 base::WeakNSObject<CRWWebController> webController_; |
| 89 // true if a task has been processed. | 92 // true if a task has been processed. |
| 90 bool processed_a_task_; | 93 bool processed_a_task_; |
| 91 | 94 |
| 92 private: | 95 private: |
| 93 // LoadURL() for data URLs sometimes lock up navigation, so if the loaded page | 96 // LoadURL() for data URLs sometimes lock up navigation, so if the loaded page |
| 94 // is not the one expected, reset the web view. In some cases, document or | 97 // is not the one expected, reset the web view. In some cases, document or |
| 95 // document.body does not exist either; also reset in those cases. | 98 // document.body does not exist either; also reset in those cases. |
| 96 // Returns true if a reset occurred. One may want to load the page again. | 99 // Returns true if a reset occurred. One may want to load the page again. |
| 97 bool ResetPageIfNavigationStalled(NSString* load_check); | 100 bool ResetPageIfNavigationStalled(NSString* load_check); |
| 98 // Creates a unique HTML element to look for in | 101 // Creates a unique HTML element to look for in |
| 99 // ResetPageIfNavigationStalled(). | 102 // ResetPageIfNavigationStalled(). |
| 100 NSString* CreateLoadCheck(); | 103 NSString* CreateLoadCheck(); |
| 101 // The web state for testing. | 104 // The web state for testing. |
| 102 std::unique_ptr<WebStateImpl> web_state_impl_; | 105 std::unique_ptr<WebStateImpl> web_state_impl_; |
| 103 }; | 106 }; |
| 104 | 107 |
| 105 } // namespace web | 108 } // namespace web |
| 106 | 109 |
| 107 #endif // IOS_WEB_TEST_WEB_TEST_H_ | 110 #endif // IOS_WEB_TEST_WEB_TEST_H_ |
| OLD | NEW |