Commit 164f2f6a authored by Lowell Manners's avatar Lowell Manners Committed by Commit Bot

Simplify ExtensionBrowserTest::NavigateInRenderer.

NavigateInRenderer was using a non-standard method of waiting for
navigations, (written in 2010). Now there is a much simpler way to
do this.

This cleanup has the pleasant side effect of fixing some test failures
when BackForwardCache is enabled.

Change-Id: I96b3d3d93fb9b58485cf0f7c7f33751a1abf55f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1813350
Commit-Queue: Lowell Manners <lowell@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarArthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699731}
parent 3f6cbe40
...@@ -723,22 +723,11 @@ void ExtensionBrowserTest::OpenWindow(content::WebContents* contents, ...@@ -723,22 +723,11 @@ void ExtensionBrowserTest::OpenWindow(content::WebContents* contents,
void ExtensionBrowserTest::NavigateInRenderer(content::WebContents* contents, void ExtensionBrowserTest::NavigateInRenderer(content::WebContents* contents,
const GURL& url) { const GURL& url) {
// Ensure any existing navigations complete before trying to navigate anew, to // Note: We use ExecuteScript instead of ExecJS here, because ExecuteScript
// avoid triggering of the unload event for the wrong navigation. // works on pages with a Content Security Policy.
EXPECT_TRUE(content::ExecuteScript(
contents, "window.location = '" + url.spec() + "';"));
content::WaitForLoadStop(contents); content::WaitForLoadStop(contents);
bool result = false;
content::WindowedNotificationObserver windowed_observer(
content::NOTIFICATION_LOAD_STOP,
content::NotificationService::AllSources());
ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
contents,
"window.addEventListener('unload', function() {"
" window.domAutomationController.send(true);"
"}, false);"
"window.location = '" + url.spec() + "';",
&result));
ASSERT_TRUE(result);
windowed_observer.Wait();
EXPECT_EQ(url, contents->GetController().GetLastCommittedEntry()->GetURL()); EXPECT_EQ(url, contents->GetController().GetLastCommittedEntry()->GetURL());
} }
......
# These tests currently fail when run with --enable-features=BackForwardCache # These tests currently fail when run with --enable-features=BackForwardCache
# Rely on an unload handler to run. It doesn't run.
-IsolatedAppTest.IsolatedAppProcessModel
# No focused view. # No focused view.
-PaymentRequestShippingAddressEditorTest.FocusFirstInvalidField_NotName -PaymentRequestShippingAddressEditorTest.FocusFirstInvalidField_NotName
......
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