Commit b8d5524a authored by philipj@opera.com's avatar philipj@opera.com

Ignore fullscreen requests for the current fullscreen element

http://fullscreen.spec.whatwg.org/#dom-element-requestfullscreen

This spec change was made in order to simplify the fix for mis-nested
fullscreen in iframes:
https://www.w3.org/Bugs/Public/show_bug.cgi?id=26568 (comments 9-13)

The requestFullscreen() implementation is not in sync with the spec, but
an early return is equivalent until the "run the remaining steps
asynchronously" bit is implemented.

In order to be affected by this change, one would have to request
fullscreen for the same element twice and do something meaningful in the
fullscreenerror event, which is likely rare.

Note that exitFullscreen() already does nothing if the fullscreen
element stack is empty, so there is some symmetry to this.

TEST=LayoutTests/fullscreen/api/element-request-fullscreen-top.html
TEST=LayoutTests/fullscreen/api/element-request-fullscreen-non-top.html

BUG=403741

Review URL: https://codereview.chromium.org/482543002

git-svn-id: svn://svn.chromium.org/blink/trunk@180444 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent bbd2e072
<!DOCTYPE html>
<title>Element.requestFullscreen() for non-top element in fullscreen element stack</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../trusted-event.js"></script>
<div id="log"></div>
<div id="first">
<div id="last"></div>
</div>
<script>
async_test(function(t)
{
var first = document.getElementById("first");
trusted_request(first);
document.onfullscreenchange = t.step_func(function()
{
assert_equals(document.fullscreenElement, first);
var last = document.getElementById("last");
trusted_request(last);
document.onfullscreenchange = t.step_func(function()
{
assert_equals(document.fullscreenElement, last);
trusted_request(first, last);
document.onfullscreenerror = t.step_func_done();
});
});
});
</script>
<!DOCTYPE html>
<title>Element.requestFullscreen() for top element in fullscreen element stack</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../trusted-event.js"></script>
<div id="log"></div>
<div id="top"></div>
<script>
async_test(function(t)
{
var top = document.getElementById("top");
trusted_request(top);
document.onfullscreenchange = t.step_func(function()
{
assert_equals(document.fullscreenElement, top);
document.onfullscreenchange = t.unreached_func("fullscreenchange event");
trusted_event(t.step_func(function()
{
top.requestFullscreen();
// An fullscreenerror event would be fired after an async section
// and an animation frame task, so wait until after that.
setTimeout(requestAnimationFrame.bind(null, t.step_func_done()), 0);
}), top);
});
document.onfullscreenerror = t.unreached_func("fullscreenerror event");
});
</script>
EVENT(webkitfullscreenchange)
EXPECTED (document.webkitCurrentFullScreenElement == '[object HTMLHtmlElement]') OK
EVENT(webkitfullscreenerror)
EXPECTED (document.webkitCurrentFullScreenElement == '[object HTMLHtmlElement]') OK
EVENT(webkitfullscreenchange)
EXPECTED (document.webkitCurrentFullScreenElement == '[object HTMLSpanElement]') OK
EVENT(webkitfullscreenerror)
EXPECTED (document.webkitCurrentFullScreenElement == '[object HTMLSpanElement]') OK
EVENT(webkitfullscreenchange)
EXPECTED (document.webkitCurrentFullScreenElement == '[object HTMLHtmlElement]') OK
EVENT(webkitfullscreenchange)
......
......@@ -5,24 +5,12 @@
var span = document.getElementsByTagName('span')[0];
var documentEnteredFullScreen = function() {
testExpected("document.webkitCurrentFullScreenElement", document.documentElement);
runWithKeyDown(function(){document.documentElement.webkitRequestFullscreen()});
waitForEvent(document, 'webkitfullscreenerror', documentDidNotReenterFullScreen, false, true);
};
var documentDidNotReenterFullScreen = function() {
testExpected("document.webkitCurrentFullScreenElement", document.documentElement);
runWithKeyDown(function(){span.webkitRequestFullscreen()});
waitForEvent(document, 'webkitfullscreenchange', spanEnteredFullScreen, false, true);
};
var spanEnteredFullScreen = function() {
testExpected("document.webkitCurrentFullScreenElement", span);
runWithKeyDown(function(){span.webkitRequestFullscreen()});
waitForEvent(document, 'webkitfullscreenerror', spanDidNotReenterFullScreen, false, true);
};
var spanDidNotReenterFullScreen = function() {
testExpected("document.webkitCurrentFullScreenElement", span);
waitForEvent(document, 'webkitfullscreenchange', spanExited, false, true);
document.webkitExitFullscreen();
......
......@@ -205,6 +205,10 @@ void Fullscreen::requestFullscreen(Element& element, RequestType requestType)
if (!document()->isActive())
return;
// If |element| is on top of |doc|'s fullscreen element stack, terminate these substeps.
if (&element == fullscreenElement())
return;
do {
// 1. If any of the following conditions are true, terminate these steps and queue a task to fire
// an event named fullscreenerror with its bubbles attribute set to true on the context object's
......
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