Fix flaky test: NavigationRequestBrowserTest.BlockCredentialedSubresources
I can't really reproduce. However, I suspect the error was about bad
interactions in between previous and new navigations. Fix was to reload
the whole document everytime and wait for its iframe to be loaded before
going forward.
See previous error location:
https://ci.chromium.org/ui/p/chromium/builders/ci/linux-chromeos-rel/b8832425952522501681/overview
Bug:1262910
Fixed:1262910
Change-Id: I1332054e924183a92924e860ce4991ccdc832471
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3289137
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/main@{#944007}
diff --git a/content/browser/renderer_host/navigation_request_browsertest.cc b/content/browser/renderer_host/navigation_request_browsertest.cc
index 4b6d08ef..4e14e2b8 100644
--- a/content/browser/renderer_host/navigation_request_browsertest.cc
+++ b/content/browser/renderer_host/navigation_request_browsertest.cc
@@ -2278,9 +2278,8 @@
// Check that iframe with embedded credentials are blocked.
// See https://crbug.com/755892.
-// TODO(crbug.com/1262910): Enable the test again.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
- DISABLED_BlockCredentialedSubresources) {
+ BlockCredentialedSubresources) {
const struct {
GURL main_url;
GURL iframe_url;
@@ -2340,10 +2339,16 @@
GURL iframe_url_with_redirect = GURL(embedded_test_server()->GetURL(
"/server-redirect?" + iframe_url_final.spec()));
- ASSERT_TRUE(NavigateToURL(shell(), main_url));
-
// Blocking the request must work, even after a redirect.
for (bool redirect : {false, true}) {
+ ASSERT_TRUE(NavigateToURL(shell(), main_url));
+ EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
+ FrameTreeNode* root =
+ static_cast<WebContentsImpl*>(shell()->web_contents())
+ ->GetPrimaryFrameTree()
+ .root();
+ ASSERT_EQ(1u, root->child_count());
+
const GURL& iframe_url =
redirect ? iframe_url_with_redirect : iframe_url_final;
SCOPED_TRACE(::testing::Message()
@@ -2358,12 +2363,8 @@
NavigationThrottle::PROCEED);
NavigateIframeToURL(shell()->web_contents(), "child0", iframe_url);
+ EXPECT_EQ(1, installer.install_count());
- FrameTreeNode* root =
- static_cast<WebContentsImpl*>(shell()->web_contents())
- ->GetPrimaryFrameTree()
- .root();
- ASSERT_EQ(1u, root->child_count());
if (test_case.blocked) {
EXPECT_EQ(redirect, !!installer.will_start_called());
EXPECT_FALSE(installer.will_process_called());