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 "ios/web/public/test/web_test_with_web_state.h" | 5 #import "ios/web/public/test/web_test_with_web_state.h" |
6 | 6 |
7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
8 #include "base/test/ios/wait_util.h" | 8 #include "base/test/ios/wait_util.h" |
9 #import "ios/web/public/web_state/url_verification_constants.h" | 9 #import "ios/web/public/web_state/url_verification_constants.h" |
10 #include "ios/web/public/web_state/web_state_observer.h" | 10 #include "ios/web/public/web_state/web_state_observer.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 CRWWebController* web_controller = GetWebController(web_state()); | 64 CRWWebController* web_controller = GetWebController(web_state()); |
65 ASSERT_EQ(PAGE_LOADED, web_controller.loadPhase); | 65 ASSERT_EQ(PAGE_LOADED, web_controller.loadPhase); |
66 [web_controller loadHTML:html forURL:url]; | 66 [web_controller loadHTML:html forURL:url]; |
67 ASSERT_EQ(LOAD_REQUESTED, web_controller.loadPhase); | 67 ASSERT_EQ(LOAD_REQUESTED, web_controller.loadPhase); |
68 | 68 |
69 // Wait until the page is loaded. | 69 // Wait until the page is loaded. |
70 base::test::ios::WaitUntilCondition(^{ | 70 base::test::ios::WaitUntilCondition(^{ |
71 return web_controller.loadPhase == PAGE_LOADED; | 71 return web_controller.loadPhase == PAGE_LOADED; |
72 }); | 72 }); |
73 | 73 |
74 // Wait until scripts execution becomes possible. | 74 // Reload the page if script execution is not possible. |
75 base::test::ios::WaitUntilCondition(^bool { | 75 if (![ExecuteJavaScript(@"0;") isEqual:@0]) { |
76 return [ExecuteJavaScript(@"0;") isEqual:@0]; | 76 LoadHtml(html, url); |
77 }); | 77 } |
78 } | 78 } |
79 | 79 |
80 void WebTestWithWebState::LoadHtml(NSString* html) { | 80 void WebTestWithWebState::LoadHtml(NSString* html) { |
81 GURL url("https://chromium.test/"); | 81 GURL url("https://chromium.test/"); |
82 LoadHtml(html, url); | 82 LoadHtml(html, url); |
83 } | 83 } |
84 | 84 |
85 void WebTestWithWebState::LoadHtml(const std::string& html) { | 85 void WebTestWithWebState::LoadHtml(const std::string& html) { |
86 LoadHtml(base::SysUTF8ToNSString(html)); | 86 LoadHtml(base::SysUTF8ToNSString(html)); |
87 } | 87 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 void WebTestWithWebState::WillProcessTask(const base::PendingTask&) { | 149 void WebTestWithWebState::WillProcessTask(const base::PendingTask&) { |
150 // Nothing to do. | 150 // Nothing to do. |
151 } | 151 } |
152 | 152 |
153 void WebTestWithWebState::DidProcessTask(const base::PendingTask&) { | 153 void WebTestWithWebState::DidProcessTask(const base::PendingTask&) { |
154 processed_a_task_ = true; | 154 processed_a_task_ = true; |
155 } | 155 } |
156 | 156 |
157 } // namespace web | 157 } // namespace web |
OLD | NEW |