Commit 3f17cd3c authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Chromium LUCI CQ

[iOS] Fix the failing back/forward tests

Tests with back/forward navigations including an error page from the
same host are failing with the new error page workflow.
This CL is fixing them and adding todo to revist once WebKit has
shipped.

Bug: 1153261
Change-Id: I7160431842511b67f9605929318968d6b2eac49e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2565238
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Commit-Queue: Ali Juma <ajuma@chromium.org>
Reviewed-by: default avatarAli Juma <ajuma@chromium.org>
Auto-Submit: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#831888}
parent 1d2aa44d
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#import "base/test/ios/wait_util.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h" #include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/safe_browsing/core/features.h" #include "components/safe_browsing/core/features.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
...@@ -436,10 +437,16 @@ std::unique_ptr<net::test_server::HttpResponse> HandleRequest( ...@@ -436,10 +437,16 @@ std::unique_ptr<net::test_server::HttpResponse> HandleRequest(
[ChromeEarlGrey loadURL:_safeURL2]; [ChromeEarlGrey loadURL:_safeURL2];
[ChromeEarlGrey waitForWebStateContainingText:_safeContent2]; [ChromeEarlGrey waitForWebStateContainingText:_safeContent2];
// TODO(crbug.com/1153261): Adding a delay to avoid never-ending load on the
// last navigation forward. Should be fixed in newer iOS version.
base::test::ios::SpinRunLoopWithMinDelay(base::TimeDelta::FromSecondsD(1));
[ChromeEarlGrey goBack]; [ChromeEarlGrey goBack];
[ChromeEarlGrey waitForWebStateContainingText:l10n_util::GetStringUTF8( [ChromeEarlGrey waitForWebStateContainingText:l10n_util::GetStringUTF8(
IDS_MALWARE_V3_HEADING)]; IDS_MALWARE_V3_HEADING)];
// TODO(crbug.com/1153261): Adding a delay to avoid never-ending load on the
// last navigation forward. Should be fixed in newer iOS version.
base::test::ios::SpinRunLoopWithMinDelay(base::TimeDelta::FromSecondsD(1));
[ChromeEarlGrey goForward]; [ChromeEarlGrey goForward];
[ChromeEarlGrey waitForWebStateContainingText:_safeContent2]; [ChromeEarlGrey waitForWebStateContainingText:_safeContent2];
......
...@@ -69,7 +69,8 @@ std::string GetErrorMessage() { ...@@ -69,7 +69,8 @@ std::string GetErrorMessage() {
// Tests that the error page is correctly displayed after navigating back to it // Tests that the error page is correctly displayed after navigating back to it
// multiple times. See http://crbug.com/944037 . // multiple times. See http://crbug.com/944037 .
- (void)testBackForwardErrorPage { - (void)testBackForwardErrorPage {
// Using ERR_CONNECTION_CLOSED doesn't work. // TODO(crbug.com/1153261): Going back/forward on the same host is failing.
// Use chrome:// to have a different hosts.
std::string errorText = net::ErrorToShortString(net::ERR_INVALID_URL); std::string errorText = net::ErrorToShortString(net::ERR_INVALID_URL);
self.serverRespondsWithContent = YES; self.serverRespondsWithContent = YES;
......
...@@ -168,9 +168,12 @@ class ErrorPageTest : public WebTestWithWebState { ...@@ -168,9 +168,12 @@ class ErrorPageTest : public WebTestWithWebState {
#endif #endif
TEST_F(ErrorPageTest, MAYBE_BackForwardErrorPage) { TEST_F(ErrorPageTest, MAYBE_BackForwardErrorPage) {
if (base::FeatureList::IsEnabled(features::kUseJSForErrorPage)) { if (base::FeatureList::IsEnabled(features::kUseJSForErrorPage)) {
// TODO(crbug.com/1151938): Check if the test can be re-enabled with higher // TODO(crbug.com/1153261): this test should be fixed in newer versions of
// version of WebKit. // WebKit.
return; if (@available(iOS 14.4, *)) {
} else {
return;
}
} }
test::LoadUrl(web_state(), server_.GetURL("/close-socket")); test::LoadUrl(web_state(), server_.GetURL("/close-socket"));
ASSERT_TRUE(WaitForErrorText(web_state(), server_.GetURL("/close-socket"))); ASSERT_TRUE(WaitForErrorText(web_state(), server_.GetURL("/close-socket")));
......
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