Commit ceb117a6 authored by Danyao Wang's avatar Danyao Wang Committed by Commit Bot

[Nav Experiment] Update FormsTestCase setup for WKBasedNavigationManger.

These tests currently assume that the repost confirmation dialog is
shown on back/forward navigation. This is not true for
WKBasedNavigationManager because it matches WKWebView behavior, which
uses back/forward cache for back/forward navigation. This CL adds
|reload| to explicitly trigger the repost confirmation dialog.

Bug: 874635
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I24dafdd02014184f3fbc5b86f1026ebe8f5f00c7
Reviewed-on: https://chromium-review.googlesource.com/1243323
Commit-Queue: Danyao Wang <danyao@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593965}
parent a9dc0da4
...@@ -250,6 +250,15 @@ id<GREYMatcher> ResendPostButtonMatcher() { ...@@ -250,6 +250,15 @@ id<GREYMatcher> ResendPostButtonMatcher() {
// Go to a new page and go back and check that the data is reposted. // Go to a new page and go back and check that the data is reposted.
[ChromeEarlGrey loadURL:GetGenericUrl()]; [ChromeEarlGrey loadURL:GetGenericUrl()];
[ChromeEarlGrey goBack]; [ChromeEarlGrey goBack];
// WKBasedNavigationManager doesn't triggere repost on |goForward| due to
// WKWebView's back-forward cache. Force reload to trigger repost. Not using
// [ChromeEarlGrey reload] because WKBasedNavigationManager presents repost
// confirmation dialog before loading stops.
if (web::GetWebClient()->IsSlimNavigationManagerEnabled()) {
[chrome_test_util::BrowserCommandDispatcherForMainBVC() reload];
}
[self confirmResendWarning]; [self confirmResendWarning];
[ChromeEarlGrey waitForWebViewContainingText:kDestinationText]; [ChromeEarlGrey waitForWebViewContainingText:kDestinationText];
[[EarlGrey selectElementWithMatcher:OmniboxText(destinationURL.GetContent())] [[EarlGrey selectElementWithMatcher:OmniboxText(destinationURL.GetContent())]
...@@ -271,6 +280,15 @@ id<GREYMatcher> ResendPostButtonMatcher() { ...@@ -271,6 +280,15 @@ id<GREYMatcher> ResendPostButtonMatcher() {
[ChromeEarlGrey goBack]; [ChromeEarlGrey goBack];
[ChromeEarlGrey goForward]; [ChromeEarlGrey goForward];
// WKBasedNavigationManager doesn't triggere repost on |goForward| due to
// WKWebView's back-forward cache. Force reload to trigger repost. Not using
// [ChromeEarlGrey reload] because WKBasedNavigationManager presents repost
// confirmation dialog before loading stops.
if (web::GetWebClient()->IsSlimNavigationManagerEnabled()) {
[chrome_test_util::BrowserCommandDispatcherForMainBVC() reload];
}
[self confirmResendWarning]; [self confirmResendWarning];
[ChromeEarlGrey waitForWebViewContainingText:kDestinationText]; [ChromeEarlGrey waitForWebViewContainingText:kDestinationText];
[[EarlGrey selectElementWithMatcher:OmniboxText(destinationURL.GetContent())] [[EarlGrey selectElementWithMatcher:OmniboxText(destinationURL.GetContent())]
...@@ -325,16 +343,38 @@ id<GREYMatcher> ResendPostButtonMatcher() { ...@@ -325,16 +343,38 @@ id<GREYMatcher> ResendPostButtonMatcher() {
[ChromeEarlGrey goBack]; [ChromeEarlGrey goBack];
[ChromeEarlGrey goForward]; [ChromeEarlGrey goForward];
// WKBasedNavigationManager doesn't triggere repost on |goForward| due to
// WKWebView's back-forward cache. Force reload to trigger repost. Not using
// [ChromeEarlGrey reload] because WKBasedNavigationManager presents repost
// confirmation dialog before loading stops.
if (web::GetWebClient()->IsSlimNavigationManagerEnabled()) {
[chrome_test_util::BrowserCommandDispatcherForMainBVC() reload];
}
[[EarlGrey selectElementWithMatcher:ElementToDismissAlert(@"Cancel")] [[EarlGrey selectElementWithMatcher:ElementToDismissAlert(@"Cancel")]
performAction:grey_tap()]; performAction:grey_tap()];
[ChromeEarlGrey waitForPageToFinishLoading]; [ChromeEarlGrey waitForPageToFinishLoading];
// Verify that navigation was cancelled, and forward navigation is possible. // Expected behavior is different between the two navigation manager
[ChromeEarlGrey waitForWebViewContainingText:kSubmitButtonLabel]; // implementations.
[[EarlGrey selectElementWithMatcher:OmniboxText(GetFormUrl().GetContent())] if (!web::GetWebClient()->IsSlimNavigationManagerEnabled()) {
assertWithMatcher:grey_notNil()]; // LegacyNavigationManager displays repost on |goBack|. So after cancelling,
[[EarlGrey selectElementWithMatcher:chrome_test_util::ForwardButton()] // web view should show form URL.
assertWithMatcher:grey_interactable()]; [ChromeEarlGrey waitForWebViewContainingText:kSubmitButtonLabel];
[[EarlGrey selectElementWithMatcher:OmniboxText(GetFormUrl().GetContent())]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::ForwardButton()]
assertWithMatcher:grey_interactable()];
} else {
// WKBasedNavigationManager displays repost on |reload|. So after
// cancelling, web view should show |destinationURL|.
[ChromeEarlGrey waitForWebViewContainingText:kDestinationText];
[[EarlGrey
selectElementWithMatcher:OmniboxText(destinationURL.GetContent())]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::BackButton()]
assertWithMatcher:grey_interactable()];
}
} }
// A new navigation dismisses the repost dialog. // A new navigation dismisses the repost dialog.
......
...@@ -4358,6 +4358,7 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -4358,6 +4358,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
decisionHandler(WKNavigationActionPolicyCancel); decisionHandler(WKNavigationActionPolicyCancel);
if (action.targetFrame.mainFrame) { if (action.targetFrame.mainFrame) {
[_pendingNavigationInfo setCancelled:YES]; [_pendingNavigationInfo setCancelled:YES];
_webStateImpl->SetIsLoading(false);
} }
} }
})); }));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment