| Index: ios/chrome/browser/web/browsing_egtest.mm
|
| diff --git a/ios/chrome/browser/web/browsing_egtest.mm b/ios/chrome/browser/web/browsing_egtest.mm
|
| index ac51f9bc840fb67d3533341e4f40865f76fa4d99..e35c430cb8e001275071e6465290bf3e9e456777 100644
|
| --- a/ios/chrome/browser/web/browsing_egtest.mm
|
| +++ b/ios/chrome/browser/web/browsing_egtest.mm
|
| @@ -131,11 +131,6 @@ id<GREYMatcher> TabWithTitle(const std::string& tab_title) {
|
| notPartOfOmnibox, nil);
|
| }
|
|
|
| -// Matcher for a Go button that is interactable.
|
| -id<GREYMatcher> GoButtonMatcher() {
|
| - return grey_allOf(grey_accessibilityID(@"Go"), grey_interactable(), nil);
|
| -}
|
| -
|
| // Tests that page successfully reloads.
|
| - (void)testReload {
|
| // Set up test HTTP server responses.
|
| @@ -374,31 +369,11 @@ id<GREYMatcher> GoButtonMatcher() {
|
| [[EarlGrey selectElementWithMatcher:OmniboxText(destURL.GetContent())]
|
| assertWithMatcher:grey_notNil()];
|
|
|
| - [self goBack];
|
| + [ChromeEarlGrey goBack];
|
| [[EarlGrey selectElementWithMatcher:OmniboxText(URL.GetContent())]
|
| assertWithMatcher:grey_notNil()];
|
| }
|
|
|
| -// TODO(crbug.com/638674): Evaluate if this can move to shared code
|
| -// Navigates back to the previous webpage.
|
| -- (void)goBack {
|
| - GenericChromeCommand* backCommand =
|
| - [[GenericChromeCommand alloc] initWithTag:IDC_BACK];
|
| - chrome_test_util::RunCommandWithActiveViewController(backCommand);
|
| -
|
| - [ChromeEarlGrey waitForPageToFinishLoading];
|
| -}
|
| -
|
| -// Navigates forward to a previous webpage.
|
| -// TODO(crbug.com/638674): Evaluate if this can move to shared code
|
| -- (void)goForward {
|
| - GenericChromeCommand* forwardCommand =
|
| - [[GenericChromeCommand alloc] initWithTag:IDC_FORWARD];
|
| - chrome_test_util::RunCommandWithActiveViewController(forwardCommand);
|
| -
|
| - [ChromeEarlGrey waitForPageToFinishLoading];
|
| -}
|
| -
|
| // Tests that a link with WebUI URL does not trigger a load. WebUI pages may
|
| // have increased power and using the same web process (which may potentially
|
| // be controlled by an attacker) is dangerous.
|
| @@ -435,48 +410,6 @@ id<GREYMatcher> GoButtonMatcher() {
|
| chrome_test_util::AssertMainTabCount(1U);
|
| }
|
|
|
| -// Tests that pressing the button on a POST-based form with same-page action
|
| -// does not change the page and that the back button works as expected
|
| -// afterwards.
|
| -- (void)testBrowsingPostToSamePage {
|
| -// TODO(crbug.com/714303): Re-enable this test on devices.
|
| -#if !TARGET_IPHONE_SIMULATOR
|
| - EARL_GREY_TEST_DISABLED(@"Test disabled on device.");
|
| -#endif
|
| -
|
| - // Create map of canned responses and set up the test HTML server.
|
| - std::map<GURL, std::string> responses;
|
| - const GURL firstURL = web::test::HttpServer::MakeUrl("http://first");
|
| - const GURL formURL = web::test::HttpServer::MakeUrl("http://form");
|
| - // This is just a page with some text.
|
| - responses[firstURL] = "foo";
|
| - // This is a page with at button that posts to the current URL.
|
| - responses[formURL] =
|
| - "<form method='post'>"
|
| - "<input value='button' type='submit' id='button'></form>";
|
| - web::test::SetUpSimpleHttpServer(responses);
|
| -
|
| - // Open the first URL so it's in history.
|
| - [ChromeEarlGrey loadURL:firstURL];
|
| -
|
| - // Open the second URL, tap the button, and verify the browser navigates to
|
| - // the expected URL.
|
| - [ChromeEarlGrey loadURL:formURL];
|
| - chrome_test_util::TapWebViewElementWithId("button");
|
| - [[EarlGrey selectElementWithMatcher:OmniboxText(formURL.GetContent())]
|
| - assertWithMatcher:grey_notNil()];
|
| -
|
| - // Go back once and verify the browser navigates to the form URL.
|
| - [self goBack];
|
| - [[EarlGrey selectElementWithMatcher:OmniboxText(formURL.GetContent())]
|
| - assertWithMatcher:grey_notNil()];
|
| -
|
| - // Go back a second time and verify the browser navigates to the first URL.
|
| - [self goBack];
|
| - [[EarlGrey selectElementWithMatcher:OmniboxText(firstURL.GetContent())]
|
| - assertWithMatcher:grey_notNil()];
|
| -}
|
| -
|
| // Tests that evaluating user JavaScript that causes navigation correctly
|
| // modifies history.
|
| - (void)testBrowsingUserJavaScriptNavigation {
|
| @@ -509,7 +442,7 @@ id<GREYMatcher> GoButtonMatcher() {
|
| [[EarlGrey selectElementWithMatcher:OmniboxText(targetURL.GetContent())]
|
| assertWithMatcher:grey_notNil()];
|
|
|
| - [self goBack];
|
| + [ChromeEarlGrey goBack];
|
| [[EarlGrey selectElementWithMatcher:OmniboxText(startURL.GetContent())]
|
| assertWithMatcher:grey_notNil()];
|
| }
|
| @@ -544,108 +477,12 @@ id<GREYMatcher> GoButtonMatcher() {
|
|
|
| // Verify that the JavaScript did not affect history by going back and then
|
| // forward again.
|
| - [self goBack];
|
| + [ChromeEarlGrey goBack];
|
| [[EarlGrey selectElementWithMatcher:OmniboxText(firstURL.GetContent())]
|
| assertWithMatcher:grey_notNil()];
|
| - [self goForward];
|
| + [ChromeEarlGrey goForward];
|
| [[EarlGrey selectElementWithMatcher:OmniboxText(secondURL.GetContent())]
|
| assertWithMatcher:grey_notNil()];
|
| }
|
|
|
| -// Tap the text field indicated by |ID| to open the keyboard, and then
|
| -// press the keyboard's "Go" button to submit the form.
|
| -- (void)submitFormUsingKeyboardGoButtonWithInputID:(const std::string&)ID {
|
| - // Disable EarlGrey's synchronization since it is blocked by opening the
|
| - // keyboard from a web view.
|
| - [[GREYConfiguration sharedInstance]
|
| - setValue:@NO
|
| - forConfigKey:kGREYConfigKeySynchronizationEnabled];
|
| -
|
| - // Wait for web view to be interactable before tapping.
|
| - GREYCondition* interactableCondition = [GREYCondition
|
| - conditionWithName:@"Wait for web view to be interactable."
|
| - block:^BOOL {
|
| - NSError* error = nil;
|
| - id<GREYMatcher> webViewMatcher = WebViewInWebState(
|
| - chrome_test_util::GetCurrentWebState());
|
| - [[EarlGrey selectElementWithMatcher:webViewMatcher]
|
| - assertWithMatcher:grey_interactable()
|
| - error:&error];
|
| - return !error;
|
| - }];
|
| - GREYAssert(
|
| - [interactableCondition waitWithTimeout:testing::kWaitForUIElementTimeout],
|
| - @"Web view did not become interactable.");
|
| -
|
| - web::WebState* currentWebState = chrome_test_util::GetCurrentWebState();
|
| - [[EarlGrey selectElementWithMatcher:web::WebViewInWebState(currentWebState)]
|
| - performAction:web::WebViewTapElement(currentWebState, ID)];
|
| -
|
| - // Wait until the keyboard shows up before tapping.
|
| - GREYCondition* condition = [GREYCondition
|
| - conditionWithName:@"Wait for the keyboard to show up."
|
| - block:^BOOL {
|
| - NSError* error = nil;
|
| - [[EarlGrey selectElementWithMatcher:GoButtonMatcher()]
|
| - assertWithMatcher:grey_notNil()
|
| - error:&error];
|
| - return (error == nil);
|
| - }];
|
| - GREYAssert([condition waitWithTimeout:10],
|
| - @"No keyboard with 'Go' button showed up.");
|
| -
|
| - [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Go")]
|
| - performAction:grey_tap()];
|
| -
|
| - // Reenable synchronization now that the keyboard has been closed.
|
| - [[GREYConfiguration sharedInstance]
|
| - setValue:@YES
|
| - forConfigKey:kGREYConfigKeySynchronizationEnabled];
|
| -}
|
| -
|
| -// Tests that submitting a POST-based form by tapping the 'Go' button on the
|
| -// keyboard navigates to the correct URL and the back button works as expected
|
| -// afterwards.
|
| -// TODO(crbug.com/711108): Move test to forms_egtest.mm.
|
| -- (void)testBrowsingPostEntryWithKeyboard {
|
| -// TODO(crbug.com/704618): Re-enable this test on devices.
|
| -#if !TARGET_IPHONE_SIMULATOR
|
| - EARL_GREY_TEST_DISABLED(@"Test disabled on device.");
|
| -#endif
|
| -
|
| - // 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://postEntryWithKeyboard");
|
| - const GURL destinationURL = web::test::HttpServer::MakeUrl("http://foo");
|
| - // This is a page this an input text field and a button that posts to the
|
| - // destination.
|
| - responses[URL] = base::StringPrintf(
|
| - "hello!"
|
| - "<form action='%s' method='post'>"
|
| - "<input value='textfield' id='textfield' type='text'></label>"
|
| - "<input type='submit'></form>",
|
| - destinationURL.spec().c_str());
|
| - // This is the page that should be showing at the end of the test.
|
| - responses[destinationURL] = "baz!";
|
| - web::test::SetUpSimpleHttpServer(responses);
|
| -
|
| - // Open the URL, focus the textfield,and submit via keyboard.
|
| - [ChromeEarlGrey loadURL:URL];
|
| - [ChromeEarlGrey waitForWebViewContainingText:"hello!"];
|
| -
|
| - [self submitFormUsingKeyboardGoButtonWithInputID:"textfield"];
|
| -
|
| - // Verify that the browser navigates to the expected URL.
|
| - [ChromeEarlGrey waitForWebViewContainingText:"baz!"];
|
| - [[EarlGrey selectElementWithMatcher:OmniboxText(destinationURL.GetContent())]
|
| - assertWithMatcher:grey_notNil()];
|
| -
|
| - // Go back and verify that the browser navigates to the original URL.
|
| - [self goBack];
|
| - [ChromeEarlGrey waitForWebViewContainingText:"hello!"];
|
| - [[EarlGrey selectElementWithMatcher:OmniboxText(URL.GetContent())]
|
| - assertWithMatcher:grey_notNil()];
|
| -}
|
| -
|
| @end
|
|
|