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