Commit 76ca4e08 authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Only allow one full screen per user activation - experimental

When the user activation state is active, we should only allow one full
screen. This is a simply change to do an experiment to see if any
web page breaks.

Intent to ship link is
https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/Y58tbs-TSgE

Bug: 852645
Change-Id: Iebef20ba197ecd09e7067986073999e334b07498
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1594805Reviewed-by: default avatarMustaq Ahmed <mustaq@chromium.org>
Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Commit-Queue: Lan Wei <lanwei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664292}
parent 5dd599eb
......@@ -225,7 +225,9 @@ bool AllowedToRequestFullscreen(Document& document) {
// true:
// The algorithm is triggered by a user activation.
if (LocalFrame::HasTransientUserActivation(document.GetFrame()))
// We are doing experiment to see if there is any webpage breaking after we
// only allow one fullscreen when the user activation state is active.
if (LocalFrame::ConsumeTransientUserActivation(document.GetFrame()))
return true;
// The algorithm is triggered by a user generated orientation change.
......
......@@ -4304,6 +4304,11 @@ crbug.com/877296 external/wpt/wasm/serialization/module/window-serviceworker-fai
crbug.com/831509 external/wpt/service-workers/service-worker/skip-waiting-installed.https.html [ Failure Pass ]
crbug.com/831509 virtual/navigation-mojo-response/external/wpt/service-workers/service-worker/skip-waiting-installed.https.html [ Failure Pass ]
# Fullscreen tests are failed because of consuming user activation on fullscreen
crbug.com/852645 external/wpt/fullscreen/api/element-request-fullscreen-twice-manual.html [ Failure ]
crbug.com/852645 external/wpt/fullscreen/api/element-request-fullscreen-two-elements-manual.html [ Failure ]
crbug.com/852645 external/wpt/fullscreen/api/element-request-fullscreen-two-iframes-manual.html [ Failure Timeout ]
# Sheriff failures 2017-02-21
crbug.com/73609 http/tests/media/video-play-stall.html [ Pass Timeout ]
......@@ -4353,6 +4358,8 @@ crbug.com/718155 media/video-controls-fullscreen-iframe-not-allowed.html [ Failu
crbug.com/718155 virtual/android/fullscreen/full-screen-iframe-not-allowed.html [ Failure ]
crbug.com/718155 virtual/android/fullscreen/full-screen-restrictions.html [ Failure Timeout ]
crbug.com/852645 gamepad/full-screen-gamepad.html [ Timeout ]
# Feature Policy changes same-origin allowpaymentrequest behaviour, tests need updating
crbug.com/718155 payments/payment-request-in-iframe.html [ Failure ]
crbug.com/718155 payments/payment-request-in-iframe-nested-not-allowed.html [ Failure ]
......
<!DOCTYPE html>
<!--
Tentative due to:
https://github.com/whatwg/fullscreen/issues/152
-->
<title>Element#requestFullscreen() twice</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../trusted-click.js"></script>
<div id="log"></div>
<script>
promise_test(async (test) => {
const div = document.querySelector("div");
const fullscreenChangePromise = new Promise((resolve, reject) => {
document.onfullscreenchange = test.step_func(() => {
assert_equals(document.fullscreenElement, div);
// Ensure that there's only one fullscreenchange event.
document.onfullscreenchange = test.unreached_func("second fullscreenchange event");
resolve();
});
});
const fullscreenErrorPromise = new Promise((resolve, reject) => {
document.onfullscreenerror = test.step_func(() => {
resolve();
});
});
trusted_click(test, () => {
// Request fullscreen twice.
div.requestFullscreen();
assert_equals(document.fullscreenElement, null, "fullscreenElement after first requestFullscreen()");
var p = div.requestFullscreen();
if (p) {
p.then(test.unreached_func("promise unexpectedly resolved"), ()=>{});
}
}, document.body);
await Promise.all([
fullscreenChangePromise,
fullscreenErrorPromise,
]);
});
</script>
<!DOCTYPE html>
<!--
Tentative due to:
https://github.com/whatwg/fullscreen/issues/152
-->
<title>Element#requestFullscreen() on two elements in the same document</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../trusted-click.js"></script>
<div id="log"></div>
<div id="a"></div>
<div id="b"></div>
<script>
promise_test(async (test) => {
// Request fullscreen on both elements, but in reverse tree order.
const a = document.getElementById('a');
const b = document.getElementById('b');
// Expect two fullscreenchange events, with document.fullscreenElement
// changing in the same order as the requests.
const order = [];
const fullscreenChangePromise = new Promise((resolve, reject) => {
document.onfullscreenchange = test.step_func(() => {
assert_in_array(document.fullscreenElement, [a, b]);
order.push(document.fullscreenElement.id);
if (order.length == 2) {
// Since fullscreenchange event occurs at animation frame timing we might
// have not seen the transition from null -> 'b' but just see the
// resulting 'a' transition twice.
assert_true(order[0] == 'a' || order[0] == 'b', 'first id seen is a or b');
assert_true(order[1] == 'a', 'second id seen is b');
}
resolve();
});
});
const fullscreenErrorPromise = new Promise((resolve, reject) => {
document.onfullscreenerror = test.step_func(() => {
resolve();
});
});
trusted_click(test, () => {
b.requestFullscreen();
var p = a.requestFullscreen();
if (p) {
p.then(test.unreached_func("promise unexpectedly resolved"), ()=>{});
}
}, document.body);
await Promise.all([
fullscreenChangePromise,
fullscreenErrorPromise,
]);
});
</script>
<!DOCTYPE html>
<!--
Tentative due to:
https://github.com/whatwg/fullscreen/issues/152
-->
<title>Element#requestFullscreen() on two elements in different iframes</title>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../trusted-click.js"></script>
<div id="log"></div>
<iframe id="a" allowfullscreen></iframe>
<iframe id="b" allowfullscreen></iframe>
<script>
promise_test(async (test) => {
// Request fullscreen on the body elements of both iframes, but in reverse
// tree order.
const a = document.getElementById('a');
const b = document.getElementById('b');
var rejected = false;
// Expect two fullscreenchange events, with document.fullscreenElement
// changing in the same order as the requests. (Events should also fire on the
// iframes' documents, but this is not covered by this test.)
const order = [];
const fullscreenChangePromise = new Promise((resolve, reject) => {
document.onfullscreenchange = test.step_func(() => {
assert_in_array(document.fullscreenElement, [a, b]);
order.push(document.fullscreenElement.id);
if (order.length == 2) {
// When the second event arrived, the fullscreen element may still be the
// old one.
//
// TODO(mustaq): We need a better explanation here to cover the tree-order
// idea of the spec.
assert_true(order[0] == 'a' || order[0] == 'b', 'first id seen is a or b');
assert_true(order[1] == 'a', 'second id seen is a');
}
resolve();
});
});
const fullscreenErrorPromise = new Promise((resolve, reject) => {
document.onfullscreenerror = test.step_func(() => {
resolve();
});
});
// Make a trusted click on frame 'b' to activate it.
trusted_click(test, () => {
// Now queue a trusted click on frame 'a' to make back-to-back calls.
setTimeout(() => {
trusted_click(test, () => {
b.contentDocument.body.requestFullscreen();
a.contentDocument.body.requestFullscreen().catch(test.step_func_done());
}, a.contentDocument.body);
}, 0);
}, b.contentDocument.body);
await Promise.all([
fullscreenChangePromise,
fullscreenErrorPromise,
]);
});
</script>
CONSOLE WARNING: line 45: Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture.
CONSOLE ERROR: line 45: Uncaught (in promise) TypeError: fullscreen error
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = fullscreen error
FAIL Document#exitFullscreen() vs. Element#requestFullscreen() assert_unreached: fullscreenerror event Reached unreachable code
Harness: the test ran to completion.
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