Commit e9c808f2 authored by Makoto Shimazu's avatar Makoto Shimazu Committed by Commit Bot

Revert "Enable ConsumeGestureOnNavigation by default"

This reverts commit 2ca250d4.

Reason for revert: A leak bot complains navigation-consumes-user-activation.tentative.sub.html is leaking.
Sample build:
https://uberchromegw.corp.google.com/i/chromium.webkit/builders/WebKit%20Linux%20Trusty%20Leak/builds/17509

Original change's description:
> Enable ConsumeGestureOnNavigation by default
> 
> See blink-dev thread:
> https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/kPli8ZCUeok
> 
> A browser test is moved to be a tentative WPT due to this change.
> 
> Bug: 772515
> Change-Id: Icf99c8c303c5055dcbcdace6ae94e3fcd1a01921
> Reviewed-on: https://chromium-review.googlesource.com/980599
> Reviewed-by: Nasko Oskov <nasko@chromium.org>
> Reviewed-by: Mustaq Ahmed <mustaq@chromium.org>
> Reviewed-by: Jonathon Kereliuk <kereliuk@chromium.org>
> Commit-Queue: Charlie Harrison <csharrison@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#549293}

TBR=nasko@chromium.org,mustaq@chromium.org,csharrison@chromium.org,kereliuk@chromium.org

Change-Id: I0c998798d1367be61c633db76429c18ac554e4ff
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 772515
Reviewed-on: https://chromium-review.googlesource.com/1003437Reviewed-by: default avatarMakoto Shimazu <shimazu@chromium.org>
Commit-Queue: Makoto Shimazu <shimazu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549363}
parent bb693e3c
...@@ -1041,6 +1041,8 @@ IN_PROC_BROWSER_TEST_F(ChromeNavigationBrowserTest, CrossSiteRedirectionToPDF) { ...@@ -1041,6 +1041,8 @@ IN_PROC_BROWSER_TEST_F(ChromeNavigationBrowserTest, CrossSiteRedirectionToPDF) {
->GetLastCommittedURL()); ->GetLastCommittedURL());
} }
// TODO(csharrison): These tests should become tentative WPT, once the feature
// is enabled by default.
class NavigationConsumingTest : public ChromeNavigationBrowserTest { class NavigationConsumingTest : public ChromeNavigationBrowserTest {
void SetUpCommandLine(base::CommandLine* cmd_line) override { void SetUpCommandLine(base::CommandLine* cmd_line) override {
ChromeNavigationBrowserTest::SetUpCommandLine(cmd_line); ChromeNavigationBrowserTest::SetUpCommandLine(cmd_line);
...@@ -1050,9 +1052,50 @@ class NavigationConsumingTest : public ChromeNavigationBrowserTest { ...@@ -1050,9 +1052,50 @@ class NavigationConsumingTest : public ChromeNavigationBrowserTest {
base::test::ScopedFeatureList scoped_feature_; base::test::ScopedFeatureList scoped_feature_;
}; };
// Checks that popups are successfully blocked if spawned after a navigation. // The fullscreen API is spec'd to require a user activation (aka user gesture),
// It is hard to convert this test to WPT because WPT don't use Chrome's popup // so use that API to test if navigation consumes the activation.
// blocker, since it is implemented in the //chrome layer. // https://fullscreen.spec.whatwg.org/#allowed-to-request-fullscreen
IN_PROC_BROWSER_TEST_F(NavigationConsumingTest,
NavigationConsumesUserGesture_Fullscreen) {
ui_test_utils::NavigateToURL(
browser(),
embedded_test_server()->GetURL("/navigation_consumes_gesture.html"));
content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents();
// Normally, fullscreen should work, as long as there is a user gesture.
bool is_fullscreen = false;
EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
contents, "document.body.webkitRequestFullscreen();", &is_fullscreen));
EXPECT_TRUE(is_fullscreen);
EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
contents, "document.webkitExitFullscreen();", &is_fullscreen));
EXPECT_FALSE(is_fullscreen);
EXPECT_TRUE(content::ExecuteScriptWithoutUserGestureAndExtractBool(
contents, "document.body.webkitRequestFullscreen();", &is_fullscreen));
EXPECT_FALSE(is_fullscreen);
// However, starting a navigation should consume the gesture. Fullscreen
// should not work afterwards. Make sure the navigation is synchronously
// started via click().
std::string script = R"(
document.getElementsByTagName('a')[0].click();
document.body.webkitRequestFullscreen();
)";
// Use the TestNavigationManager to ensure the navigation is not finished
// before fullscreen can occur.
content::TestNavigationManager nav_manager(
contents, embedded_test_server()->GetURL("/title1.html"));
EXPECT_TRUE(
content::ExecuteScriptAndExtractBool(contents, script, &is_fullscreen));
EXPECT_FALSE(is_fullscreen);
}
// Similar to the fullscreen test above, but checks that popups are successfully
// blocked if spawned after a navigation.
IN_PROC_BROWSER_TEST_F(NavigationConsumingTest, IN_PROC_BROWSER_TEST_F(NavigationConsumingTest,
NavigationConsumesUserGesture_Popups) { NavigationConsumesUserGesture_Popups) {
ui_test_utils::NavigateToURL(browser(), ui_test_utils::NavigateToURL(browser(),
......
...@@ -323,7 +323,7 @@ struct PendingNavigationParams { ...@@ -323,7 +323,7 @@ struct PendingNavigationParams {
namespace { namespace {
const base::Feature kConsumeGestureOnNavigation = { const base::Feature kConsumeGestureOnNavigation = {
"ConsumeGestureOnNavigation", base::FEATURE_ENABLED_BY_DEFAULT}; "ConsumeGestureOnNavigation", base::FEATURE_DISABLED_BY_DEFAULT};
const int kExtraCharsBeforeAndAfterSelection = 100; const int kExtraCharsBeforeAndAfterSelection = 100;
......
<!DOCTYPE html>
<meta charset="utf-8">
<title>Navigations consume user activation</title>
<a href="/">Home</a>
<button id="fullscreen">Click to fullscreen</button>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script>
var t = async_test("Navigations consume user activation");
// First, issue a fullscreen request without a navigation to consume the
// activation. Then when that test is complete, run another test that tries to
// synchronously navigate before issuing the fullscreen request. That navigation
// should consume the activation and prevent fullscreen from succeeding.
function doTest(withNavigation, callback) {
function doFullscreen() {
if (withNavigation)
document.getElementsByTagName("a")[0].click();
document.body.webkitRequestFullscreen();
}
let fullscreenButton = document.getElementById("fullscreen");
fullscreenButton.addEventListener("click", t.step_func(doFullscreen));
let stepChange = t.step_func(fullscreenChange);
document.addEventListener("webkitfullscreenchange", stepChange);
document.addEventListener("webkitfullscreenerror", stepChange);
function fullscreenChange() {
// Remove event listeners so exiting fullscreen doesn't mess with the test.
document.removeEventListener("webkitfullscreenchange", stepChange);
document.removeEventListener("webkitfullscreenerror", stepChange);
let isFullscreen = !!document.webkitFullscreenElement;
if (withNavigation) {
assert_false(isFullscreen, "Navigation should consume the gesture, and disallow fullscreen");
} else {
assert_true(isFullscreen, "Document should be fullscreened after a gesture");
document.webkitExitFullscreen();
}
callback();
};
test_driver.click(fullscreenButton);
}
doTest(false, t.step_func(function() {
doTest(true, t.step_func_done(function() {}));
}));
</script>
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