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 <XCTest/XCTest.h> | 5 #import <XCTest/XCTest.h> |
6 | 6 |
7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
8 #include "base/memory/ptr_util.h" | |
8 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
9 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
10 #include "components/strings/grit/components_strings.h" | 11 #include "components/strings/grit/components_strings.h" |
11 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" | 12 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
12 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 13 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
13 #include "ios/chrome/browser/ui/ui_util.h" | 14 #include "ios/chrome/browser/ui/ui_util.h" |
14 #import "ios/chrome/test/app/chrome_test_util.h" | 15 #import "ios/chrome/test/app/chrome_test_util.h" |
15 #include "ios/chrome/test/app/navigation_test_util.h" | 16 #include "ios/chrome/test/app/navigation_test_util.h" |
16 #include "ios/chrome/test/app/web_view_interaction_test_util.h" | 17 #include "ios/chrome/test/app/web_view_interaction_test_util.h" |
17 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" | 18 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" |
18 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 19 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
19 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 20 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
20 #import "ios/testing/wait_util.h" | 21 #import "ios/testing/wait_util.h" |
21 #import "ios/web/public/test/http_server.h" | 22 #import "ios/web/public/test/http_server.h" |
22 #import "ios/web/public/test/http_server_util.h" | 23 #import "ios/web/public/test/http_server_util.h" |
23 #include "ios/web/public/test/response_providers/html_response_provider.h" | 24 #include "ios/web/public/test/response_providers/data_response_provider.h" |
24 #include "ios/web/public/test/response_providers/html_response_provider_impl.h" | |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 // URL for a generic website in the user navigation flow. | 28 // Test Server scheme. |
29 const char kGenericUrl[] = "http://generic"; | 29 const char kHTTPScheme[] = "http://"; |
Eugene But (OOO till 7-30)
2017/02/14 21:44:43
kHttpScheme
michaeldo
2017/02/15 00:56:34
Done.
| |
30 | 30 |
31 // URL for the server to print the HTTP method and the request body. | 31 // Test server domain. |
32 const char kPrintFormDataUrl[] = "http://printFormData"; | 32 const char kHttpServerDomain[] = "localhost"; |
Eugene But (OOO till 7-30)
2017/02/14 21:44:43
nit: kHttpServerHost ?
michaeldo
2017/02/15 00:56:34
Done.
| |
33 | 33 |
34 // URL for the server that redirects to kPrintPostData with a 302. | 34 // Path for a generic website in the user navigation flow. |
35 const char kRedirectUrl[] = "http://redirect"; | 35 const char kGenericPath[] = "/generic/"; |
36 | 36 |
37 // URL for the server to return a page that posts a form with some data to | 37 // Path for the server to print the HTTP method and the request body. |
38 // |kPrintPostData|. | 38 const char kPrintFormDataPath[] = "/printformdata/"; |
39 const char kFormUrl[] = "http://formURL"; | |
40 | 39 |
41 // URL for the server to return a page that posts to |kRedirect|. | 40 // Path for the server that redirects to |kPrintFormDataPath| with a 302. |
42 const char kRedirectFormUrl[] = "http://redirectFormURL"; | 41 const char kRedirectPath[] = "/redirect/"; |
42 | |
43 // Path for the server to return a page that posts a form with some data to | |
44 // |kPrintFormDataPath|. | |
45 const char kFormPath[] = "/form/"; | |
46 | |
47 // Path for the server to return a page that posts to |kRedirectPath|. | |
48 const char kRedirectFormPath[] = "/redirectform/"; | |
43 | 49 |
44 // Label for the button in the form. | 50 // Label for the button in the form. |
45 const char kSubmitButton[] = "Submit"; | 51 const char kSubmitButton[] = "Submit"; |
46 | 52 |
47 // Expected response from the server. | 53 // Expected response from the server. |
48 const char kExpectedPostData[] = "POST Data=Unicorn"; | 54 const char kExpectedPostData[] = "POST Data=Unicorn"; |
49 | 55 |
56 #pragma mark - TestResponseProvider | |
57 | |
58 // A ResponseProvider that provides html response or a redirect. | |
59 class TestResponseProvider : public web::DataResponseProvider { | |
60 public: | |
61 // TestResponseProvider implementation. | |
62 bool CanHandleRequest(const Request& request) override; | |
63 void GetResponseHeadersAndBody( | |
64 const Request& request, | |
65 scoped_refptr<net::HttpResponseHeaders>* headers, | |
66 std::string* response_body) override; | |
67 }; | |
68 | |
69 bool TestResponseProvider::CanHandleRequest(const Request& request) { | |
70 const GURL& url = request.url; | |
71 return url.host() == kHttpServerDomain && | |
72 (url.path() == kFormPath || url.path() == kRedirectFormPath || | |
73 url.path() == kRedirectPath || url.path() == kPrintFormDataPath); | |
74 } | |
75 | |
76 void TestResponseProvider::GetResponseHeadersAndBody( | |
77 const Request& request, | |
78 scoped_refptr<net::HttpResponseHeaders>* headers, | |
79 std::string* response_body) { | |
80 GURL printFormDataUrl = web::test::HttpServer::MakeUrl( | |
Eugene But (OOO till 7-30)
2017/02/14 21:44:43
print_form_data_url
michaeldo
2017/02/15 00:56:34
Done.
| |
81 std::string(kHTTPScheme) + kPrintFormDataPath); | |
Eugene But (OOO till 7-30)
2017/02/14 21:44:43
How about using url::SchemeHostPort instead of str
michaeldo
2017/02/15 00:56:34
I agree that url::SchemeHostPort is more ideal, bu
Eugene But (OOO till 7-30)
2017/02/15 01:28:04
I suggested to use url::SchemeHostPort to avoid st
| |
82 | |
83 const GURL& url = request.url; | |
84 if (url.path() == kRedirectPath) { | |
85 *headers = web::ResponseProvider::GetRedirectResponseHeaders( | |
86 printFormDataUrl.spec(), net::HTTP_FOUND); | |
87 return; | |
88 } | |
89 | |
90 const char* formHtml = | |
Eugene But (OOO till 7-30)
2017/02/14 21:44:43
form_html
michaeldo
2017/02/15 00:56:34
Done.
| |
91 "<form method=\"post\" action=\"%s\">" | |
92 "<textarea rows=\"1\" name=\"Data\">Unicorn</textarea>" | |
93 "<input type=\"submit\" value=\"%s\" id=\"%s\">" | |
94 "</form>"; | |
95 | |
96 *headers = web::ResponseProvider::GetDefaultResponseHeaders(); | |
97 if (url.path() == kFormPath) { | |
98 *response_body = | |
99 base::StringPrintf(formHtml, printFormDataUrl.spec().c_str(), | |
100 kSubmitButton, kSubmitButton); | |
101 return; | |
102 } else if (url.path() == kRedirectFormPath) { | |
103 *response_body = base::StringPrintf( | |
104 formHtml, | |
105 web::test::HttpServer::MakeUrl(std::string(kHTTPScheme) + kRedirectPath) | |
106 .spec() | |
107 .c_str(), | |
108 kSubmitButton, kSubmitButton); | |
109 return; | |
110 } else if (url.path() == kPrintFormDataPath) { | |
111 *response_body = request.method + std::string(" ") + request.body; | |
112 return; | |
113 } | |
114 NOTREACHED(); | |
115 } | |
116 | |
50 } // namespace | 117 } // namespace |
51 | 118 |
52 // Tests submition of HTTP forms POST data including cases involving navigation. | 119 // Tests submition of HTTP forms POST data including cases involving navigation. |
53 @interface FormsTestCase : ChromeTestCase | 120 @interface FormsTestCase : ChromeTestCase |
54 @end | 121 @end |
55 | 122 |
56 @implementation FormsTestCase | 123 @implementation FormsTestCase |
57 | 124 |
58 // Sets up server urls and responses. | 125 // Sets up server urls and responses. |
59 - (void)setUp { | 126 - (void)setUp { |
60 [super setUp]; | 127 [super setUp]; |
61 std::map<GURL, HtmlResponseProviderImpl::Response> responses; | |
62 | 128 |
63 const char* formHtml = | 129 web::test::SetUpHttpServer(base::MakeUnique<TestResponseProvider>()); |
64 "<form method=\"post\" action=\"%s\">" | |
65 "<textarea rows=\"1\" name=\"Data\">Unicorn</textarea>" | |
66 "<input type=\"submit\" value=\"%s\" id=\"%s\">" | |
67 "</form>"; | |
68 GURL printFormDataUrl = web::test::HttpServer::MakeUrl(kPrintFormDataUrl); | |
69 | |
70 const GURL formUrl = web::test::HttpServer::MakeUrl(kFormUrl); | |
71 responses[formUrl] = HtmlResponseProviderImpl::GetSimpleResponse( | |
72 base::StringPrintf(formHtml, printFormDataUrl.spec().c_str(), | |
73 kSubmitButton, kSubmitButton)); | |
74 | |
75 const GURL redirectFormUrl = web::test::HttpServer::MakeUrl(kRedirectFormUrl); | |
76 const std::string redirectFormResponse = base::StringPrintf( | |
77 formHtml, web::test::HttpServer::MakeUrl(kRedirectUrl).spec().c_str(), | |
78 kSubmitButton, kSubmitButton); | |
79 responses[redirectFormUrl] = | |
80 HtmlResponseProviderImpl::GetSimpleResponse(redirectFormResponse); | |
81 | |
82 const GURL redirectUrl = web::test::HttpServer::MakeUrl(kRedirectUrl); | |
83 responses[redirectUrl] = HtmlResponseProviderImpl::GetRedirectResponse( | |
84 printFormDataUrl, net::HTTP_FOUND); | |
85 | |
86 std::unique_ptr<web::DataResponseProvider> provider( | |
87 new HtmlResponseProvider(responses)); | |
88 web::test::SetUpHttpServer(std::move(provider)); | |
89 } | 130 } |
90 | 131 |
91 // Submits the html form and verifies the destination url. | 132 // Submits the html form and verifies the destination url. |
92 - (void)submitForm { | 133 - (void)submitForm { |
93 chrome_test_util::TapWebViewElementWithId(kSubmitButton); | 134 chrome_test_util::TapWebViewElementWithId(kSubmitButton); |
94 | 135 |
95 GURL url = web::test::HttpServer::MakeUrl(kPrintFormDataUrl); | 136 GURL url = web::test::HttpServer::MakeUrl(std::string(kHTTPScheme) + |
Eugene But (OOO till 7-30)
2017/02/14 21:44:43
Optional nit: Do you want to create TestResponsePr
michaeldo
2017/02/15 00:56:34
Done. This was a great cleanup point so I similarl
| |
137 kPrintFormDataPath); | |
96 id<GREYMatcher> URLMatcher = chrome_test_util::OmniboxText(url.GetContent()); | 138 id<GREYMatcher> URLMatcher = chrome_test_util::OmniboxText(url.GetContent()); |
97 [[EarlGrey selectElementWithMatcher:URLMatcher] | 139 [[EarlGrey selectElementWithMatcher:URLMatcher] |
98 assertWithMatcher:grey_notNil()]; | 140 assertWithMatcher:grey_notNil()]; |
99 } | 141 } |
100 | 142 |
101 // Waits for the |expectedResponse| within the web view. | 143 // Waits for the |expectedResponse| within the web view. |
102 - (void)waitForExpectedResponse:(std::string)expectedResponse { | 144 - (void)waitForExpectedResponse:(std::string)expectedResponse { |
103 [[GREYCondition | 145 GREYCondition* condition = [GREYCondition |
104 conditionWithName:@"Waiting for webview to display resulting text." | 146 conditionWithName:@"Waiting for webview to display resulting text." |
105 block:^BOOL { | 147 block:^BOOL { |
106 id<GREYMatcher> webViewMatcher = | 148 id<GREYMatcher> webViewMatcher = |
107 chrome_test_util::WebViewContainingText( | 149 chrome_test_util::WebViewContainingText( |
108 expectedResponse); | 150 expectedResponse); |
109 NSError* error = nil; | 151 NSError* error = nil; |
110 [[EarlGrey selectElementWithMatcher:webViewMatcher] | 152 [[EarlGrey selectElementWithMatcher:webViewMatcher] |
111 assertWithMatcher:grey_notNil() | 153 assertWithMatcher:grey_notNil() |
112 error:&error]; | 154 error:&error]; |
113 return error == nil; | 155 return error == nil; |
114 }] waitWithTimeout:5]; | 156 }]; |
157 GREYAssert([condition waitWithTimeout:5], @"Webview text was not displayed."); | |
115 } | 158 } |
116 | 159 |
117 // Waits for view with Tab History accessibility ID. | 160 // Waits for view with Tab History accessibility ID. |
118 - (void)waitForTabHistoryView { | 161 - (void)waitForTabHistoryView { |
119 [[GREYCondition conditionWithName:@"Waiting for Tab History to display." | 162 GREYCondition* condition = [GREYCondition |
120 block:^BOOL { | 163 conditionWithName:@"Waiting for Tab History to display." |
121 NSError* error = nil; | 164 block:^BOOL { |
122 id<GREYMatcher> tabHistory = | 165 NSError* error = nil; |
123 grey_accessibilityID(@"Tab History"); | 166 id<GREYMatcher> tabHistory = |
124 [[EarlGrey selectElementWithMatcher:tabHistory] | 167 grey_accessibilityID(@"Tab History"); |
125 assertWithMatcher:grey_notNil() | 168 [[EarlGrey selectElementWithMatcher:tabHistory] |
126 error:&error]; | 169 assertWithMatcher:grey_notNil() |
127 return error == nil; | 170 error:&error]; |
128 }] waitWithTimeout:5]; | 171 return error == nil; |
172 }]; | |
173 GREYAssert([condition waitWithTimeout:5], @"Tab History View not displayed."); | |
129 } | 174 } |
130 | 175 |
131 // Reloads the web view and waits for the loading to complete. | 176 // Reloads the web view and waits for the loading to complete. |
132 // TODO(crbug.com/638674): Evaluate if this can move to shared code | 177 // TODO(crbug.com/638674): Evaluate if this can move to shared code |
133 - (void)reloadPage { | 178 - (void)reloadPage { |
134 base::scoped_nsobject<GenericChromeCommand> reloadCommand( | 179 base::scoped_nsobject<GenericChromeCommand> reloadCommand( |
135 [[GenericChromeCommand alloc] initWithTag:IDC_RELOAD]); | 180 [[GenericChromeCommand alloc] initWithTag:IDC_RELOAD]); |
136 chrome_test_util::RunCommandWithActiveViewController(reloadCommand); | 181 chrome_test_util::RunCommandWithActiveViewController(reloadCommand); |
137 | 182 |
138 [ChromeEarlGrey waitForPageToFinishLoading]; | 183 [ChromeEarlGrey waitForPageToFinishLoading]; |
(...skipping 28 matching lines...) Expand all Loading... | |
167 - (void)confirmResendWarning { | 212 - (void)confirmResendWarning { |
168 id<GREYMatcher> resendWarning = | 213 id<GREYMatcher> resendWarning = |
169 chrome_test_util::ButtonWithAccessibilityLabelId( | 214 chrome_test_util::ButtonWithAccessibilityLabelId( |
170 IDS_HTTP_POST_WARNING_RESEND); | 215 IDS_HTTP_POST_WARNING_RESEND); |
171 [[EarlGrey selectElementWithMatcher:resendWarning] | 216 [[EarlGrey selectElementWithMatcher:resendWarning] |
172 performAction:grey_longPress()]; | 217 performAction:grey_longPress()]; |
173 } | 218 } |
174 | 219 |
175 // Tests whether the request data is reposted correctly. | 220 // Tests whether the request data is reposted correctly. |
176 - (void)testRepostForm { | 221 - (void)testRepostForm { |
177 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kFormUrl)]; | 222 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl( |
223 std::string(kHTTPScheme) + kFormPath)]; | |
178 | 224 |
179 [self submitForm]; | 225 [self submitForm]; |
180 [self waitForExpectedResponse:kExpectedPostData]; | 226 [self waitForExpectedResponse:kExpectedPostData]; |
181 | 227 |
182 [self reloadPage]; | 228 [self reloadPage]; |
183 [self confirmResendWarning]; | 229 [self confirmResendWarning]; |
184 | 230 |
185 [self waitForExpectedResponse:kExpectedPostData]; | 231 [self waitForExpectedResponse:kExpectedPostData]; |
186 } | 232 } |
187 | 233 |
188 // Tests that a POST followed by navigating to a new page and then tapping back | 234 // Tests that a POST followed by navigating to a new page and then tapping back |
189 // to the form result page resends data. | 235 // to the form result page resends data. |
190 - (void)testRepostFormAfterTappingBack { | 236 - (void)testRepostFormAfterTappingBack { |
191 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kFormUrl)]; | 237 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl( |
238 std::string(kHTTPScheme) + kFormPath)]; | |
192 | 239 |
193 [self submitForm]; | 240 [self submitForm]; |
194 | 241 |
195 // Go to a new page. | 242 // Go to a new page. |
196 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kGenericUrl)]; | 243 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl( |
244 std::string(kHTTPScheme) + kGenericPath)]; | |
197 | 245 |
198 // Go back and check that the data is reposted. | 246 // Go back and check that the data is reposted. |
199 [self goBack]; | 247 [self goBack]; |
200 [self confirmResendWarning]; | 248 [self confirmResendWarning]; |
201 [self waitForExpectedResponse:kExpectedPostData]; | 249 [self waitForExpectedResponse:kExpectedPostData]; |
202 } | 250 } |
203 | 251 |
204 // Tests that a POST followed by tapping back to the form page and then tapping | 252 // Tests that a POST followed by tapping back to the form page and then tapping |
205 // forward to the result page resends data. | 253 // forward to the result page resends data. |
206 - (void)testRepostFormAfterTappingBackAndForward { | 254 - (void)testRepostFormAfterTappingBackAndForward { |
207 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kFormUrl)]; | 255 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl( |
256 std::string(kHTTPScheme) + kFormPath)]; | |
208 [self submitForm]; | 257 [self submitForm]; |
209 | 258 |
210 [self goBack]; | 259 [self goBack]; |
211 [self goForward]; | 260 [self goForward]; |
212 [self confirmResendWarning]; | 261 [self confirmResendWarning]; |
213 [self waitForExpectedResponse:kExpectedPostData]; | 262 [self waitForExpectedResponse:kExpectedPostData]; |
214 } | 263 } |
215 | 264 |
216 // Tests that a POST followed by a new request and then index navigation to get | 265 // Tests that a POST followed by a new request and then index navigation to get |
217 // back to the result page resends data. | 266 // back to the result page resends data. |
218 - (void)testRepostFormAfterIndexNavigation { | 267 - (void)testRepostFormAfterIndexNavigation { |
219 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kFormUrl)]; | 268 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl( |
269 std::string(kHTTPScheme) + kFormPath)]; | |
220 [self submitForm]; | 270 [self submitForm]; |
221 | 271 |
222 // Go to a new page. | 272 // Go to a new page. |
223 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kGenericUrl)]; | 273 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl( |
274 std::string(kHTTPScheme) + kGenericPath)]; | |
224 | 275 |
225 [self openBackHistory]; | 276 [self openBackHistory]; |
226 [self waitForTabHistoryView]; | 277 [self waitForTabHistoryView]; |
227 | 278 |
228 const GURL printURL = web::test::HttpServer::MakeUrl(kPrintFormDataUrl); | 279 const GURL printURL = web::test::HttpServer::MakeUrl( |
280 std::string(kHTTPScheme) + kPrintFormDataPath); | |
229 id<GREYMatcher> historyItem = | 281 id<GREYMatcher> historyItem = |
230 grey_text(base::SysUTF8ToNSString(printURL.spec())); | 282 grey_text(base::SysUTF8ToNSString(printURL.spec())); |
231 [[EarlGrey selectElementWithMatcher:historyItem] performAction:grey_tap()]; | 283 [[EarlGrey selectElementWithMatcher:historyItem] performAction:grey_tap()]; |
232 | 284 |
233 [ChromeEarlGrey waitForPageToFinishLoading]; | 285 [ChromeEarlGrey waitForPageToFinishLoading]; |
234 | 286 |
235 [self confirmResendWarning]; | 287 [self confirmResendWarning]; |
236 [self waitForExpectedResponse:kExpectedPostData]; | 288 [self waitForExpectedResponse:kExpectedPostData]; |
237 } | 289 } |
238 | 290 |
239 // When data is not re-sent, the request is done with a GET method. | 291 // When data is not re-sent, the request is done with a GET method. |
240 - (void)testRepostFormCancelling { | 292 - (void)testRepostFormCancelling { |
241 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kFormUrl)]; | 293 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl( |
294 std::string(kHTTPScheme) + kFormPath)]; | |
242 [self submitForm]; | 295 [self submitForm]; |
243 | 296 |
244 [self reloadPage]; | 297 [self reloadPage]; |
245 | 298 |
246 // Abort the reload. | 299 // Abort the reload. |
247 if (IsIPadIdiom()) { | 300 if (IsIPadIdiom()) { |
248 // On tablet, dismiss the popover. | 301 // On tablet, dismiss the popover. |
249 base::scoped_nsobject<GREYElementMatcherBlock> matcher([ | 302 base::scoped_nsobject<GREYElementMatcherBlock> matcher([ |
250 [GREYElementMatcherBlock alloc] | 303 [GREYElementMatcherBlock alloc] |
251 initWithMatchesBlock:^BOOL(UIView* view) { | 304 initWithMatchesBlock:^BOOL(UIView* view) { |
252 return [NSStringFromClass([view class]) hasPrefix:@"UIDimmingView"]; | 305 return [NSStringFromClass([view class]) hasPrefix:@"UIDimmingView"]; |
253 } | 306 } |
254 descriptionBlock:^(id<GREYDescription> description) { | 307 descriptionBlock:^(id<GREYDescription> description) { |
255 [description appendText:@"class prefixed with UIDimmingView"]; | 308 [description appendText:@"class prefixed with UIDimmingView"]; |
256 }]); | 309 }]); |
257 [[EarlGrey selectElementWithMatcher:matcher] | 310 [[EarlGrey selectElementWithMatcher:matcher] |
258 performAction:grey_tapAtPoint(CGPointMake(50.0f, 50.0f))]; | 311 performAction:grey_tapAtPoint(CGPointMake(50.0f, 50.0f))]; |
259 } else { | 312 } else { |
260 // On handset, dismiss via the cancel button. | 313 // On handset, dismiss via the cancel button. |
261 [[EarlGrey selectElementWithMatcher:chrome_test_util::CancelButton()] | 314 [[EarlGrey selectElementWithMatcher:chrome_test_util::CancelButton()] |
262 performAction:grey_tap()]; | 315 performAction:grey_tap()]; |
263 } | 316 } |
264 // Check that the POST is changed to a GET | 317 // Check that the POST is changed to a GET |
265 [self waitForExpectedResponse:"GET"]; | 318 [self waitForExpectedResponse:"GET"]; |
266 } | 319 } |
267 | 320 |
268 // Tests that a POST followed by a redirect does not show the popup. | 321 // Tests that a POST followed by a redirect does not show the popup. |
269 - (void)testRepostFormCancellingAfterRedirect { | 322 - (void)testRepostFormCancellingAfterRedirect { |
270 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kRedirectFormUrl)]; | 323 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl( |
324 std::string(kHTTPScheme) + kRedirectFormPath)]; | |
271 // Submit the form, which redirects before printing the data. | 325 // Submit the form, which redirects before printing the data. |
272 [self submitForm]; | 326 [self submitForm]; |
273 // Check that the redirect changes the POST to a GET. | 327 // Check that the redirect changes the POST to a GET. |
274 [self waitForExpectedResponse:"GET"]; | 328 [self waitForExpectedResponse:"GET"]; |
275 [self reloadPage]; | 329 [self reloadPage]; |
276 | 330 |
277 // Check that the popup did not show | 331 // Check that the popup did not show |
278 id<GREYMatcher> resendWarning = | 332 id<GREYMatcher> resendWarning = |
279 chrome_test_util::ButtonWithAccessibilityLabelId( | 333 chrome_test_util::ButtonWithAccessibilityLabelId( |
280 IDS_HTTP_POST_WARNING_RESEND); | 334 IDS_HTTP_POST_WARNING_RESEND); |
281 [[EarlGrey selectElementWithMatcher:resendWarning] | 335 [[EarlGrey selectElementWithMatcher:resendWarning] |
282 assertWithMatcher:grey_nil()]; | 336 assertWithMatcher:grey_nil()]; |
283 | 337 |
284 [self waitForExpectedResponse:"GET"]; | 338 [self waitForExpectedResponse:"GET"]; |
285 } | 339 } |
286 | 340 |
287 @end | 341 @end |
OLD | NEW |