Commit 9a1a151b authored by Karan Bhatia's avatar Karan Bhatia Committed by Commit Bot

(Hopefully) Fix flaky ChromeNavigationBrowserTest.RedirectErrorPageReloadToAboutBlank.

This CL tries to deflake
ChromeNavigationBrowserTest.RedirectErrorPageReloadToAboutBlank. The
theory is that the extension web request listeners aren't getting set up
by the time the page is reloaded, hence the redirect is not happening.
Fix by waiting for an ack from the extension background page.

BUG=981295

Change-Id: If1171578dcbf248b910cbb6f774491ccb348f2ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2056942Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Karan Bhatia <karandeepb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743241}
parent 5572e025
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include "content/public/test/navigation_handle_observer.h" #include "content/public/test/navigation_handle_observer.h"
#include "content/public/test/test_navigation_observer.h" #include "content/public/test/test_navigation_observer.h"
#include "content/public/test/url_loader_interceptor.h" #include "content/public/test/url_loader_interceptor.h"
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/test_extension_dir.h" #include "extensions/test/test_extension_dir.h"
#include "google_apis/gaia/gaia_switches.h" #include "google_apis/gaia/gaia_switches.h"
#include "net/dns/mock_host_resolver.h" #include "net/dns/mock_host_resolver.h"
...@@ -613,16 +614,8 @@ IN_PROC_BROWSER_TEST_F(ChromeNavigationBrowserTest, ...@@ -613,16 +614,8 @@ IN_PROC_BROWSER_TEST_F(ChromeNavigationBrowserTest,
// Test for https://crbug.com/866549#c2. It verifies that about:blank does not // Test for https://crbug.com/866549#c2. It verifies that about:blank does not
// commit in the error page process when it is redirected to. // commit in the error page process when it is redirected to.
// Flaky on Linux. See https://crbug.com/981295.
#if defined(OS_LINUX)
#define MAYBE_RedirectErrorPageReloadToAboutBlank \
DISABLED_RedirectErrorPageReloadToAboutBlank
#else
#define MAYBE_RedirectErrorPageReloadToAboutBlank \
RedirectErrorPageReloadToAboutBlank
#endif
IN_PROC_BROWSER_TEST_F(ChromeNavigationBrowserTest, IN_PROC_BROWSER_TEST_F(ChromeNavigationBrowserTest,
MAYBE_RedirectErrorPageReloadToAboutBlank) { RedirectErrorPageReloadToAboutBlank) {
content::WebContents* web_contents = content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
GURL url(embedded_test_server()->GetURL("a.com", "/title1.html")); GURL url(embedded_test_server()->GetURL("a.com", "/title1.html"));
...@@ -658,10 +651,16 @@ IN_PROC_BROWSER_TEST_F(ChromeNavigationBrowserTest, ...@@ -658,10 +651,16 @@ IN_PROC_BROWSER_TEST_F(ChromeNavigationBrowserTest,
console.log("onBeforeRequest: ", d); console.log("onBeforeRequest: ", d);
return {redirectUrl:"about:blank"}; return {redirectUrl:"about:blank"};
}, {urls: ["*://a.com/*"]}, ["blocking"]); }, {urls: ["*://a.com/*"]}, ["blocking"]);
chrome.test.sendMessage('ready');
)"); )");
ExtensionTestMessageListener ready_listener("ready", false /* will_reply */);
extensions::ChromeTestExtensionLoader extension_loader(browser()->profile()); extensions::ChromeTestExtensionLoader extension_loader(browser()->profile());
extension_loader.LoadExtension(test_extension_dir.UnpackedPath()); extension_loader.LoadExtension(test_extension_dir.UnpackedPath());
// Wait for the background page to load.
ASSERT_TRUE(ready_listener.WaitUntilSatisfied());
// Remove the interceptor to allow a reload to succeed, which the extension // Remove the interceptor to allow a reload to succeed, which the extension
// will intercept and redirect. The navigation should complete successfully // will intercept and redirect. The navigation should complete successfully
// and commit in a process that is different than the error page one. // and commit in a process that is different than the error page one.
......
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