Bug 697636 - Don't grant full-screen requests in hidden documents. r=bz

This commit is contained in:
Chris Pearce 2011-11-02 13:03:04 +13:00
parent c46ab13671
commit 6c2ed85b04
4 changed files with 55 additions and 2 deletions

View File

@ -8608,7 +8608,8 @@ nsDocument::GetMozFullScreenEnabled(bool *aFullScreen)
*aFullScreen = false;
if (!nsContentUtils::IsFullScreenApiEnabled() ||
nsContentUtils::HasPluginWithUncontrolledEventDispatch(this)) {
nsContentUtils::HasPluginWithUncontrolledEventDispatch(this) ||
!IsVisible()) {
return NS_OK;
}

View File

@ -283,6 +283,7 @@ _TEST_FILES = \
test_fullscreen-api.html \
file_fullscreen-plugins.html \
file_fullscreen-denied.html \
file_fullscreen-hidden.html \
test_li_attributes_reflection.html \
test_ol_attributes_reflection.html \
test_bug651956.html \

View File

@ -0,0 +1,50 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=697636
-->
<head>
<title>Test for Bug 697636</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body onload="boom();">
<iframe id="f" src="data:text/html,<body text=green>1" mozallowfullscreen></iframe>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=697636">Mozilla Bug 697636</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 697636 **/
var frameWin;
var e1;
function boom()
{
frameWin = document.getElementById("f").contentWindow;
e1 = frameWin.document.documentElement;
frameWin.location = "data:text/html,<body text=blue onload='parent.b2()'>2";
}
function b2()
{
try { e1.mozRequestFullScreen(); } catch(e) { opener.ok(false, "Should not enter full-screen"); }
setTimeout(done, 0);
}
function done() {
opener.ok(!document.mozFullScreen, "Should not have entered full-screen mode in hidden document.");
opener.ok(!e1.ownerDocument.mozFullScreen, "Requesting owner should not have entered full-screen mode.");
opener.nextTest();
}
</script>
</pre>
</body>
</html>

View File

@ -39,7 +39,8 @@ var gTestWindows = [
"file_fullscreen-denied.html",
"file_fullscreen-api.html",
"file_fullscreen-api-keys.html",
"file_fullscreen-plugins.html"
"file_fullscreen-plugins.html",
"file_fullscreen-hidden.html"
];
var testWindow = null;