Commit b4383a79 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Only verify error code when link tapping fails.

The behavior of TapWebViewElementWithId() for links that close a
WebState is flaky on both simulator and device, regardless of whether
the Phase 1 UI Reboot flag is enabled.  This CL updates
FullscreenTestCase.testShowHeaderWhenChildTabCloses to check for the
error code only if the link tap is unsuccessful.

Note that the closure of the Tab and the visibility of the toolbar is
still verified after this occurs, so the test will still catch
fullscreen regressions after this change.

Bug: 812664
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ia56293763e185eeb615a5f734aa9a3a473f0b424
Reviewed-on: https://chromium-review.googlesource.com/974791
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545713}
parent 798a2135
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#import <EarlGrey/EarlGrey.h> #import <EarlGrey/EarlGrey.h>
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <WebKit/WebKit.h>
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
#include "base/ios/ios_util.h" #include "base/ios/ios_util.h"
...@@ -247,11 +248,6 @@ void AssertURLIs(const GURL& expectedURL) { ...@@ -247,11 +248,6 @@ void AssertURLIs(const GURL& expectedURL) {
// Test to make sure the header is shown when a Tab opened by the current Tab is // Test to make sure the header is shown when a Tab opened by the current Tab is
// closed even if the toolbar was not present previously. // closed even if the toolbar was not present previously.
- (void)testShowHeaderWhenChildTabCloses { - (void)testShowHeaderWhenChildTabCloses {
// TODO(crbug.com/812664): Re-enable this test on devices.
#if !TARGET_IPHONE_SIMULATOR
EARL_GREY_TEST_DISABLED(@"Test disabled on device.");
#endif
std::map<GURL, std::string> responses; std::map<GURL, std::string> responses;
const GURL URL = web::test::HttpServer::MakeUrl("http://origin"); const GURL URL = web::test::HttpServer::MakeUrl("http://origin");
const GURL destinationURL = const GURL destinationURL =
...@@ -297,22 +293,18 @@ void AssertURLIs(const GURL& expectedURL) { ...@@ -297,22 +293,18 @@ void AssertURLIs(const GURL& expectedURL) {
HideToolbarUsingUI(); HideToolbarUsingUI();
[ChromeEarlGreyUI waitForToolbarVisible:NO]; [ChromeEarlGreyUI waitForToolbarVisible:NO];
// Close the tab. // Close the tab by tapping link2.
NSError* error = nil; NSError* error = nil;
bool success = chrome_test_util::TapWebViewElementWithId("link2", &error); if (!chrome_test_util::TapWebViewElementWithId("link2", &error)) {
// Sometimes, the tap will be unsuccessful due to the window.close()
if (!web::GetWebClient()->IsSlimNavigationManagerEnabled()) { // operation invalidating the WKWebView. If this occurs, verify the error.
// The effect of clicking the link, closes the tab and invalidates the web // This results in |TapWebViewElementWithId| returning false.
// view. This results in |TapWebViewElementWithId| returning false. This // TODO(crbug.com/824879): Remove conditional once flake is eliminated from
// error is represented by code 3. WKBasedNavigationManager does not trigger // TapWebViewElementWithId() for window.close() links.
// any error. GREYAssert(error.code == WKErrorWebViewInvalidated,
GREYAssertFalse(success, @"Failed to tap \"link2\"");
GREYAssert(error.code == 3,
@"Failed to receive WKErrorWebViewInvalidated error"); @"Failed to receive WKErrorWebViewInvalidated error");
GREYAssert([error.domain isEqualToString:@"WKErrorDomain"], GREYAssert([error.domain isEqualToString:WKErrorDomain],
@"Failed to receive WKErrorDomain error"); @"Failed to receive WKErrorDomain error");
} else {
GREYAssert(success, @"Failed to tap \"link2\"");
} }
[ChromeEarlGrey waitForWebViewContainingText:"link1"]; [ChromeEarlGrey waitForWebViewContainingText:"link1"];
......
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