mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 12:50:09 +00:00
Bug 1212299 part 1 - Forbid documents inside elements other than iframe from requesting fullscreen. r=smaug
--HG-- extra : source : b995b57bc1dd2003eeff6f568f5f22298ff81608
This commit is contained in:
parent
866344b549
commit
57b9d7be94
@ -2512,20 +2512,25 @@ nsDocShell::GetFullscreenAllowed(bool* aFullscreenAllowed)
|
||||
// Assume false until we determine otherwise...
|
||||
*aFullscreenAllowed = false;
|
||||
|
||||
// For non-browsers/apps, check that the enclosing iframe element
|
||||
// has the allowfullscreen attribute set to true. If any ancestor
|
||||
// iframe does not have mozallowfullscreen=true, then fullscreen is
|
||||
// prohibited.
|
||||
nsCOMPtr<nsPIDOMWindow> win = GetWindow();
|
||||
if (!win) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<Element> frameElement = win->GetFrameElementInternal();
|
||||
if (frameElement &&
|
||||
frameElement->IsHTMLElement(nsGkAtoms::iframe) &&
|
||||
!frameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::allowfullscreen) &&
|
||||
!frameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::mozallowfullscreen)) {
|
||||
return NS_OK;
|
||||
if (frameElement && !frameElement->IsXULElement()) {
|
||||
// We do not allow document inside any containing element other
|
||||
// than iframe to enter fullscreen.
|
||||
if (!frameElement->IsHTMLElement(nsGkAtoms::iframe)) {
|
||||
return NS_OK;
|
||||
}
|
||||
// If any ancestor iframe does not have allowfullscreen attribute
|
||||
// set, then fullscreen is not allowed.
|
||||
if (!frameElement->HasAttr(kNameSpaceID_None,
|
||||
nsGkAtoms::allowfullscreen) &&
|
||||
!frameElement->HasAttr(kNameSpaceID_None,
|
||||
nsGkAtoms::mozallowfullscreen)) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// If we have no parent then we're the root docshell; no ancestor of the
|
||||
|
@ -12027,18 +12027,15 @@ nsDocument::IsFullScreenEnabled(bool aCallerIsChrome, bool aLogFailure)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensure that all ancestor <iframe> elements have the allowfullscreen
|
||||
// boolean attribute set.
|
||||
// Ensure that all containing elements are <iframe> and have
|
||||
// allowfullscreen attribute set.
|
||||
nsCOMPtr<nsIDocShell> docShell(mDocumentContainer);
|
||||
bool allowed = false;
|
||||
if (docShell) {
|
||||
docShell->GetFullscreenAllowed(&allowed);
|
||||
}
|
||||
if (!allowed) {
|
||||
LogFullScreenDenied(aLogFailure, "FullScreenDeniedIframeNotAllowed", this);
|
||||
if (!docShell || !docShell->GetFullscreenAllowed()) {
|
||||
LogFullScreenDenied(aLogFailure, "FullScreenDeniedContainerNotAllowed", this);
|
||||
return false;
|
||||
}
|
||||
|
||||
return allowed;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
|
@ -67,7 +67,7 @@ nsIDOMWindowInternalWarning=Use of nsIDOMWindowInternal is deprecated. Use nsIDO
|
||||
FullScreenDeniedDisabled=Request for full-screen was denied because full-screen API is disabled by user preference.
|
||||
FullScreenDeniedFocusedPlugin=Request for full-screen was denied because a windowed plugin is focused.
|
||||
FullScreenDeniedHidden=Request for full-screen was denied because the document is no longer visible.
|
||||
FullScreenDeniedIframeNotAllowed=Request for full-screen was denied because at least one of the document's containing iframes does not have an "allowfullscreen" attribute.
|
||||
FullScreenDeniedContainerNotAllowed=Request for full-screen was denied because at least one of the document's containing element is not iframe or does not have an "allowfullscreen" attribute.
|
||||
FullScreenDeniedNotInputDriven=Request for full-screen was denied because Element.mozRequestFullScreen() was not called from inside a short running user-generated event handler.
|
||||
FullScreenDeniedNotInDocument=Request for full-screen was denied because requesting element is no longer in its document.
|
||||
FullScreenDeniedMovedDocument=Request for full-screen was denied because requesting element has moved document.
|
||||
|
@ -67,7 +67,7 @@ nsIDOMWindowInternalWarning=Use of nsIDOMWindowInternal is deprecated. Use nsIDO
|
||||
FullScreenDeniedDisabled=Request for full-screen was denied because full-screen API is disabled by user preference.
|
||||
FullScreenDeniedFocusedPlugin=Request for full-screen was denied because a windowed plugin is focused.
|
||||
FullScreenDeniedHidden=Request for full-screen was denied because the document is no longer visible.
|
||||
FullScreenDeniedIframeNotAllowed=Request for full-screen was denied because at least one of the document's containing iframes does not have an "allowfullscreen" attribute.
|
||||
FullScreenDeniedContainerNotAllowed=Request for full-screen was denied because at least one of the document's containing element is not iframe or does not have an "allowfullscreen" attribute.
|
||||
FullScreenDeniedNotInputDriven=Request for full-screen was denied because Element.mozRequestFullScreen() was not called from inside a short running user-generated event handler.
|
||||
FullScreenDeniedNotInDocument=Request for full-screen was denied because requesting element is no longer in its document.
|
||||
FullScreenDeniedMovedDocument=Request for full-screen was denied because requesting element has moved document.
|
||||
|
Loading…
x
Reference in New Issue
Block a user