Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5816)

Unified Diff: chrome/browser/net/ftp_browsertest.cc

Issue 2641173005: Fix flaky FtpBrowserTest.DirectoryListingNavigation (Closed)
Patch Set: fix Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/ftp_browsertest.cc
diff --git a/chrome/browser/net/ftp_browsertest.cc b/chrome/browser/net/ftp_browsertest.cc
index 2037826604f5fd41aef0844b8fbccd8fb5134511..8137eb59037640bf28f100dc1ae387528b1c2f5b 100644
--- a/chrome/browser/net/ftp_browsertest.cc
+++ b/chrome/browser/net/ftp_browsertest.cc
@@ -46,13 +46,7 @@ IN_PROC_BROWSER_TEST_F(FtpBrowserTest, BasicFtpUrlAuthentication) {
"Index of /");
}
-// http://crbug.com/521409
-#if defined(OS_WIN)
-#define MAYBE_DirectoryListingNavigation DISABLED_DirectoryListingNavigation
-#else
-#define MAYBE_DirectoryListingNavigation DirectoryListingNavigation
-#endif
-IN_PROC_BROWSER_TEST_F(FtpBrowserTest, MAYBE_DirectoryListingNavigation) {
+IN_PROC_BROWSER_TEST_F(FtpBrowserTest, DirectoryListingNavigation) {
ftp_server_.set_no_anonymous_ftp_user(true);
ASSERT_TRUE(ftp_server_.Start());
@@ -63,24 +57,40 @@ IN_PROC_BROWSER_TEST_F(FtpBrowserTest, MAYBE_DirectoryListingNavigation) {
// Navigate to directory dir1/ without needing to re-authenticate
EXPECT_TRUE(content::ExecuteScript(
browser()->tab_strip_model()->GetActiveWebContents(),
- "var elements = document.getElementsByTagName('a');"
- "for (var i = 0; i < elements.length; i++) {"
- " if (elements[i].innerHTML == 'dir1/') {"
- " elements[i].click();"
+ "(function() {"
+ " function navigate() {"
+ " for (const element of document.getElementsByTagName('a')) {"
+ " if (element.innerHTML == 'dir1/') {"
+ " element.click();"
+ " }"
+ " }"
" }"
- "}"));
+ " if (document.readyState === 'loading') {"
+ " document.addEventListener('DOMContentLoaded', navigate);"
+ " } else {"
+ " navigate();"
+ " }"
+ "})()"));
WaitForTitle(browser()->tab_strip_model()->GetActiveWebContents(),
"Index of /dir1/");
EXPECT_TRUE(content::ExecuteScript(
- browser()->tab_strip_model()->GetActiveWebContents(),
- "var elements = document.getElementsByTagName('a');"
- "for (var i = 0; i < elements.length; i++) {"
- " if (elements[i].innerHTML == 'test.html') {"
- " elements[i].click();"
- " }"
- "}"));
+ browser()->tab_strip_model()->GetActiveWebContents(),
+ "(function() {"
+ " function navigate() {"
+ " for (const element of document.getElementsByTagName('a')) {"
+ " if (element.innerHTML == 'test.html') {"
+ " element.click();"
+ " }"
+ " }"
+ " }"
+ " if (document.readyState === 'loading') {"
+ " document.addEventListener('DOMContentLoaded', navigate);"
+ " } else {"
+ " navigate();"
+ " }"
+ "})()"));
WaitForTitle(browser()->tab_strip_model()->GetActiveWebContents(),
"PASS");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698