mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 04:38:02 +00:00
Bug 1283526 part 1 - Revert behavior of allowfullscreen attribute for non-sandboxed iframe. r=smaug
MozReview-Commit-ID: BayA4tQBsfC --HG-- extra : rebase_source : 17818546cd0c1ec971412346d6e32d537442dd26
This commit is contained in:
parent
6a32106bbf
commit
dc193d9f49
@ -2556,10 +2556,6 @@ nsDocShell::GetFullscreenAllowed(bool* aFullscreenAllowed)
|
||||
// neither iframe nor embed
|
||||
return NS_OK;
|
||||
}
|
||||
nsIDocument* doc = frameElement->GetUncomposedDoc();
|
||||
if (!doc || !doc->FullscreenEnabledInternal()) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// If we have no parent then we're the root docshell; no ancestor of the
|
||||
@ -3837,13 +3833,6 @@ nsDocShell::IsSandboxedFrom(nsIDocShell* aTargetDocShell)
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShell::ApplySandboxAndFullscreenFlags(nsIDocument* aDoc)
|
||||
{
|
||||
aDoc->SetSandboxFlags(mSandboxFlags);
|
||||
aDoc->SetFullscreenEnabled(GetFullscreenAllowed());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetTreeOwner(nsIDocShellTreeOwner** aTreeOwner)
|
||||
{
|
||||
@ -8062,9 +8051,9 @@ nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
|
||||
|
||||
blankDoc->SetContainer(this);
|
||||
|
||||
// Apply the sandbox and fullscreen enabled flags to the document.
|
||||
// These are immutable after being set here.
|
||||
ApplySandboxAndFullscreenFlags(blankDoc);
|
||||
// Copy our sandbox flags to the document. These are immutable
|
||||
// after being set here.
|
||||
blankDoc->SetSandboxFlags(mSandboxFlags);
|
||||
|
||||
// create a content viewer for us and the new document
|
||||
docFactory->CreateInstanceForDocument(
|
||||
|
@ -25,7 +25,6 @@ interface nsIChannel;
|
||||
interface nsIContentViewer;
|
||||
interface nsIDOMEventTarget;
|
||||
interface nsIDocShellLoadInfo;
|
||||
interface nsIDocument;
|
||||
interface nsIEditor;
|
||||
interface nsIEditingSession;
|
||||
interface nsISimpleEnumerator;
|
||||
@ -901,11 +900,6 @@ interface nsIDocShell : nsIDocShellTreeItem
|
||||
*/
|
||||
[noscript,notxpcom,nostdcall] bool isSandboxedFrom(in nsIDocShell aTargetDocShell);
|
||||
|
||||
/**
|
||||
* Apply sandbox flags and fullscreen enabled flag to the given document.
|
||||
*/
|
||||
[noscript,notxpcom] void applySandboxAndFullscreenFlags(in nsIDocument aDoc);
|
||||
|
||||
/**
|
||||
* This member variable determines whether a document has Mixed Active Content that
|
||||
* was initially blocked from loading, but the user has choosen to override the
|
||||
|
@ -601,7 +601,6 @@ ImportLoader::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
|
||||
// We want to inherit the sandbox flags and fullscreen enabled flag
|
||||
// from the master document.
|
||||
mDocument->SetSandboxFlags(master->GetSandboxFlags());
|
||||
mDocument->SetFullscreenEnabled(master->FullscreenEnabledInternal());
|
||||
|
||||
// We have to connect the blank document we created with the channel we opened,
|
||||
// and create its own LoadGroup for it.
|
||||
|
@ -1455,7 +1455,6 @@ nsIDocument::nsIDocument()
|
||||
mFontFaceSetDirty(true),
|
||||
mGetUserFontSetCalled(false),
|
||||
mPostedFlushUserFontSet(false),
|
||||
mFullscreenEnabled(false),
|
||||
mPartID(0),
|
||||
mDidFireDOMContentLoaded(true),
|
||||
mHasScrollLinkedEffect(false),
|
||||
@ -2594,7 +2593,8 @@ nsDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
|
||||
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(aContainer);
|
||||
|
||||
if (docShell) {
|
||||
docShell->ApplySandboxAndFullscreenFlags(this);
|
||||
nsresult rv = docShell->GetSandboxFlags(&mSandboxFlags);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
WarnIfSandboxIneffective(docShell, mSandboxFlags, GetChannel());
|
||||
}
|
||||
|
||||
@ -11802,7 +11802,11 @@ GetFullscreenError(nsIDocument* aDoc, bool aCallerIsChrome)
|
||||
if (!nsContentUtils::IsFullScreenApiEnabled()) {
|
||||
return "FullscreenDeniedDisabled";
|
||||
}
|
||||
if (!aDoc->FullscreenEnabledInternal()) {
|
||||
|
||||
// Ensure that all containing elements are <iframe> and have
|
||||
// allowfullscreen attribute set.
|
||||
nsCOMPtr<nsIDocShell> docShell(aDoc->GetDocShell());
|
||||
if (!docShell || !docShell->GetFullscreenAllowed()) {
|
||||
return "FullscreenDeniedContainerNotAllowed";
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -2593,11 +2593,6 @@ public:
|
||||
return !!GetFullscreenElement();
|
||||
}
|
||||
void ExitFullscreen();
|
||||
bool FullscreenEnabledInternal() const { return mFullscreenEnabled; }
|
||||
void SetFullscreenEnabled(bool aEnabled)
|
||||
{
|
||||
mFullscreenEnabled = aEnabled;
|
||||
}
|
||||
Element* GetMozPointerLockElement();
|
||||
void MozExitPointerLock()
|
||||
{
|
||||
@ -3059,10 +3054,6 @@ protected:
|
||||
// Do we currently have an event posted to call FlushUserFontSet?
|
||||
bool mPostedFlushUserFontSet : 1;
|
||||
|
||||
// Whether fullscreen is enabled for this document. This corresponds
|
||||
// to the "fullscreen enabled flag" in the HTML spec.
|
||||
bool mFullscreenEnabled : 1;
|
||||
|
||||
enum Type {
|
||||
eUnknown, // should never be used
|
||||
eHTML,
|
||||
|
@ -383,7 +383,6 @@ XULDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
|
||||
mStillWalking = true;
|
||||
mMayStartLayout = false;
|
||||
mDocumentLoadGroup = do_GetWeakReference(aLoadGroup);
|
||||
mFullscreenEnabled = true;
|
||||
|
||||
mChannel = aChannel;
|
||||
|
||||
|
@ -10,9 +10,8 @@
|
||||
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
function test_allowfullscreen(t, setup_iframe) {
|
||||
async_test(function(t) {
|
||||
var iframe = document.createElement("iframe");
|
||||
setup_iframe(iframe);
|
||||
iframe.src = "support/blank.htm";
|
||||
var eventWatcher = new EventWatcher(t, iframe, "load");
|
||||
document.body.appendChild(iframe);
|
||||
@ -21,74 +20,15 @@
|
||||
});
|
||||
|
||||
assert_true(document.fullscreenEnabled, "Top level document has fullscreen enabled flag set");
|
||||
eventWatcher.wait_for("load").then(t.step_func(function() {
|
||||
eventWatcher.wait_for("load").then(t.step_func_done(function() {
|
||||
assert_false(iframe.contentDocument.fullscreenEnabled, "Document inside iframe without allowfullscreen attribute should not have fullscreen enabled flag set");
|
||||
iframe.setAttribute("allowfullscreen", true);
|
||||
assert_false(iframe.contentDocument.fullscreenEnabled, "Setting allowfullscreen attribute after document load should not affect fullscreen enabled flag");
|
||||
iframe.contentWindow.location.reload();
|
||||
return eventWatcher.wait_for("load");
|
||||
})).then(t.step_func(function() {
|
||||
assert_true(iframe.contentDocument.fullscreenEnabled, "Fullscreen enabled flag should be set when a new document is loaded with allowfullscreen attribute present");
|
||||
assert_true(iframe.contentDocument.fullscreenEnabled, "Fullscreen should be allowed when allowfullscreen attribute is set");
|
||||
iframe.removeAttribute("allowfullscreen");
|
||||
assert_true(iframe.contentDocument.fullscreenEnabled, "Removing allowfullscreen attribute should not affect fullscreen enabled flag");
|
||||
iframe.contentWindow.location.reload();
|
||||
return eventWatcher.wait_for("load");
|
||||
})).then(t.step_func_done(function() {
|
||||
assert_false(iframe.contentDocument.fullscreenEnabled, "Fullscreen enabled flag should be reset when a new document is loaded with allowfullscreen attribute absent");
|
||||
assert_false(iframe.contentDocument.fullscreenEnabled, "Fullscreen should be denied when allowfullscreen attribute is removed");
|
||||
}));
|
||||
}
|
||||
|
||||
async_test(function(t) {
|
||||
test_allowfullscreen(t, function(iframe) {});
|
||||
}, "iframe-allowfullscreen");
|
||||
|
||||
async_test(function(t) {
|
||||
test_allowfullscreen(t, function(iframe) {
|
||||
iframe.setAttribute("sandbox", "allow-same-origin");
|
||||
});
|
||||
}, "iframe-sandbox-allowfullscreen");
|
||||
|
||||
/* Fullscreen enabled flag with dialog */
|
||||
|
||||
function test_allowfullscreen_dialog(t, setup_iframe, check) {
|
||||
var iframe = document.createElement("iframe");
|
||||
setup_iframe(iframe);
|
||||
iframe.src = "support/blank.htm";
|
||||
var eventWatcher = new EventWatcher(t, iframe, "load");
|
||||
document.body.appendChild(iframe);
|
||||
t.add_cleanup(function() {
|
||||
document.body.removeChild(iframe);
|
||||
});
|
||||
|
||||
var newWin;
|
||||
assert_true(document.fullscreenEnabled, "Top level document has fullscreen enabled flag set");
|
||||
eventWatcher.wait_for("load").then(t.step_func(function() {
|
||||
assert_false(iframe.contentDocument.fullscreenEnabled, "Document inside iframe without allowfullscreen attribute should not have fullscreen enabled flag set");
|
||||
newWin = iframe.contentWindow.open("support/blank.htm");
|
||||
t.add_cleanup(function() {
|
||||
newWin.close();
|
||||
});
|
||||
var newWinEventWatcher = new EventWatcher(t, newWin, "load");
|
||||
return newWinEventWatcher.wait_for("load");
|
||||
})).then(t.step_func_done(function() {
|
||||
check(newWin);
|
||||
}));
|
||||
}
|
||||
|
||||
async_test(function(t) {
|
||||
test_allowfullscreen_dialog(t, function() {}, function(newWin) {
|
||||
assert_true(newWin.document.fullscreenEnabled, "Document in the new window is a top level document, thus should has fullscreen enabled flag set");
|
||||
});
|
||||
}, "iframe-allowfullscreen-dialog");
|
||||
|
||||
async_test(function(t) {
|
||||
test_allowfullscreen_dialog(t, function(iframe) {
|
||||
iframe.setAttribute("sandbox", "allow-same-origin allow-popups");
|
||||
}, function(newWin) {
|
||||
assert_false(newWin.document.fullscreenEnabled, "Document in the new window should inherit the sandboxed fullscreen flag and should not have fullscreen enabled flag set");
|
||||
});
|
||||
}, "iframe-sandbox-allowfullscreen-dialog");
|
||||
|
||||
/* Fullscreen enabled flag with about:blank */
|
||||
|
||||
function test_allowfullscreen_noload(setup_iframe, check) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user