зеркало из https://github.com/mozilla/pjs.git
Bug 689058 - Implement document.mozFullScreenEnabled r=cpearce sr=roc
This commit is contained in:
Родитель
0b5b31ffb4
Коммит
538590773a
|
@ -8660,6 +8660,38 @@ nsDocument::GetMozFullScreen(bool *aFullScreen)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetMozFullScreenEnabled(bool *aFullScreen)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFullScreen);
|
||||
*aFullScreen = false;
|
||||
|
||||
if (!nsContentUtils::IsFullScreenApiEnabled()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// todo: Bug 684618 - Deny requests for DOM full-screen when windowed
|
||||
// plugins are present.
|
||||
|
||||
// Ensure that all ancestor <iframe> elements have the mozallowfullscreen
|
||||
// boolean attribute set.
|
||||
nsINode* node = static_cast<nsINode*>(this);
|
||||
do {
|
||||
nsIContent* content = static_cast<nsIContent*>(node);
|
||||
if (content->IsHTML(nsGkAtoms::iframe) &&
|
||||
!content->HasAttr(kNameSpaceID_None, nsGkAtoms::mozallowfullscreen)) {
|
||||
// The node requesting fullscreen, or one of its crossdoc ancestors,
|
||||
// is an iframe which doesn't have the "mozalllowfullscreen" attribute.
|
||||
// This request is not authorized by the parent document.
|
||||
return NS_OK;
|
||||
}
|
||||
node = nsContentUtils::GetCrossDocParentNode(node);
|
||||
} while (node);
|
||||
|
||||
*aFullScreen = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt64
|
||||
nsDocument::SizeOf() const
|
||||
{
|
||||
|
|
|
@ -3419,28 +3419,20 @@ nsresult nsGenericHTMLElement::MozRequestFullScreen()
|
|||
// This stops the full-screen from being abused similar to the popups of old,
|
||||
// and it also makes it harder for bad guys' script to go full-screen and
|
||||
// spoof the browser chrome/window and phish logins etc.
|
||||
if (!nsContentUtils::IsFullScreenApiEnabled() ||
|
||||
!nsContentUtils::IsRequestFullScreenAllowed()) {
|
||||
if (!nsContentUtils::IsRequestFullScreenAllowed()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Ensure that all ancestor <iframe> elements have the mozallowfullscreen
|
||||
// boolean attribute set.
|
||||
nsINode* node = static_cast<nsINode*>(this);
|
||||
do {
|
||||
nsIContent* content = static_cast<nsIContent*>(node);
|
||||
if (content->IsHTML(nsGkAtoms::iframe) &&
|
||||
!content->HasAttr(kNameSpaceID_None, nsGkAtoms::mozallowfullscreen)) {
|
||||
// The node requesting fullscreen, or one of its crossdoc ancestors,
|
||||
// is an iframe which doesn't have the "mozalllowfullscreen" attribute.
|
||||
// This request is not authorized by the parent document.
|
||||
return NS_OK;
|
||||
}
|
||||
node = nsContentUtils::GetCrossDocParentNode(node);
|
||||
} while (node);
|
||||
|
||||
nsIDocument* doc = GetOwnerDoc();
|
||||
NS_ENSURE_STATE(doc);
|
||||
nsCOMPtr<nsIDOMDocument> domDocument(do_QueryInterface(doc));
|
||||
NS_ENSURE_STATE(domDocument);
|
||||
bool fullScreenEnabled;
|
||||
domDocument->GetMozFullScreenEnabled(&fullScreenEnabled);
|
||||
if (!fullScreenEnabled) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
doc->RequestFullScreen(this);
|
||||
#ifdef DEBUG
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(doc->GetWindow());
|
||||
|
@ -3448,7 +3440,6 @@ nsresult nsGenericHTMLElement::MozRequestFullScreen()
|
|||
bool fullscreen;
|
||||
window->GetFullScreen(&fullscreen);
|
||||
NS_ASSERTION(fullscreen, "Windows should report fullscreen");
|
||||
nsCOMPtr<nsIDOMDocument> domDocument(do_QueryInterface(doc));
|
||||
domDocument->GetMozFullScreen(&fullscreen);
|
||||
NS_ASSERTION(fullscreen, "Document should report fullscreen");
|
||||
NS_ASSERTION(doc->IsFullScreenDoc(), "Should be in full screen state!");
|
||||
|
|
|
@ -140,7 +140,23 @@ function fullScreenChange(event) {
|
|||
break;
|
||||
}
|
||||
case 7: {
|
||||
ok(!document.mozFullScreen, "Should have left full-screen mode (last time).");
|
||||
ok(!document.mozFullScreen, "Should have left full-screen mode (last time).");
|
||||
|
||||
SpecialPowers.setBoolPref("full-screen-api.enabled", false);
|
||||
is(document.mozFullScreenEnabled, false, "document.mozFullScreenEnabled should be false if full-screen-api.enabled is false");
|
||||
document.body.mozRequestFullScreen();
|
||||
ok(!document.mozFullScreen, "Should still be in normal mode, because pref is not enabled.");
|
||||
|
||||
SpecialPowers.setBoolPref("full-screen-api.enabled", true);
|
||||
is(document.mozFullScreenEnabled, true, "document.mozFullScreenEnabled should be true if full-screen-api.enabled is true");
|
||||
|
||||
iframe = document.createElement("iframe");
|
||||
document.body.appendChild(iframe);
|
||||
iframe.src = iframeContents;
|
||||
ok(!document.mozFullScreen, "Should still be in normal mode, because iframe did not have mozallowfullscreen attribute.");
|
||||
document.body.removeChild(iframe);
|
||||
iframe = null;
|
||||
|
||||
// Set timeout for calling finish(), so that any pending "mozfullscreenchange" events
|
||||
// would have a chance to fire.
|
||||
setTimeout(function(){opener.apiTestFinished();}, 0);
|
||||
|
|
|
@ -67,7 +67,7 @@ interface nsIDOMCaretPosition;
|
|||
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
|
||||
*/
|
||||
|
||||
[scriptable, uuid(489faaa9-c54e-466c-8164-9a5fcc3a7052)]
|
||||
[scriptable, uuid(86bdbe61-760c-4982-a822-c6a0df63b8d2)]
|
||||
interface nsIDOMDocument : nsIDOMNode
|
||||
{
|
||||
readonly attribute nsIDOMDocumentType doctype;
|
||||
|
@ -398,6 +398,15 @@ interface nsIDOMDocument : nsIDOMNode
|
|||
*/
|
||||
readonly attribute boolean mozFullScreen;
|
||||
|
||||
/**
|
||||
* Denotes whether the full-screen-api.enabled is true, no windowed
|
||||
* plugins are present, and all ancestor documents have the
|
||||
* mozallowfullscreen attribute set.
|
||||
*
|
||||
* @see <https://wiki.mozilla.org/index.php?title=Gecko:FullScreenAPI>
|
||||
*/
|
||||
readonly attribute boolean mozFullScreenEnabled;
|
||||
|
||||
/**
|
||||
* Inline event handler for readystatechange events.
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче