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

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

Issue 2903883002: Added NavigationContext::IsPost. (Closed)
Patch Set: Self review 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 | « ios/web/test/web_int_test.mm ('k') | ios/web/web_state/navigation_context_impl.h » ('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());
43 NavigationManager* navigation_manager = web_state->GetNavigationManager(); 45 NavigationManager* navigation_manager = web_state->GetNavigationManager();
44 NavigationItem* item = navigation_manager->GetPendingItem(); 46 NavigationItem* item = navigation_manager->GetPendingItem();
45 EXPECT_EQ(url, item->GetURL()); 47 EXPECT_EQ(url, item->GetURL());
46 } 48 }
47 49
48 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation 50 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation
49 // passed to |DidFinishNavigation|. Asserts that |NavigationContext| the same as 51 // passed to |DidFinishNavigation|. Asserts that |NavigationContext| the same as
50 // |context|. 52 // |context|.
51 ACTION_P3(VerifyNewPageFinishedContext, web_state, url, context) { 53 ACTION_P3(VerifyNewPageFinishedContext, web_state, url, context) {
52 ASSERT_EQ(*context, arg0); 54 ASSERT_EQ(*context, arg0);
53 EXPECT_EQ(web_state, (*context)->GetWebState()); 55 EXPECT_EQ(web_state, (*context)->GetWebState());
54 ASSERT_TRUE((*context)); 56 ASSERT_TRUE((*context));
55 EXPECT_EQ(web_state, (*context)->GetWebState()); 57 EXPECT_EQ(web_state, (*context)->GetWebState());
56 EXPECT_EQ(url, (*context)->GetUrl()); 58 EXPECT_EQ(url, (*context)->GetUrl());
57 EXPECT_TRUE( 59 EXPECT_TRUE(
58 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED, 60 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED,
59 (*context)->GetPageTransition())); 61 (*context)->GetPageTransition()));
60 EXPECT_FALSE((*context)->IsSameDocument()); 62 EXPECT_FALSE((*context)->IsSameDocument());
63 EXPECT_FALSE((*context)->IsPost());
61 EXPECT_FALSE((*context)->GetError()); 64 EXPECT_FALSE((*context)->GetError());
62 ASSERT_TRUE((*context)->GetResponseHeaders()); 65 ASSERT_TRUE((*context)->GetResponseHeaders());
63 std::string mime_type; 66 std::string mime_type;
64 (*context)->GetResponseHeaders()->GetMimeType(&mime_type); 67 (*context)->GetResponseHeaders()->GetMimeType(&mime_type);
65 EXPECT_EQ(kExpectedMimeType, mime_type); 68 EXPECT_EQ(kExpectedMimeType, mime_type);
66 NavigationManager* navigation_manager = web_state->GetNavigationManager(); 69 NavigationManager* navigation_manager = web_state->GetNavigationManager();
67 NavigationItem* item = navigation_manager->GetLastCommittedItem(); 70 NavigationItem* item = navigation_manager->GetLastCommittedItem();
68 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0); 71 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0);
69 EXPECT_EQ(url, item->GetURL()); 72 EXPECT_EQ(url, item->GetURL());
70 } 73 }
71 74
75 // Verifies correctness of |NavigationContext| (|arg0|) for navigations via POST
76 // HTTP methods passed to |DidStartNavigation|. Stores |NavigationContext| in
77 // |context| pointer.
78 ACTION_P3(VerifyPostStartedContext, web_state, url, context) {
79 *context = arg0;
80 ASSERT_TRUE(*context);
81 EXPECT_EQ(web_state, (*context)->GetWebState());
82 EXPECT_EQ(url, (*context)->GetUrl());
83 EXPECT_FALSE((*context)->IsSameDocument());
84 EXPECT_TRUE((*context)->IsPost());
85 EXPECT_FALSE((*context)->GetError());
86 ASSERT_FALSE((*context)->GetResponseHeaders());
87 // TODO(crbug.com/676129): Reload does not create a pending item. Remove this
88 // workaround once the bug is fixed.
89 if (!ui::PageTransitionTypeIncludingQualifiersIs(
90 ui::PageTransition::PAGE_TRANSITION_RELOAD,
91 (*context)->GetPageTransition())) {
92 NavigationManager* navigation_manager = web_state->GetNavigationManager();
93 NavigationItem* item = navigation_manager->GetPendingItem();
94 EXPECT_EQ(url, item->GetURL());
95 }
96 }
97
98 // Verifies correctness of |NavigationContext| (|arg0|) for navigations via POST
99 // HTTP methods passed to |DidFinishNavigation|. Stores |NavigationContext| in
100 // |context| pointer.
101 ACTION_P3(VerifyPostFinishedContext, web_state, url, context) {
102 ASSERT_EQ(*context, arg0);
103 EXPECT_EQ(web_state, (*context)->GetWebState());
104 ASSERT_TRUE((*context));
105 EXPECT_EQ(web_state, (*context)->GetWebState());
106 EXPECT_EQ(url, (*context)->GetUrl());
107 EXPECT_FALSE((*context)->IsSameDocument());
108 EXPECT_TRUE((*context)->IsPost());
109 EXPECT_FALSE((*context)->GetError());
110 NavigationManager* navigation_manager = web_state->GetNavigationManager();
111 NavigationItem* item = navigation_manager->GetLastCommittedItem();
112 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0);
113 EXPECT_EQ(url, item->GetURL());
114 }
115
72 // Verifies correctness of |NavigationContext| (|arg0|) for same page navigation 116 // Verifies correctness of |NavigationContext| (|arg0|) for same page navigation
73 // passed to |DidFinishNavigation|. Stores |NavigationContext| in |context| 117 // passed to |DidFinishNavigation|. Stores |NavigationContext| in |context|
74 // pointer. 118 // pointer.
75 ACTION_P4(VerifySameDocumentStartedContext, 119 ACTION_P4(VerifySameDocumentStartedContext,
76 web_state, 120 web_state,
77 url, 121 url,
78 context, 122 context,
79 page_transition) { 123 page_transition) {
80 *context = arg0; 124 *context = arg0;
81 ASSERT_TRUE(*context); 125 ASSERT_TRUE(*context);
82 EXPECT_EQ(web_state, (*context)->GetWebState()); 126 EXPECT_EQ(web_state, (*context)->GetWebState());
83 EXPECT_EQ(url, (*context)->GetUrl()); 127 EXPECT_EQ(url, (*context)->GetUrl());
84 EXPECT_TRUE(PageTransitionTypeIncludingQualifiersIs( 128 EXPECT_TRUE(PageTransitionTypeIncludingQualifiersIs(
85 page_transition, (*context)->GetPageTransition())); 129 page_transition, (*context)->GetPageTransition()));
86 EXPECT_FALSE((*context)->IsSameDocument()); 130 EXPECT_FALSE((*context)->IsSameDocument());
131 EXPECT_FALSE((*context)->IsPost());
87 EXPECT_FALSE((*context)->GetError()); 132 EXPECT_FALSE((*context)->GetError());
88 EXPECT_FALSE((*context)->GetResponseHeaders()); 133 EXPECT_FALSE((*context)->GetResponseHeaders());
89 } 134 }
90 135
91 // Verifies correctness of |NavigationContext| (|arg0|) for same page navigation 136 // Verifies correctness of |NavigationContext| (|arg0|) for same page navigation
92 // passed to |DidFinishNavigation|. Asserts that |NavigationContext| the same as 137 // passed to |DidFinishNavigation|. Asserts that |NavigationContext| the same as
93 // |context|. 138 // |context|.
94 ACTION_P4(VerifySameDocumentFinishedContext, 139 ACTION_P4(VerifySameDocumentFinishedContext,
95 web_state, 140 web_state,
96 url, 141 url,
97 context, 142 context,
98 page_transition) { 143 page_transition) {
99 ASSERT_EQ(*context, arg0); 144 ASSERT_EQ(*context, arg0);
100 ASSERT_TRUE(*context); 145 ASSERT_TRUE(*context);
101 EXPECT_EQ(web_state, (*context)->GetWebState()); 146 EXPECT_EQ(web_state, (*context)->GetWebState());
102 EXPECT_EQ(url, (*context)->GetUrl()); 147 EXPECT_EQ(url, (*context)->GetUrl());
103 EXPECT_TRUE(PageTransitionTypeIncludingQualifiersIs( 148 EXPECT_TRUE(PageTransitionTypeIncludingQualifiersIs(
104 page_transition, (*context)->GetPageTransition())); 149 page_transition, (*context)->GetPageTransition()));
105 EXPECT_TRUE((*context)->IsSameDocument()); 150 EXPECT_TRUE((*context)->IsSameDocument());
151 EXPECT_FALSE((*context)->IsPost());
106 EXPECT_FALSE((*context)->GetError()); 152 EXPECT_FALSE((*context)->GetError());
107 EXPECT_FALSE((*context)->GetResponseHeaders()); 153 EXPECT_FALSE((*context)->GetResponseHeaders());
108 NavigationManager* navigation_manager = web_state->GetNavigationManager(); 154 NavigationManager* navigation_manager = web_state->GetNavigationManager();
109 NavigationItem* item = navigation_manager->GetLastCommittedItem(); 155 NavigationItem* item = navigation_manager->GetLastCommittedItem();
110 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0); 156 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0);
111 EXPECT_EQ(url, item->GetURL()); 157 EXPECT_EQ(url, item->GetURL());
112 } 158 }
113 159
114 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation 160 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation
115 // to native URLs passed to |DidStartNavigation|. Stores |NavigationContext| in 161 // to native URLs passed to |DidStartNavigation|. Stores |NavigationContext| in
116 // |context| pointer. 162 // |context| pointer.
117 ACTION_P3(VerifyNewNativePageStartedContext, web_state, url, context) { 163 ACTION_P3(VerifyNewNativePageStartedContext, web_state, url, context) {
118 *context = arg0; 164 *context = arg0;
119 ASSERT_TRUE(*context); 165 ASSERT_TRUE(*context);
120 EXPECT_EQ(web_state, (*context)->GetWebState()); 166 EXPECT_EQ(web_state, (*context)->GetWebState());
121 EXPECT_EQ(url, (*context)->GetUrl()); 167 EXPECT_EQ(url, (*context)->GetUrl());
122 EXPECT_TRUE( 168 EXPECT_TRUE(
123 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED, 169 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED,
124 (*context)->GetPageTransition())); 170 (*context)->GetPageTransition()));
125 EXPECT_FALSE((*context)->IsSameDocument()); 171 EXPECT_FALSE((*context)->IsSameDocument());
172 EXPECT_FALSE((*context)->IsPost());
126 EXPECT_FALSE((*context)->GetError()); 173 EXPECT_FALSE((*context)->GetError());
127 EXPECT_FALSE((*context)->GetResponseHeaders()); 174 EXPECT_FALSE((*context)->GetResponseHeaders());
128 NavigationManager* navigation_manager = web_state->GetNavigationManager(); 175 NavigationManager* navigation_manager = web_state->GetNavigationManager();
129 NavigationItem* item = navigation_manager->GetPendingItem(); 176 NavigationItem* item = navigation_manager->GetPendingItem();
130 EXPECT_EQ(url, item->GetURL()); 177 EXPECT_EQ(url, item->GetURL());
131 } 178 }
132 179
133 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation 180 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation
134 // to native URLs passed to |DidFinishNavigation|. Asserts that 181 // to native URLs passed to |DidFinishNavigation|. Asserts that
135 // |NavigationContext| the same as |context|. 182 // |NavigationContext| the same as |context|.
136 ACTION_P3(VerifyNewNativePageFinishedContext, web_state, url, context) { 183 ACTION_P3(VerifyNewNativePageFinishedContext, web_state, url, context) {
137 ASSERT_EQ(*context, arg0); 184 ASSERT_EQ(*context, arg0);
138 ASSERT_TRUE(*context); 185 ASSERT_TRUE(*context);
139 EXPECT_EQ(web_state, (*context)->GetWebState()); 186 EXPECT_EQ(web_state, (*context)->GetWebState());
140 EXPECT_EQ(url, (*context)->GetUrl()); 187 EXPECT_EQ(url, (*context)->GetUrl());
141 EXPECT_TRUE( 188 EXPECT_TRUE(
142 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED, 189 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED,
143 (*context)->GetPageTransition())); 190 (*context)->GetPageTransition()));
144 EXPECT_FALSE((*context)->IsSameDocument()); 191 EXPECT_FALSE((*context)->IsSameDocument());
192 EXPECT_FALSE((*context)->IsPost());
145 EXPECT_FALSE((*context)->GetError()); 193 EXPECT_FALSE((*context)->GetError());
146 EXPECT_FALSE((*context)->GetResponseHeaders()); 194 EXPECT_FALSE((*context)->GetResponseHeaders());
147 NavigationManager* navigation_manager = web_state->GetNavigationManager(); 195 NavigationManager* navigation_manager = web_state->GetNavigationManager();
148 NavigationItem* item = navigation_manager->GetLastCommittedItem(); 196 NavigationItem* item = navigation_manager->GetLastCommittedItem();
149 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0); 197 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0);
150 EXPECT_EQ(url, item->GetURL()); 198 EXPECT_EQ(url, item->GetURL());
151 } 199 }
152 200
153 // Mocks DidFinishNavigation navigation callback. 201 // Mocks DidFinishNavigation navigation callback.
154 class WebStateObserverMock : public WebStateObserver { 202 class WebStateObserverMock : public WebStateObserver {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 TEST_F(StartAndFinishNavigationTest, NativeContentNavigation) { 352 TEST_F(StartAndFinishNavigationTest, NativeContentNavigation) {
305 GURL url(url::SchemeHostPort(kTestNativeContentScheme, "ui", 0).Serialize()); 353 GURL url(url::SchemeHostPort(kTestNativeContentScheme, "ui", 0).Serialize());
306 NavigationContext* context = nullptr; 354 NavigationContext* context = nullptr;
307 EXPECT_CALL(*observer_, DidStartNavigation(_)) 355 EXPECT_CALL(*observer_, DidStartNavigation(_))
308 .WillOnce(VerifyNewNativePageStartedContext(web_state(), url, &context)); 356 .WillOnce(VerifyNewNativePageStartedContext(web_state(), url, &context));
309 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 357 EXPECT_CALL(*observer_, DidFinishNavigation(_))
310 .WillOnce(VerifyNewNativePageFinishedContext(web_state(), url, &context)); 358 .WillOnce(VerifyNewNativePageFinishedContext(web_state(), url, &context));
311 LoadUrl(url); 359 LoadUrl(url);
312 } 360 }
313 361
362 // Tests successful navigation to a new page with post HTTP method.
363 TEST_F(StartAndFinishNavigationTest, UserInitiatedPostNavigation) {
364 const GURL url = HttpServer::MakeUrl("http://chromium.test");
365 std::map<GURL, std::string> responses;
366 responses[url] = "Chromium Test";
367 web::test::SetUpSimpleHttpServer(responses);
368
369 // Perform new page navigation.
370 NavigationContext* context = nullptr;
371 EXPECT_CALL(*observer_, DidStartNavigation(_))
372 .WillOnce(VerifyPostStartedContext(web_state(), url, &context));
373 EXPECT_CALL(*observer_, DidFinishNavigation(_))
374 .WillOnce(VerifyPostFinishedContext(web_state(), url, &context));
375
376 // Load request using POST HTTP method.
377 web::NavigationManager::WebLoadParams params(url);
378 params.post_data.reset(
379 [[@"foo" dataUsingEncoding:NSUTF8StringEncoding] retain]);
380 params.extra_headers.reset([@{ @"Content-Type" : @"text/html" } retain]);
381 LoadWithParams(params);
382 }
383
384 // Tests successful navigation to a new page with post HTTP method.
385 TEST_F(StartAndFinishNavigationTest, RendererInitiatedPostNavigation) {
386 const GURL url = HttpServer::MakeUrl("http://chromium.test");
387 std::map<GURL, std::string> responses;
388 responses[url] = "<form method='post' id='form'></form>";
389 web::test::SetUpSimpleHttpServer(responses);
390
391 // Perform new page navigation.
392 NavigationContext* context = nullptr;
393 EXPECT_CALL(*observer_, DidStartNavigation(_));
394 EXPECT_CALL(*observer_, DidFinishNavigation(_));
395 LoadUrl(url);
396
397 // Submit the form using JavaScript.
398 EXPECT_CALL(*observer_, DidStartNavigation(_))
399 .WillOnce(VerifyPostStartedContext(web_state(), url, &context));
400 EXPECT_CALL(*observer_, DidFinishNavigation(_))
401 .WillOnce(VerifyPostFinishedContext(web_state(), url, &context));
402 ExecuteJavaScript(@"window.document.getElementById('form').submit();");
403 }
404
405 // Tests successful reload of a page returned for post request.
406 TEST_F(StartAndFinishNavigationTest, ReloadPostNavigation) {
407 const GURL url = HttpServer::MakeUrl("http://chromium.test");
408 std::map<GURL, std::string> responses;
409 const GURL action = HttpServer::MakeUrl("http://action.test");
410 responses[url] =
411 base::StringPrintf("<form method='post' id='form' action='%s'></form>",
412 action.spec().c_str());
413 web::test::SetUpSimpleHttpServer(responses);
414
415 // Perform new page navigation.
416 NavigationContext* context = nullptr;
417 EXPECT_CALL(*observer_, DidStartNavigation(_));
418 EXPECT_CALL(*observer_, DidFinishNavigation(_));
419 LoadUrl(url);
420
421 // Submit the form using JavaScript.
422 EXPECT_CALL(*observer_, DidStartNavigation(_));
423 EXPECT_CALL(*observer_, DidFinishNavigation(_));
424 ExecuteBlockAndWaitForLoad(action, ^{
425 ExecuteJavaScript(@"window.document.getElementById('form').submit();");
426 });
427
428 // Reload the page.
429 EXPECT_CALL(*observer_, DidStartNavigation(_))
430 .WillOnce(VerifyPostStartedContext(web_state(), action, &context));
431 EXPECT_CALL(*observer_, DidFinishNavigation(_))
432 .WillOnce(VerifyPostFinishedContext(web_state(), action, &context));
433 // TODO(crbug.com/700958): ios/web ignores |check_for_repost| flag and current
434 // delegate does not run callback for ShowRepostFormWarningDialog. Clearing
435 // the delegate will allow form resubmission. Remove this workaround (clearing
436 // the delegate, once |check_for_repost| is supported).
437 web_state()->SetDelegate(nullptr);
438 ExecuteBlockAndWaitForLoad(action, ^{
439 navigation_manager()->Reload(ReloadType::NORMAL,
440 false /*check_for_repost*/);
441 });
442 }
443
444 // Tests going forward to a page rendered from post response.
445 TEST_F(StartAndFinishNavigationTest, ForwardPostNavigation) {
446 const GURL url = HttpServer::MakeUrl("http://chromium.test");
447 std::map<GURL, std::string> responses;
448 const GURL action = HttpServer::MakeUrl("http://action.test");
449 responses[url] =
450 base::StringPrintf("<form method='post' id='form' action='%s'></form>",
451 action.spec().c_str());
452 web::test::SetUpSimpleHttpServer(responses);
453
454 // Perform new page navigation.
455 NavigationContext* context = nullptr;
456 EXPECT_CALL(*observer_, DidStartNavigation(_));
457 EXPECT_CALL(*observer_, DidFinishNavigation(_));
458 LoadUrl(url);
459
460 // Submit the form using JavaScript.
461 EXPECT_CALL(*observer_, DidStartNavigation(_));
462 EXPECT_CALL(*observer_, DidFinishNavigation(_));
463 ExecuteBlockAndWaitForLoad(action, ^{
464 ExecuteJavaScript(@"window.document.getElementById('form').submit();");
465 });
466
467 // Go Back.
468 EXPECT_CALL(*observer_, DidStartNavigation(_));
469 EXPECT_CALL(*observer_, DidFinishNavigation(_));
470 ExecuteBlockAndWaitForLoad(url, ^{
471 navigation_manager()->GoBack();
472 });
473
474 // Go forward.
475 EXPECT_CALL(*observer_, DidStartNavigation(_))
476 .WillOnce(VerifyPostStartedContext(web_state(), action, &context));
477 EXPECT_CALL(*observer_, DidFinishNavigation(_))
478 .WillOnce(VerifyPostFinishedContext(web_state(), action, &context));
479 // TODO(crbug.com/700958): ios/web ignores |check_for_repost| flag and current
480 // delegate does not run callback for ShowRepostFormWarningDialog. Clearing
481 // the delegate will allow form resubmission. Remove this workaround (clearing
482 // the delegate, once |check_for_repost| is supported).
483 web_state()->SetDelegate(nullptr);
484 ExecuteBlockAndWaitForLoad(action, ^{
485 navigation_manager()->GoForward();
486 });
487 }
488
314 } // namespace web 489 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/test/web_int_test.mm ('k') | ios/web/web_state/navigation_context_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698