| Index: ios/web/shell/test/page_state_egtest.mm
|
| diff --git a/ios/web/shell/test/page_state_egtest.mm b/ios/web/shell/test/page_state_egtest.mm
|
| index ab9a244f1f4bb00b8a0e0236bbf2bd8d9909064d..08ffddd7d41bd328d969c654925488669099ad98 100644
|
| --- a/ios/web/shell/test/page_state_egtest.mm
|
| +++ b/ios/web/shell/test/page_state_egtest.mm
|
| @@ -53,6 +53,17 @@ void WaitForOffset(CGFloat y_offset) {
|
| GREYAssert([condition waitWithTimeout:10], error_text);
|
| }
|
|
|
| +// Loads the long page at |url|, scrolls to the top, and waits for the offset to
|
| +// be {0, 0} before returning.
|
| +void ScrollLongPageToTop(const GURL& url) {
|
| + // Load the page and swipe down.
|
| + [ShellEarlGrey loadURL:url];
|
| + [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
|
| + performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];
|
| + // Waits for the {0, 0} offset.
|
| + WaitForOffset(0.0);
|
| +}
|
| +
|
| } // namespace
|
|
|
| using web::test::HttpServer;
|
| @@ -65,24 +76,18 @@ @implementation PageStateTestCase
|
|
|
| // Tests that page scroll position of a page is restored upon returning to the
|
| // page via the back/forward buttons.
|
| -// TODO(crbug.com/702410): This test flakily fails when it scrolls too far down
|
| -// the page.
|
| -- (void)FLAKY_testScrollPositionRestoring {
|
| +- (void)testScrollPositionRestoring {
|
| web::test::SetUpFileBasedHttpServer();
|
|
|
| - // Load first URL which is a long page.
|
| - [ShellEarlGrey loadURL:HttpServer::MakeUrl(kLongPage1)];
|
| -
|
| // Scroll the first page and verify the offset.
|
| + ScrollLongPageToTop(HttpServer::MakeUrl(kLongPage1));
|
| [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
|
| performAction:grey_scrollInDirection(kGREYDirectionDown, kOffset1)];
|
| [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
|
| assertWithMatcher:grey_scrollViewContentOffset(CGPointMake(0, kOffset1))];
|
|
|
| - // Load second URL, which is also a long page.
|
| - [ShellEarlGrey loadURL:HttpServer::MakeUrl(kLongPage2)];
|
| -
|
| // Scroll the second page and verify the offset.
|
| + ScrollLongPageToTop(HttpServer::MakeUrl(kLongPage2));
|
| [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
|
| performAction:grey_scrollInDirection(kGREYDirectionDown, kOffset2)];
|
| [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
|
|
|