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