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

Unified Diff: ios/chrome/browser/web/forms_egtest.mm

Issue 2806743004: Fixing testBrowsingPostEntryWithButton flakiness. (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/web/forms_egtest.mm
diff --git a/ios/chrome/browser/web/forms_egtest.mm b/ios/chrome/browser/web/forms_egtest.mm
index 2210492ffa19019a3b7cd16d853daf33248f394a..0387d378297af4e69bc6f17078bca983df645b99 100644
--- a/ios/chrome/browser/web/forms_egtest.mm
+++ b/ios/chrome/browser/web/forms_egtest.mm
@@ -346,4 +346,31 @@ - (void)testRepostFormCancellingAfterRedirect {
[self waitForExpectedResponse:"GET"];
}
+// Tests that pressing the button on a POST-based form changes the page and that
+// the back button works as expected afterwards.
+- (void)testGoBackButtonAfterFormSubmission {
+ // Create map of canned responses and set up the test HTML server.
+ std::map<GURL, std::string> responses;
+ const GURL URL = web::test::HttpServer::MakeUrl("http://postEntryWithButton");
+ const GURL destinationURL = web::test::HttpServer::MakeUrl("http://foo");
+ // This is a page with a button that posts to the destination.
+ responses[URL] = base::StringPrintf(
+ "<form action='%s' method='post'>"
+ "<input value='button' type='submit' id='button'></form>",
+ destinationURL.spec().c_str());
+ // This is the page that should be showing at the end of the test.
+ responses[destinationURL] = "bar!";
+ web::test::SetUpSimpleHttpServer(responses);
+
+ [ChromeEarlGrey loadURL:URL];
+ chrome_test_util::TapWebViewElementWithId("button");
+ [ChromeEarlGrey
+ waitForOmniboxText:base::SysUTF8ToNSString(destinationURL.GetContent())];
Eugene But (OOO till 7-30) 2017/04/08 00:16:27 Should |waitForOmniboxText:| take std::string inst
liaoyuke 2017/04/08 00:43:07 Yeah, I thought about that, but I went with NSStri
Eugene But (OOO till 7-30) 2017/04/08 00:55:09 Should we lean towards API convenience rather that
+
+ // Go back and verify the browser navigates to the original URL.
+ [self goBack];
+ [[EarlGrey selectElementWithMatcher:OmniboxText(URL.GetContent())]
+ assertWithMatcher:grey_notNil()];
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698