Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: ios/web/web_state/navigation_callbacks_inttest.mm

Issue 2912993002: Call WebStateObserver::DidStopLoading for native content reloads. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ios/web/web_state/ui/crw_web_controller.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #include <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 7
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/strings/stringprintf.h"
9 #import "ios/web/public/navigation_item.h" 10 #import "ios/web/public/navigation_item.h"
10 #import "ios/web/public/navigation_manager.h" 11 #import "ios/web/public/navigation_manager.h"
11 #import "ios/web/public/test/http_server.h" 12 #import "ios/web/public/test/http_server.h"
12 #include "ios/web/public/test/http_server_util.h" 13 #include "ios/web/public/test/http_server_util.h"
13 #import "ios/web/public/web_state/navigation_context.h" 14 #import "ios/web/public/web_state/navigation_context.h"
14 #include "ios/web/public/web_state/web_state_observer.h" 15 #include "ios/web/public/web_state/web_state_observer.h"
15 #include "ios/web/test/test_url_constants.h" 16 #include "ios/web/test/test_url_constants.h"
16 #import "ios/web/test/web_int_test.h" 17 #import "ios/web/test/web_int_test.h"
17 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 12 matching lines...) Expand all
31 // pointer. 32 // pointer.
32 ACTION_P3(VerifyNewPageStartedContext, web_state, url, context) { 33 ACTION_P3(VerifyNewPageStartedContext, web_state, url, context) {
33 *context = arg0; 34 *context = arg0;
34 ASSERT_TRUE(*context); 35 ASSERT_TRUE(*context);
35 EXPECT_EQ(web_state, (*context)->GetWebState()); 36 EXPECT_EQ(web_state, (*context)->GetWebState());
36 EXPECT_EQ(url, (*context)->GetUrl()); 37 EXPECT_EQ(url, (*context)->GetUrl());
37 EXPECT_TRUE( 38 EXPECT_TRUE(
38 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED, 39 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED,
39 (*context)->GetPageTransition())); 40 (*context)->GetPageTransition()));
40 EXPECT_FALSE((*context)->IsSameDocument()); 41 EXPECT_FALSE((*context)->IsSameDocument());
42 EXPECT_FALSE((*context)->IsPost());
41 EXPECT_FALSE((*context)->GetError()); 43 EXPECT_FALSE((*context)->GetError());
42 ASSERT_FALSE((*context)->GetResponseHeaders()); 44 ASSERT_FALSE((*context)->GetResponseHeaders());
45 ASSERT_TRUE(web_state->IsLoading());
43 NavigationManager* navigation_manager = web_state->GetNavigationManager(); 46 NavigationManager* navigation_manager = web_state->GetNavigationManager();
44 NavigationItem* item = navigation_manager->GetPendingItem(); 47 NavigationItem* item = navigation_manager->GetPendingItem();
45 EXPECT_EQ(url, item->GetURL()); 48 EXPECT_EQ(url, item->GetURL());
46 } 49 }
47 50
48 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation 51 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation
49 // passed to |DidFinishNavigation|. Asserts that |NavigationContext| the same as 52 // passed to |DidFinishNavigation|. Asserts that |NavigationContext| the same as
50 // |context|. 53 // |context|.
51 ACTION_P3(VerifyNewPageFinishedContext, web_state, url, context) { 54 ACTION_P3(VerifyNewPageFinishedContext, web_state, url, context) {
52 ASSERT_EQ(*context, arg0); 55 ASSERT_EQ(*context, arg0);
53 EXPECT_EQ(web_state, (*context)->GetWebState()); 56 EXPECT_EQ(web_state, (*context)->GetWebState());
54 ASSERT_TRUE((*context)); 57 ASSERT_TRUE((*context));
55 EXPECT_EQ(web_state, (*context)->GetWebState()); 58 EXPECT_EQ(web_state, (*context)->GetWebState());
56 EXPECT_EQ(url, (*context)->GetUrl()); 59 EXPECT_EQ(url, (*context)->GetUrl());
57 EXPECT_TRUE( 60 EXPECT_TRUE(
58 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED, 61 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED,
59 (*context)->GetPageTransition())); 62 (*context)->GetPageTransition()));
60 EXPECT_FALSE((*context)->IsSameDocument()); 63 EXPECT_FALSE((*context)->IsSameDocument());
64 EXPECT_FALSE((*context)->IsPost());
61 EXPECT_FALSE((*context)->GetError()); 65 EXPECT_FALSE((*context)->GetError());
62 ASSERT_TRUE((*context)->GetResponseHeaders()); 66 ASSERT_TRUE((*context)->GetResponseHeaders());
63 std::string mime_type; 67 std::string mime_type;
64 (*context)->GetResponseHeaders()->GetMimeType(&mime_type); 68 (*context)->GetResponseHeaders()->GetMimeType(&mime_type);
69 ASSERT_TRUE(web_state->IsLoading());
65 EXPECT_EQ(kExpectedMimeType, mime_type); 70 EXPECT_EQ(kExpectedMimeType, mime_type);
66 NavigationManager* navigation_manager = web_state->GetNavigationManager(); 71 NavigationManager* navigation_manager = web_state->GetNavigationManager();
67 NavigationItem* item = navigation_manager->GetLastCommittedItem(); 72 NavigationItem* item = navigation_manager->GetLastCommittedItem();
68 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0); 73 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0);
69 EXPECT_EQ(url, item->GetURL()); 74 EXPECT_EQ(url, item->GetURL());
70 } 75 }
71 76
77 // Verifies correctness of |NavigationContext| (|arg0|) for navigations via POST
78 // HTTP methods passed to |DidStartNavigation|. Stores |NavigationContext| in
79 // |context| pointer.
80 ACTION_P3(VerifyPostStartedContext, web_state, url, context) {
81 *context = arg0;
82 ASSERT_TRUE(*context);
83 EXPECT_EQ(web_state, (*context)->GetWebState());
84 EXPECT_EQ(url, (*context)->GetUrl());
85 EXPECT_FALSE((*context)->IsSameDocument());
86 EXPECT_TRUE((*context)->IsPost());
87 EXPECT_FALSE((*context)->GetError());
88 ASSERT_FALSE((*context)->GetResponseHeaders());
89 ASSERT_TRUE(web_state->IsLoading());
90 // TODO(crbug.com/676129): Reload does not create a pending item. Remove this
91 // workaround once the bug is fixed.
92 if (!ui::PageTransitionTypeIncludingQualifiersIs(
93 ui::PageTransition::PAGE_TRANSITION_RELOAD,
94 (*context)->GetPageTransition())) {
95 NavigationManager* navigation_manager = web_state->GetNavigationManager();
96 NavigationItem* item = navigation_manager->GetPendingItem();
97 EXPECT_EQ(url, item->GetURL());
98 }
99 }
100
101 // Verifies correctness of |NavigationContext| (|arg0|) for navigations via POST
102 // HTTP methods passed to |DidFinishNavigation|. Stores |NavigationContext| in
103 // |context| pointer.
104 ACTION_P3(VerifyPostFinishedContext, web_state, url, context) {
105 ASSERT_EQ(*context, arg0);
106 EXPECT_EQ(web_state, (*context)->GetWebState());
107 ASSERT_TRUE((*context));
108 EXPECT_EQ(web_state, (*context)->GetWebState());
109 EXPECT_EQ(url, (*context)->GetUrl());
110 EXPECT_FALSE((*context)->IsSameDocument());
111 EXPECT_TRUE((*context)->IsPost());
112 EXPECT_FALSE((*context)->GetError());
113 ASSERT_TRUE(web_state->IsLoading());
114 NavigationManager* navigation_manager = web_state->GetNavigationManager();
115 NavigationItem* item = navigation_manager->GetLastCommittedItem();
116 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0);
117 EXPECT_EQ(url, item->GetURL());
118 }
119
72 // Verifies correctness of |NavigationContext| (|arg0|) for same page navigation 120 // Verifies correctness of |NavigationContext| (|arg0|) for same page navigation
73 // passed to |DidFinishNavigation|. Stores |NavigationContext| in |context| 121 // passed to |DidFinishNavigation|. Stores |NavigationContext| in |context|
74 // pointer. 122 // pointer.
75 ACTION_P4(VerifySameDocumentStartedContext, 123 ACTION_P4(VerifySameDocumentStartedContext,
76 web_state, 124 web_state,
77 url, 125 url,
78 context, 126 context,
79 page_transition) { 127 page_transition) {
80 *context = arg0; 128 *context = arg0;
81 ASSERT_TRUE(*context); 129 ASSERT_TRUE(*context);
82 EXPECT_EQ(web_state, (*context)->GetWebState()); 130 EXPECT_EQ(web_state, (*context)->GetWebState());
83 EXPECT_EQ(url, (*context)->GetUrl()); 131 EXPECT_EQ(url, (*context)->GetUrl());
84 EXPECT_TRUE(PageTransitionTypeIncludingQualifiersIs( 132 EXPECT_TRUE(PageTransitionTypeIncludingQualifiersIs(
85 page_transition, (*context)->GetPageTransition())); 133 page_transition, (*context)->GetPageTransition()));
86 EXPECT_FALSE((*context)->IsSameDocument()); 134 EXPECT_FALSE((*context)->IsSameDocument());
135 EXPECT_FALSE((*context)->IsPost());
87 EXPECT_FALSE((*context)->GetError()); 136 EXPECT_FALSE((*context)->GetError());
88 EXPECT_FALSE((*context)->GetResponseHeaders()); 137 EXPECT_FALSE((*context)->GetResponseHeaders());
89 } 138 }
90 139
91 // Verifies correctness of |NavigationContext| (|arg0|) for same page navigation 140 // Verifies correctness of |NavigationContext| (|arg0|) for same page navigation
92 // passed to |DidFinishNavigation|. Asserts that |NavigationContext| the same as 141 // passed to |DidFinishNavigation|. Asserts that |NavigationContext| the same as
93 // |context|. 142 // |context|.
94 ACTION_P4(VerifySameDocumentFinishedContext, 143 ACTION_P4(VerifySameDocumentFinishedContext,
95 web_state, 144 web_state,
96 url, 145 url,
97 context, 146 context,
98 page_transition) { 147 page_transition) {
99 ASSERT_EQ(*context, arg0); 148 ASSERT_EQ(*context, arg0);
100 ASSERT_TRUE(*context); 149 ASSERT_TRUE(*context);
101 EXPECT_EQ(web_state, (*context)->GetWebState()); 150 EXPECT_EQ(web_state, (*context)->GetWebState());
102 EXPECT_EQ(url, (*context)->GetUrl()); 151 EXPECT_EQ(url, (*context)->GetUrl());
103 EXPECT_TRUE(PageTransitionTypeIncludingQualifiersIs( 152 EXPECT_TRUE(PageTransitionTypeIncludingQualifiersIs(
104 page_transition, (*context)->GetPageTransition())); 153 page_transition, (*context)->GetPageTransition()));
105 EXPECT_TRUE((*context)->IsSameDocument()); 154 EXPECT_TRUE((*context)->IsSameDocument());
155 EXPECT_FALSE((*context)->IsPost());
106 EXPECT_FALSE((*context)->GetError()); 156 EXPECT_FALSE((*context)->GetError());
107 EXPECT_FALSE((*context)->GetResponseHeaders()); 157 EXPECT_FALSE((*context)->GetResponseHeaders());
108 NavigationManager* navigation_manager = web_state->GetNavigationManager(); 158 NavigationManager* navigation_manager = web_state->GetNavigationManager();
109 NavigationItem* item = navigation_manager->GetLastCommittedItem(); 159 NavigationItem* item = navigation_manager->GetLastCommittedItem();
110 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0); 160 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0);
111 EXPECT_EQ(url, item->GetURL()); 161 EXPECT_EQ(url, item->GetURL());
112 } 162 }
113 163
114 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation 164 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation
115 // to native URLs passed to |DidStartNavigation|. Stores |NavigationContext| in 165 // to native URLs passed to |DidStartNavigation|. Stores |NavigationContext| in
116 // |context| pointer. 166 // |context| pointer.
117 ACTION_P3(VerifyNewNativePageStartedContext, web_state, url, context) { 167 ACTION_P3(VerifyNewNativePageStartedContext, web_state, url, context) {
118 *context = arg0; 168 *context = arg0;
119 ASSERT_TRUE(*context); 169 ASSERT_TRUE(*context);
120 EXPECT_EQ(web_state, (*context)->GetWebState()); 170 EXPECT_EQ(web_state, (*context)->GetWebState());
121 EXPECT_EQ(url, (*context)->GetUrl()); 171 EXPECT_EQ(url, (*context)->GetUrl());
122 EXPECT_TRUE( 172 EXPECT_TRUE(
123 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED, 173 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED,
124 (*context)->GetPageTransition())); 174 (*context)->GetPageTransition()));
125 EXPECT_FALSE((*context)->IsSameDocument()); 175 EXPECT_FALSE((*context)->IsSameDocument());
176 EXPECT_FALSE((*context)->IsPost());
126 EXPECT_FALSE((*context)->GetError()); 177 EXPECT_FALSE((*context)->GetError());
127 EXPECT_FALSE((*context)->GetResponseHeaders()); 178 EXPECT_FALSE((*context)->GetResponseHeaders());
179 ASSERT_TRUE(web_state->IsLoading());
128 NavigationManager* navigation_manager = web_state->GetNavigationManager(); 180 NavigationManager* navigation_manager = web_state->GetNavigationManager();
129 NavigationItem* item = navigation_manager->GetPendingItem(); 181 NavigationItem* item = navigation_manager->GetPendingItem();
130 EXPECT_EQ(url, item->GetURL()); 182 EXPECT_EQ(url, item->GetURL());
131 } 183 }
132 184
133 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation 185 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation
134 // to native URLs passed to |DidFinishNavigation|. Asserts that 186 // to native URLs passed to |DidFinishNavigation|. Asserts that
135 // |NavigationContext| the same as |context|. 187 // |NavigationContext| the same as |context|.
136 ACTION_P3(VerifyNewNativePageFinishedContext, web_state, url, context) { 188 ACTION_P3(VerifyNewNativePageFinishedContext, web_state, url, context) {
137 ASSERT_EQ(*context, arg0); 189 ASSERT_EQ(*context, arg0);
138 ASSERT_TRUE(*context); 190 ASSERT_TRUE(*context);
139 EXPECT_EQ(web_state, (*context)->GetWebState()); 191 EXPECT_EQ(web_state, (*context)->GetWebState());
140 EXPECT_EQ(url, (*context)->GetUrl()); 192 EXPECT_EQ(url, (*context)->GetUrl());
141 EXPECT_TRUE( 193 EXPECT_TRUE(
142 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED, 194 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED,
143 (*context)->GetPageTransition())); 195 (*context)->GetPageTransition()));
144 EXPECT_FALSE((*context)->IsSameDocument()); 196 EXPECT_FALSE((*context)->IsSameDocument());
197 EXPECT_FALSE((*context)->IsPost());
145 EXPECT_FALSE((*context)->GetError()); 198 EXPECT_FALSE((*context)->GetError());
146 EXPECT_FALSE((*context)->GetResponseHeaders()); 199 EXPECT_FALSE((*context)->GetResponseHeaders());
147 NavigationManager* navigation_manager = web_state->GetNavigationManager(); 200 NavigationManager* navigation_manager = web_state->GetNavigationManager();
148 NavigationItem* item = navigation_manager->GetLastCommittedItem(); 201 NavigationItem* item = navigation_manager->GetLastCommittedItem();
149 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0); 202 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0);
150 EXPECT_EQ(url, item->GetURL()); 203 EXPECT_EQ(url, item->GetURL());
151 } 204 }
152 205
153 // Verifies correctness of |NavigationContext| (|arg0|) for reload navigation 206 // Verifies correctness of |NavigationContext| (|arg0|) for reload navigation
154 // passed to |DidStartNavigation|. Stores |NavigationContext| in |context| 207 // passed to |DidStartNavigation|. Stores |NavigationContext| in |context|
(...skipping 10 matching lines...) Expand all
165 EXPECT_FALSE((*context)->GetError()); 218 EXPECT_FALSE((*context)->GetError());
166 EXPECT_FALSE((*context)->GetResponseHeaders()); 219 EXPECT_FALSE((*context)->GetResponseHeaders());
167 // TODO(crbug.com/676129): Reload does not create a pending item. Check 220 // TODO(crbug.com/676129): Reload does not create a pending item. Check
168 // pending item once the bug is fixed. 221 // pending item once the bug is fixed.
169 EXPECT_FALSE(web_state->GetNavigationManager()->GetPendingItem()); 222 EXPECT_FALSE(web_state->GetNavigationManager()->GetPendingItem());
170 } 223 }
171 224
172 // Verifies correctness of |NavigationContext| (|arg0|) for reload navigation 225 // Verifies correctness of |NavigationContext| (|arg0|) for reload navigation
173 // passed to |DidFinishNavigation|. Asserts that |NavigationContext| the same as 226 // passed to |DidFinishNavigation|. Asserts that |NavigationContext| the same as
174 // |context|. 227 // |context|.
175 ACTION_P3(VerifyReloadFinishedContext, web_state, url, context) { 228 ACTION_P4(VerifyReloadFinishedContext, web_state, url, context, is_web_page) {
176 ASSERT_EQ(*context, arg0); 229 ASSERT_EQ(*context, arg0);
177 ASSERT_TRUE(*context); 230 ASSERT_TRUE(*context);
178 EXPECT_EQ(web_state, (*context)->GetWebState()); 231 EXPECT_EQ(web_state, (*context)->GetWebState());
179 EXPECT_EQ(url, (*context)->GetUrl()); 232 EXPECT_EQ(url, (*context)->GetUrl());
180 EXPECT_TRUE( 233 EXPECT_TRUE(
181 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_RELOAD, 234 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_RELOAD,
182 (*context)->GetPageTransition())); 235 (*context)->GetPageTransition()));
183 EXPECT_FALSE((*context)->IsSameDocument()); 236 EXPECT_FALSE((*context)->IsSameDocument());
184 EXPECT_FALSE((*context)->GetError()); 237 EXPECT_FALSE((*context)->GetError());
185 EXPECT_FALSE((*context)->GetResponseHeaders()); 238 if (is_web_page) {
239 ASSERT_TRUE((*context)->GetResponseHeaders());
240 std::string mime_type;
241 (*context)->GetResponseHeaders()->GetMimeType(&mime_type);
242 EXPECT_EQ(kExpectedMimeType, mime_type);
243 } else {
244 EXPECT_FALSE((*context)->GetResponseHeaders());
245 }
186 NavigationManager* navigation_manager = web_state->GetNavigationManager(); 246 NavigationManager* navigation_manager = web_state->GetNavigationManager();
187 NavigationItem* item = navigation_manager->GetLastCommittedItem(); 247 NavigationItem* item = navigation_manager->GetLastCommittedItem();
188 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0); 248 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0);
189 EXPECT_EQ(url, item->GetURL()); 249 EXPECT_EQ(url, item->GetURL());
190 } 250 }
191 251
192 // Mocks DidFinishNavigation navigation callback. 252 // Mocks DidFinishNavigation navigation callback.
193 class WebStateObserverMock : public WebStateObserver { 253 class WebStateObserverMock : public WebStateObserver {
194 public: 254 public:
195 WebStateObserverMock(WebState* web_state) : WebStateObserver(web_state) {} 255 WebStateObserverMock(WebState* web_state) : WebStateObserver(web_state) {}
196 MOCK_METHOD1(DidStartNavigation, void(NavigationContext* context)); 256 MOCK_METHOD1(DidStartNavigation, void(NavigationContext* context));
197 MOCK_METHOD1(DidFinishNavigation, void(NavigationContext* context)); 257 MOCK_METHOD1(DidFinishNavigation, void(NavigationContext* context));
258 MOCK_METHOD0(DidStartLoading, void());
259 MOCK_METHOD0(DidStopLoading, void());
198 }; 260 };
199 261
200 } // namespace 262 } // namespace
201 263
202 using test::HttpServer; 264 using test::HttpServer;
265 using testing::StrictMock;
203 using testing::_; 266 using testing::_;
204 267
205 // Test fixture for WebStateDelegate::ProvisionalNavigationStarted and 268 // Test fixture for WebStateDelegate::ProvisionalNavigationStarted,
206 // WebStateDelegate::DidFinishNavigation integration tests. 269 // WebStateDelegate::DidFinishNavigation, WebStateDelegate::DidStartLoading and
207 class StartAndFinishNavigationTest : public WebIntTest { 270 // WebStateDelegate::DidStopLoading integration tests.
271 class NavigationCallbacksTest : public WebIntTest {
208 void SetUp() override { 272 void SetUp() override {
209 WebIntTest::SetUp(); 273 WebIntTest::SetUp();
210 observer_ = base::MakeUnique<WebStateObserverMock>(web_state()); 274 observer_ = base::MakeUnique<StrictMock<WebStateObserverMock>>(web_state());
211 } 275 }
212 276
213 protected: 277 protected:
214 std::unique_ptr<WebStateObserverMock> observer_; 278 std::unique_ptr<StrictMock<WebStateObserverMock>> observer_;
215 }; 279 };
216 280
217 // Tests successful navigation to a new page. 281 // Tests successful navigation to a new page.
218 TEST_F(StartAndFinishNavigationTest, NewPageNavigation) { 282 TEST_F(NavigationCallbacksTest, NewPageNavigation) {
219 const GURL url = HttpServer::MakeUrl("http://chromium.test"); 283 const GURL url = HttpServer::MakeUrl("http://chromium.test");
220 std::map<GURL, std::string> responses; 284 std::map<GURL, std::string> responses;
221 responses[url] = "Chromium Test"; 285 responses[url] = "Chromium Test";
222 web::test::SetUpSimpleHttpServer(responses); 286 web::test::SetUpSimpleHttpServer(responses);
223 287
224 // Perform new page navigation. 288 // Perform new page navigation.
225 NavigationContext* context = nullptr; 289 NavigationContext* context = nullptr;
226 EXPECT_CALL(*observer_, DidStartNavigation(_)) 290 EXPECT_CALL(*observer_, DidStartNavigation(_))
227 .WillOnce(VerifyNewPageStartedContext(web_state(), url, &context)); 291 .WillOnce(VerifyNewPageStartedContext(web_state(), url, &context));
292 EXPECT_CALL(*observer_, DidStartLoading());
228 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 293 EXPECT_CALL(*observer_, DidFinishNavigation(_))
229 .WillOnce(VerifyNewPageFinishedContext(web_state(), url, &context)); 294 .WillOnce(VerifyNewPageFinishedContext(web_state(), url, &context));
295 EXPECT_CALL(*observer_, DidStopLoading());
230 LoadUrl(url); 296 LoadUrl(url);
231 } 297 }
232 298
233 // Tests user-initiated hash change. 299 // Tests web page reload navigation.
234 TEST_F(StartAndFinishNavigationTest, UserInitiatedHashChangeNavigation) { 300 TEST_F(NavigationCallbacksTest, WebPageReloadNavigation) {
235 const GURL url = HttpServer::MakeUrl("http://chromium.test"); 301 const GURL url = HttpServer::MakeUrl("http://chromium.test");
236 std::map<GURL, std::string> responses; 302 std::map<GURL, std::string> responses;
237 responses[url] = "Chromium Test"; 303 responses[url] = "Chromium Test";
304 web::test::SetUpSimpleHttpServer(responses);
305
306 // Perform new page navigation.
307 NavigationContext* context = nullptr;
308 EXPECT_CALL(*observer_, DidStartNavigation(_));
309 EXPECT_CALL(*observer_, DidStartLoading());
310 EXPECT_CALL(*observer_, DidFinishNavigation(_));
311 EXPECT_CALL(*observer_, DidStopLoading());
312 LoadUrl(url);
313
314 // Reload web page.
315 EXPECT_CALL(*observer_, DidStartNavigation(_))
316 .WillOnce(VerifyReloadStartedContext(web_state(), url, &context));
317 EXPECT_CALL(*observer_, DidStartLoading());
318 EXPECT_CALL(*observer_, DidFinishNavigation(_))
319 .WillOnce(VerifyReloadFinishedContext(web_state(), url, &context,
320 true /* is_web_page */));
321 EXPECT_CALL(*observer_, DidStopLoading());
322 // TODO(crbug.com/700958): ios/web ignores |check_for_repost| flag and current
323 // delegate does not run callback for ShowRepostFormWarningDialog. Clearing
324 // the delegate will allow form resubmission. Remove this workaround (clearing
325 // the delegate, once |check_for_repost| is supported).
326 web_state()->SetDelegate(nullptr);
327 ExecuteBlockAndWaitForLoad(url, ^{
328 navigation_manager()->Reload(ReloadType::NORMAL,
329 false /*check_for_repost*/);
330 });
331 }
332
333 // Tests user-initiated hash change.
334 TEST_F(NavigationCallbacksTest, UserInitiatedHashChangeNavigation) {
335 const GURL url = HttpServer::MakeUrl("http://chromium.test");
336 std::map<GURL, std::string> responses;
337 responses[url] = "Chromium Test";
238 web::test::SetUpSimpleHttpServer(responses); 338 web::test::SetUpSimpleHttpServer(responses);
239 339
240 // Perform new page navigation. 340 // Perform new page navigation.
241 NavigationContext* context = nullptr; 341 NavigationContext* context = nullptr;
242 EXPECT_CALL(*observer_, DidStartNavigation(_)) 342 EXPECT_CALL(*observer_, DidStartNavigation(_))
243 .WillOnce(VerifyNewPageStartedContext(web_state(), url, &context)); 343 .WillOnce(VerifyNewPageStartedContext(web_state(), url, &context));
344 EXPECT_CALL(*observer_, DidStartLoading());
244 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 345 EXPECT_CALL(*observer_, DidFinishNavigation(_))
245 .WillOnce(VerifyNewPageFinishedContext(web_state(), url, &context)); 346 .WillOnce(VerifyNewPageFinishedContext(web_state(), url, &context));
347 EXPECT_CALL(*observer_, DidStopLoading());
246 LoadUrl(url); 348 LoadUrl(url);
247 349
248 // Perform same-page navigation. 350 // Perform same-page navigation.
249 const GURL hash_url = HttpServer::MakeUrl("http://chromium.test#1"); 351 const GURL hash_url = HttpServer::MakeUrl("http://chromium.test#1");
250 EXPECT_CALL(*observer_, DidStartNavigation(_)) 352 EXPECT_CALL(*observer_, DidStartNavigation(_))
251 .WillOnce(VerifySameDocumentStartedContext( 353 .WillOnce(VerifySameDocumentStartedContext(
252 web_state(), hash_url, &context, 354 web_state(), hash_url, &context,
253 ui::PageTransition::PAGE_TRANSITION_TYPED)); 355 ui::PageTransition::PAGE_TRANSITION_TYPED));
356 EXPECT_CALL(*observer_, DidStartLoading());
254 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 357 EXPECT_CALL(*observer_, DidFinishNavigation(_))
255 .WillOnce(VerifySameDocumentFinishedContext( 358 .WillOnce(VerifySameDocumentFinishedContext(
256 web_state(), hash_url, &context, 359 web_state(), hash_url, &context,
257 ui::PageTransition::PAGE_TRANSITION_TYPED)); 360 ui::PageTransition::PAGE_TRANSITION_TYPED));
361 EXPECT_CALL(*observer_, DidStopLoading());
258 LoadUrl(hash_url); 362 LoadUrl(hash_url);
259 363
260 // Perform same-page navigation by going back. 364 // Perform same-page navigation by going back.
261 EXPECT_CALL(*observer_, DidStartNavigation(_)) 365 EXPECT_CALL(*observer_, DidStartNavigation(_))
262 .WillOnce(VerifySameDocumentStartedContext( 366 .WillOnce(VerifySameDocumentStartedContext(
263 web_state(), url, &context, 367 web_state(), url, &context,
264 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT)); 368 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT));
369 EXPECT_CALL(*observer_, DidStartLoading());
265 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 370 EXPECT_CALL(*observer_, DidFinishNavigation(_))
266 .WillOnce(VerifySameDocumentFinishedContext( 371 .WillOnce(VerifySameDocumentFinishedContext(
267 web_state(), url, &context, 372 web_state(), url, &context,
268 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT)); 373 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT));
374 EXPECT_CALL(*observer_, DidStopLoading());
269 ExecuteBlockAndWaitForLoad(url, ^{ 375 ExecuteBlockAndWaitForLoad(url, ^{
270 navigation_manager()->GoBack(); 376 navigation_manager()->GoBack();
271 }); 377 });
272 } 378 }
273 379
274 // Tests renderer-initiated hash change. 380 // Tests renderer-initiated hash change.
275 TEST_F(StartAndFinishNavigationTest, RendererInitiatedHashChangeNavigation) { 381 TEST_F(NavigationCallbacksTest, RendererInitiatedHashChangeNavigation) {
276 const GURL url = HttpServer::MakeUrl("http://chromium.test"); 382 const GURL url = HttpServer::MakeUrl("http://chromium.test");
277 std::map<GURL, std::string> responses; 383 std::map<GURL, std::string> responses;
278 responses[url] = "Chromium Test"; 384 responses[url] = "Chromium Test";
279 web::test::SetUpSimpleHttpServer(responses); 385 web::test::SetUpSimpleHttpServer(responses);
280 386
281 // Perform new page navigation. 387 // Perform new page navigation.
282 NavigationContext* context = nullptr; 388 NavigationContext* context = nullptr;
283 EXPECT_CALL(*observer_, DidStartNavigation(_)) 389 EXPECT_CALL(*observer_, DidStartNavigation(_))
284 .WillOnce(VerifyNewPageStartedContext(web_state(), url, &context)); 390 .WillOnce(VerifyNewPageStartedContext(web_state(), url, &context));
391 EXPECT_CALL(*observer_, DidStartLoading());
285 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 392 EXPECT_CALL(*observer_, DidFinishNavigation(_))
286 .WillOnce(VerifyNewPageFinishedContext(web_state(), url, &context)); 393 .WillOnce(VerifyNewPageFinishedContext(web_state(), url, &context));
394 EXPECT_CALL(*observer_, DidStopLoading());
287 LoadUrl(url); 395 LoadUrl(url);
288 396
289 // Perform same-page navigation using JavaScript. 397 // Perform same-page navigation using JavaScript.
290 const GURL hash_url = HttpServer::MakeUrl("http://chromium.test#1"); 398 const GURL hash_url = HttpServer::MakeUrl("http://chromium.test#1");
291 EXPECT_CALL(*observer_, DidStartNavigation(_)) 399 EXPECT_CALL(*observer_, DidStartNavigation(_))
292 .WillOnce(VerifySameDocumentStartedContext( 400 .WillOnce(VerifySameDocumentStartedContext(
293 web_state(), hash_url, &context, 401 web_state(), hash_url, &context,
294 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT)); 402 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT));
403 EXPECT_CALL(*observer_, DidStartLoading());
295 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 404 EXPECT_CALL(*observer_, DidFinishNavigation(_))
296 .WillOnce(VerifySameDocumentFinishedContext( 405 .WillOnce(VerifySameDocumentFinishedContext(
297 web_state(), hash_url, &context, 406 web_state(), hash_url, &context,
298 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT)); 407 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT));
408 EXPECT_CALL(*observer_, DidStopLoading());
299 ExecuteJavaScript(@"window.location.hash = '#1'"); 409 ExecuteJavaScript(@"window.location.hash = '#1'");
300 } 410 }
301 411
302 // Tests state change. 412 // Tests state change.
303 TEST_F(StartAndFinishNavigationTest, StateNavigation) { 413 TEST_F(NavigationCallbacksTest, StateNavigation) {
304 const GURL url = HttpServer::MakeUrl("http://chromium.test"); 414 const GURL url = HttpServer::MakeUrl("http://chromium.test");
305 std::map<GURL, std::string> responses; 415 std::map<GURL, std::string> responses;
306 responses[url] = "Chromium Test"; 416 responses[url] = "Chromium Test";
307 web::test::SetUpSimpleHttpServer(responses); 417 web::test::SetUpSimpleHttpServer(responses);
308 418
309 // Perform new page navigation. 419 // Perform new page navigation.
310 NavigationContext* context = nullptr; 420 NavigationContext* context = nullptr;
311 EXPECT_CALL(*observer_, DidStartNavigation(_)) 421 EXPECT_CALL(*observer_, DidStartNavigation(_))
312 .WillOnce(VerifyNewPageStartedContext(web_state(), url, &context)); 422 .WillOnce(VerifyNewPageStartedContext(web_state(), url, &context));
423 EXPECT_CALL(*observer_, DidStartLoading());
313 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 424 EXPECT_CALL(*observer_, DidFinishNavigation(_))
314 .WillOnce(VerifyNewPageFinishedContext(web_state(), url, &context)); 425 .WillOnce(VerifyNewPageFinishedContext(web_state(), url, &context));
426 EXPECT_CALL(*observer_, DidStopLoading());
315 LoadUrl(url); 427 LoadUrl(url);
316 428
317 // Perform push state using JavaScript. 429 // Perform push state using JavaScript.
318 const GURL push_url = HttpServer::MakeUrl("http://chromium.test/test.html"); 430 const GURL push_url = HttpServer::MakeUrl("http://chromium.test/test.html");
319 EXPECT_CALL(*observer_, DidStartNavigation(_)) 431 EXPECT_CALL(*observer_, DidStartNavigation(_))
320 .WillOnce(VerifySameDocumentStartedContext( 432 .WillOnce(VerifySameDocumentStartedContext(
321 web_state(), push_url, &context, 433 web_state(), push_url, &context,
322 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT)); 434 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT));
323 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 435 EXPECT_CALL(*observer_, DidFinishNavigation(_))
324 .WillOnce(VerifySameDocumentFinishedContext( 436 .WillOnce(VerifySameDocumentFinishedContext(
325 web_state(), push_url, &context, 437 web_state(), push_url, &context,
326 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT)); 438 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT));
327 ExecuteJavaScript(@"window.history.pushState('', 'Test', 'test.html')"); 439 ExecuteJavaScript(@"window.history.pushState('', 'Test', 'test.html')");
328 440
329 // Perform replace state using JavaScript. 441 // Perform replace state using JavaScript.
330 const GURL replace_url = HttpServer::MakeUrl("http://chromium.test/1.html"); 442 const GURL replace_url = HttpServer::MakeUrl("http://chromium.test/1.html");
331 EXPECT_CALL(*observer_, DidStartNavigation(_)) 443 EXPECT_CALL(*observer_, DidStartNavigation(_))
332 .WillOnce(VerifySameDocumentStartedContext( 444 .WillOnce(VerifySameDocumentStartedContext(
333 web_state(), replace_url, &context, 445 web_state(), replace_url, &context,
334 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT)); 446 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT));
335 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 447 EXPECT_CALL(*observer_, DidFinishNavigation(_))
336 .WillOnce(VerifySameDocumentFinishedContext( 448 .WillOnce(VerifySameDocumentFinishedContext(
337 web_state(), replace_url, &context, 449 web_state(), replace_url, &context,
338 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT)); 450 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT));
339 ExecuteJavaScript(@"window.history.replaceState('', 'Test', '1.html')"); 451 ExecuteJavaScript(@"window.history.replaceState('', 'Test', '1.html')");
340 } 452 }
341 453
342 // Tests native content navigation. 454 // Tests native content navigation.
343 TEST_F(StartAndFinishNavigationTest, NativeContentNavigation) { 455 TEST_F(NavigationCallbacksTest, NativeContentNavigation) {
344 GURL url(url::SchemeHostPort(kTestNativeContentScheme, "ui", 0).Serialize()); 456 GURL url(url::SchemeHostPort(kTestNativeContentScheme, "ui", 0).Serialize());
345 NavigationContext* context = nullptr; 457 NavigationContext* context = nullptr;
346 EXPECT_CALL(*observer_, DidStartNavigation(_)) 458 EXPECT_CALL(*observer_, DidStartNavigation(_))
347 .WillOnce(VerifyNewNativePageStartedContext(web_state(), url, &context)); 459 .WillOnce(VerifyNewNativePageStartedContext(web_state(), url, &context));
460 EXPECT_CALL(*observer_, DidStartLoading());
348 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 461 EXPECT_CALL(*observer_, DidFinishNavigation(_))
349 .WillOnce(VerifyNewNativePageFinishedContext(web_state(), url, &context)); 462 .WillOnce(VerifyNewNativePageFinishedContext(web_state(), url, &context));
463 EXPECT_CALL(*observer_, DidStopLoading());
350 LoadUrl(url); 464 LoadUrl(url);
351 } 465 }
352 466
353 // Tests native content reload navigation. 467 // Tests native content reload navigation.
354 TEST_F(StartAndFinishNavigationTest, NativeContentReload) { 468 TEST_F(NavigationCallbacksTest, NativeContentReload) {
355 GURL url(url::SchemeHostPort(kTestNativeContentScheme, "ui", 0).Serialize()); 469 GURL url(url::SchemeHostPort(kTestNativeContentScheme, "ui", 0).Serialize());
356 NavigationContext* context = nullptr; 470 NavigationContext* context = nullptr;
357 EXPECT_CALL(*observer_, DidStartNavigation(_)); 471 EXPECT_CALL(*observer_, DidStartNavigation(_));
472 EXPECT_CALL(*observer_, DidStartLoading());
358 EXPECT_CALL(*observer_, DidFinishNavigation(_)); 473 EXPECT_CALL(*observer_, DidFinishNavigation(_));
474 EXPECT_CALL(*observer_, DidStopLoading());
359 LoadUrl(url); 475 LoadUrl(url);
360 476
361 // Reload native content. 477 // Reload native content.
362 EXPECT_CALL(*observer_, DidStartNavigation(_)) 478 EXPECT_CALL(*observer_, DidStartNavigation(_))
363 .WillOnce(VerifyReloadStartedContext(web_state(), url, &context)); 479 .WillOnce(VerifyReloadStartedContext(web_state(), url, &context));
480 EXPECT_CALL(*observer_, DidStartLoading());
364 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 481 EXPECT_CALL(*observer_, DidFinishNavigation(_))
365 .WillOnce(VerifyReloadFinishedContext(web_state(), url, &context)); 482 .WillOnce(VerifyReloadFinishedContext(web_state(), url, &context,
483 false /* is_web_page */));
484 EXPECT_CALL(*observer_, DidStopLoading());
366 navigation_manager()->Reload(ReloadType::NORMAL, false /*check_for_repost*/); 485 navigation_manager()->Reload(ReloadType::NORMAL, false /*check_for_repost*/);
367 } 486 }
368 487
488 // Tests successful navigation to a new page with post HTTP method.
489 TEST_F(NavigationCallbacksTest, UserInitiatedPostNavigation) {
490 const GURL url = HttpServer::MakeUrl("http://chromium.test");
491 std::map<GURL, std::string> responses;
492 responses[url] = "Chromium Test";
493 web::test::SetUpSimpleHttpServer(responses);
494
495 // Perform new page navigation.
496 NavigationContext* context = nullptr;
497 EXPECT_CALL(*observer_, DidStartNavigation(_))
498 .WillOnce(VerifyPostStartedContext(web_state(), url, &context));
499 EXPECT_CALL(*observer_, DidStartLoading());
500 EXPECT_CALL(*observer_, DidFinishNavigation(_))
501 .WillOnce(VerifyPostFinishedContext(web_state(), url, &context));
502 EXPECT_CALL(*observer_, DidStopLoading());
503
504 // Load request using POST HTTP method.
505 web::NavigationManager::WebLoadParams params(url);
506 params.post_data.reset(
507 [[@"foo" dataUsingEncoding:NSUTF8StringEncoding] retain]);
508 params.extra_headers.reset([@{ @"Content-Type" : @"text/html" } retain]);
509 LoadWithParams(params);
510 }
511
512 // Tests successful navigation to a new page with post HTTP method.
513 TEST_F(NavigationCallbacksTest, RendererInitiatedPostNavigation) {
514 const GURL url = HttpServer::MakeUrl("http://chromium.test");
515 std::map<GURL, std::string> responses;
516 responses[url] = "<form method='post' id='form'></form>";
517 web::test::SetUpSimpleHttpServer(responses);
518
519 // Perform new page navigation.
520 NavigationContext* context = nullptr;
521 EXPECT_CALL(*observer_, DidStartNavigation(_));
522 EXPECT_CALL(*observer_, DidStartLoading());
523 EXPECT_CALL(*observer_, DidFinishNavigation(_));
524 EXPECT_CALL(*observer_, DidStopLoading());
525 LoadUrl(url);
526
527 // Submit the form using JavaScript.
528 EXPECT_CALL(*observer_, DidStartNavigation(_))
529 .WillOnce(VerifyPostStartedContext(web_state(), url, &context));
530 EXPECT_CALL(*observer_, DidStartLoading());
531 EXPECT_CALL(*observer_, DidFinishNavigation(_))
532 .WillOnce(VerifyPostFinishedContext(web_state(), url, &context));
533 EXPECT_CALL(*observer_, DidStopLoading());
534 ExecuteJavaScript(@"window.document.getElementById('form').submit();");
535 }
536
537 // Tests successful reload of a page returned for post request.
538 TEST_F(NavigationCallbacksTest, ReloadPostNavigation) {
539 const GURL url = HttpServer::MakeUrl("http://chromium.test");
540 std::map<GURL, std::string> responses;
541 const GURL action = HttpServer::MakeUrl("http://action.test");
542 responses[url] =
543 base::StringPrintf("<form method='post' id='form' action='%s'></form>",
544 action.spec().c_str());
545 web::test::SetUpSimpleHttpServer(responses);
546
547 // Perform new page navigation.
548 NavigationContext* context = nullptr;
549 EXPECT_CALL(*observer_, DidStartNavigation(_));
550 EXPECT_CALL(*observer_, DidStartLoading());
551 EXPECT_CALL(*observer_, DidFinishNavigation(_));
552 EXPECT_CALL(*observer_, DidStopLoading());
553 LoadUrl(url);
554
555 // Submit the form using JavaScript.
556 EXPECT_CALL(*observer_, DidStartNavigation(_));
557 EXPECT_CALL(*observer_, DidStartLoading());
558 EXPECT_CALL(*observer_, DidFinishNavigation(_));
559 EXPECT_CALL(*observer_, DidStopLoading());
560 ExecuteBlockAndWaitForLoad(action, ^{
561 ExecuteJavaScript(@"window.document.getElementById('form').submit();");
562 });
563
564 // Reload the page.
565 EXPECT_CALL(*observer_, DidStartNavigation(_))
566 .WillOnce(VerifyPostStartedContext(web_state(), action, &context));
567 EXPECT_CALL(*observer_, DidStartLoading());
568 EXPECT_CALL(*observer_, DidFinishNavigation(_))
569 .WillOnce(VerifyPostFinishedContext(web_state(), action, &context));
570 EXPECT_CALL(*observer_, DidStopLoading());
571 // TODO(crbug.com/700958): ios/web ignores |check_for_repost| flag and current
572 // delegate does not run callback for ShowRepostFormWarningDialog. Clearing
573 // the delegate will allow form resubmission. Remove this workaround (clearing
574 // the delegate, once |check_for_repost| is supported).
575 web_state()->SetDelegate(nullptr);
576 ExecuteBlockAndWaitForLoad(action, ^{
577 navigation_manager()->Reload(ReloadType::NORMAL,
578 false /*check_for_repost*/);
579 });
580 }
581
582 // Tests going forward to a page rendered from post response.
583 TEST_F(NavigationCallbacksTest, ForwardPostNavigation) {
584 const GURL url = HttpServer::MakeUrl("http://chromium.test");
585 std::map<GURL, std::string> responses;
586 const GURL action = HttpServer::MakeUrl("http://action.test");
587 responses[url] =
588 base::StringPrintf("<form method='post' id='form' action='%s'></form>",
589 action.spec().c_str());
590 web::test::SetUpSimpleHttpServer(responses);
591
592 // Perform new page navigation.
593 NavigationContext* context = nullptr;
594 EXPECT_CALL(*observer_, DidStartNavigation(_));
595 EXPECT_CALL(*observer_, DidStartLoading());
596 EXPECT_CALL(*observer_, DidFinishNavigation(_));
597 EXPECT_CALL(*observer_, DidStopLoading());
598 LoadUrl(url);
599
600 // Submit the form using JavaScript.
601 EXPECT_CALL(*observer_, DidStartNavigation(_));
602 EXPECT_CALL(*observer_, DidStartLoading());
603 EXPECT_CALL(*observer_, DidFinishNavigation(_));
604 EXPECT_CALL(*observer_, DidStopLoading());
605 ExecuteBlockAndWaitForLoad(action, ^{
606 ExecuteJavaScript(@"window.document.getElementById('form').submit();");
607 });
608
609 // Go Back.
610 EXPECT_CALL(*observer_, DidStartNavigation(_));
611 EXPECT_CALL(*observer_, DidStartLoading());
612 EXPECT_CALL(*observer_, DidFinishNavigation(_));
613 EXPECT_CALL(*observer_, DidStopLoading());
614 ExecuteBlockAndWaitForLoad(url, ^{
615 navigation_manager()->GoBack();
616 });
617
618 // Go forward.
619 EXPECT_CALL(*observer_, DidStartNavigation(_))
620 .WillOnce(VerifyPostStartedContext(web_state(), action, &context));
621 EXPECT_CALL(*observer_, DidStartLoading());
622 EXPECT_CALL(*observer_, DidFinishNavigation(_))
623 .WillOnce(VerifyPostFinishedContext(web_state(), action, &context));
624 EXPECT_CALL(*observer_, DidStopLoading());
625 // TODO(crbug.com/700958): ios/web ignores |check_for_repost| flag and current
626 // delegate does not run callback for ShowRepostFormWarningDialog. Clearing
627 // the delegate will allow form resubmission. Remove this workaround (clearing
628 // the delegate, once |check_for_repost| is supported).
629 web_state()->SetDelegate(nullptr);
630 ExecuteBlockAndWaitForLoad(action, ^{
631 navigation_manager()->GoForward();
632 });
633 }
634
369 } // namespace web 635 } // namespace web
OLDNEW
« no previous file with comments | « no previous file | ios/web/web_state/ui/crw_web_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698