Commit efa963a8 authored by Mustaq Ahmed's avatar Mustaq Ahmed Committed by Commit Bot

Skip user gesture creation during RenderFrameImpl navigation commit.

|RenderFrameImpl::CommitNavigation*| functions got |WebScopedUserGesture|s few
years ago to fix a PasswordManager test (crrev.com/2378393002).  Those artificial
user gesture tokens seem to have become redundant in the meantime through changes
in navigation and/or PasswordManager.  This CL removes those tokens because they
are causing popup-blocker failure with UAv2.

Bug: 865243
Change-Id: I6ed7d73a5784f82ce3ba695067a4cbff0a9c24b4
Reviewed-on: https://chromium-review.googlesource.com/c/1323626
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarCamille Lamy <clamy@chromium.org>
Reviewed-by: default avatarCharlie Harrison <csharrison@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607233}
parent 2abc21e5
......@@ -940,6 +940,34 @@ IN_PROC_BROWSER_TEST_F(ChromeNavigationBrowserTest, CrossSiteRedirectionToPDF) {
->GetLastCommittedURL());
}
// Check that clicking on a link doesn't carry the transient user activation
// from the original page to the navigated page (crbug.com/865243).
IN_PROC_BROWSER_TEST_F(ChromeNavigationBrowserTest,
WindowOpenBlockedAfterClickNavigation) {
// Navigate to a test page with links.
ui_test_utils::NavigateToURL(browser(),
embedded_test_server()->GetURL("/links.html"));
// Click to navigate to title1.html.
content::WebContents* main_contents =
browser()->tab_strip_model()->GetActiveWebContents();
content::TestNavigationObserver observer(main_contents);
ASSERT_TRUE(ExecuteScript(main_contents,
"document.getElementById('title1').click();"));
observer.Wait();
// Make sure popup attempt fails due to lack of transient user activation.
bool opened = false;
EXPECT_TRUE(content::ExecuteScriptWithoutUserGestureAndExtractBool(
main_contents, "window.domAutomationController.send(!!window.open());",
&opened));
EXPECT_FALSE(opened);
EXPECT_EQ(embedded_test_server()->GetURL("/title1.html"),
main_contents->GetLastCommittedURL());
EXPECT_EQ(1, browser()->tab_strip_model()->count());
}
// TODO(csharrison): These tests should become tentative WPT, once the feature
// is enabled by default.
using NavigationConsumingTest = ChromeNavigationBrowserTest;
......
......@@ -3238,12 +3238,6 @@ void RenderFrameImpl::CommitNavigation(
return;
}
// If the request was initiated in the context of a user gesture then make
// sure that the navigation also executes in the context of a user gesture.
std::unique_ptr<blink::WebScopedUserGesture> gesture(
common_params.has_user_gesture ? new blink::WebScopedUserGesture(frame_)
: nullptr);
// Sanity check that the browser always sends us new loader factories on
// cross-document navigations with the Network Service enabled.
DCHECK(common_params.url.SchemeIs(url::kJavaScriptScheme) ||
......@@ -3504,12 +3498,6 @@ void RenderFrameImpl::CommitSameDocumentNavigation(
DCHECK(!request_params.is_view_source);
DCHECK(FrameMsg_Navigate_Type::IsSameDocument(common_params.navigation_type));
// If the request was initiated in the context of a user gesture then make
// sure that the navigation also executes in the context of a user gesture.
std::unique_ptr<blink::WebScopedUserGesture> gesture(
common_params.has_user_gesture ? new blink::WebScopedUserGesture(frame_)
: nullptr);
PrepareFrameForCommit(common_params.url, request_params);
blink::WebFrameLoadType load_type = NavigationTypeToLoadType(
......
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