Bug 1269157 - Add Document.fullscreen attribute. r?smaug
MozReview-Commit-ID: 7mMjGoc7cvA
--- a/dom/base/ScreenOrientation.cpp
+++ b/dom/base/ScreenOrientation.cpp
@@ -473,17 +473,17 @@ ScreenOrientation::GetLockOrientationPer
}
if (Preferences::GetBool("dom.screenorientation.testing.non_fullscreen_lock_allow",
false)) {
return LOCK_ALLOWED;
}
// Other content must be full-screen in order to lock orientation.
- return doc->MozFullScreen() ? FULLSCREEN_LOCK_ALLOWED : LOCK_DENIED;
+ return doc->Fullscreen() ? FULLSCREEN_LOCK_ALLOWED : LOCK_DENIED;
}
nsIDocument*
ScreenOrientation::GetResponsibleDocument() const
{
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner();
if (!owner) {
return nullptr;
@@ -642,17 +642,17 @@ ScreenOrientation::FullScreenEventListen
MOZ_ASSERT(target);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(target);
MOZ_ASSERT(doc);
// We have to make sure that the event we got is the event sent when
// fullscreen is disabled because we could get one when fullscreen
// got enabled if the lock call is done at the same moment.
- if (doc->MozFullScreen()) {
+ if (doc->Fullscreen()) {
return NS_OK;
}
hal::UnlockScreenOrientation();
nsresult rv = target->RemoveSystemEventListener(NS_LITERAL_STRING("fullscreenchange"),
this, true);
NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -12170,17 +12170,17 @@ nsDocument::GetFullscreenElement()
element->IsFullScreenAncestor(),
"Fullscreen element should have fullscreen styles applied");
return element;
}
NS_IMETHODIMP
nsDocument::GetMozFullScreen(bool *aFullScreen)
{
- *aFullScreen = MozFullScreen();
+ *aFullScreen = Fullscreen();
return NS_OK;
}
NS_IMETHODIMP
nsDocument::GetMozFullScreenEnabled(bool *aFullScreen)
{
NS_ENSURE_ARG_POINTER(aFullScreen);
*aFullScreen = FullscreenEnabled();
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -2555,17 +2555,17 @@ public:
Element* GetCurrentScript();
void ReleaseCapture() const;
virtual void MozSetImageElement(const nsAString& aImageElementId,
Element* aElement) = 0;
nsIURI* GetDocumentURIObject() const;
// Not const because all the full-screen goop is not const
virtual bool FullscreenEnabled() = 0;
virtual Element* GetFullscreenElement() = 0;
- bool MozFullScreen()
+ bool Fullscreen()
{
return !!GetFullscreenElement();
}
void ExitFullscreen();
Element* GetMozPointerLockElement();
void MozExitPointerLock()
{
UnlockPointer(this);
--- a/dom/html/test/file_fullscreen-api.html
+++ b/dom/html/test/file_fullscreen-api.html
@@ -51,32 +51,34 @@ function sendMouseClick(element) {
}
function fullScreenElement() {
return document.getElementById('full-screen-element');
}
function enter1(event) {
is(event.target, document, "Event target should be full-screen document #1");
+ ok(document.fullscreen, "Document should be in fullscreen");
is(document.fullscreenElement, fullScreenElement(),
"Full-screen element should be div element.");
ok(document.fullscreenElement.matches(":fullscreen"),
"FSE should match :fullscreen");
var fse = fullScreenElement();
addFullscreenChangeContinuation("exit", exit1);
fse.parentNode.removeChild(fse);
is(document.fullscreenElement, null,
"Full-screen element should be null after removing.");
document.body.appendChild(fse);
is(document.fullscreenElement, null,
"Full-screen element should still be null after re-adding former FSE.");
}
function exit1(event) {
is(event.target, document, "Event target should be full-screen document #2");
+ ok(!document.fullscreen, "Document should not be in fullscreen");
is(document.fullscreenElement, null, "Full-screen element should be null.");
iframe = document.createElement("iframe");
iframe.allowFullscreen = true;
addFullscreenChangeContinuation("enter", enter2);
document.body.appendChild(iframe);
iframe.src = iframeContents;
}
--- a/dom/html/test/file_fullscreen-lenient-setters.html
+++ b/dom/html/test/file_fullscreen-lenient-setters.html
@@ -20,16 +20,25 @@ function is(a, b, msg) {
function info(msg) {
opener.info("[lenient-setters] " + msg);
}
let unattachedDiv = document.createElement("div");
function begin() {
+ var originalValue = document.fullscreen;
+ try {
+ document.fullscreen = !document.fullscreen;
+ is(document.fullscreen, originalValue,
+ "fullscreen should not be changed");
+ } catch (e) {
+ ok(false, "Setting fullscreen should not throw");
+ }
+
var originalElem = document.fullscreenElement;
try {
document.fullscreenElement = unattachedDiv;
document.fullscreenElement = [];
is(document.fullscreenElement, originalElem,
"fullscreenElement should not be changed");
} catch (e) {
ok(false, "Setting fullscreenElement should not throw");
--- a/dom/html/test/file_fullscreen-unprefix-disabled-inner.html
+++ b/dom/html/test/file_fullscreen-unprefix-disabled-inner.html
@@ -26,16 +26,17 @@ SimpleTest.requestFlakyTimeout(
"need to wait for a while to confirm no unexpected event is dispatched");
let div = document.getElementById("fullscreen");
let unattachedDiv = document.createElement('div');
function begin() {
ok(!("requestFullscreen" in div), "No element.requestFullscreen");
ok(!("exitFullscreen" in document), "No document.exitFullscreen");
+ ok(!("fullscreen" in document), "No document.fullscreen");
ok(!("fullscreenElement" in document), "No document.fullscreenElement");
ok(!("fullscreenEnabled" in document), "No document.fullscreenEnabled");
ok(!("onfullscreenchange" in document), "No document.onfullscreenchange");
ok(!("onfullscreenerror" in document), "No document.onfullscreenerror");
for (var event of ["fullscreenchange", "fullscreenerror"]) {
let customEvent = new Event(event, {bubbles: true});
let gotCustomEventFromWindow = false;
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -220,32 +220,32 @@ partial interface Document {
};
// https://fullscreen.spec.whatwg.org/#api
partial interface Document {
// Note: Per spec the 'S' in these two is lowercase, but the "Moz"
// versions hve it uppercase.
[LenientSetter, Func="nsDocument::IsUnprefixedFullscreenEnabled"]
+ readonly attribute boolean fullscreen;
+ [BinaryName="fullscreen", Deprecated="PrefixedFullscreenAPI"]
+ readonly attribute boolean mozFullScreen;
+ [LenientSetter, Func="nsDocument::IsUnprefixedFullscreenEnabled"]
readonly attribute boolean fullscreenEnabled;
[BinaryName="fullscreenEnabled", Deprecated="PrefixedFullscreenAPI"]
readonly attribute boolean mozFullScreenEnabled;
[LenientSetter, Func="nsDocument::IsUnprefixedFullscreenEnabled"]
readonly attribute Element? fullscreenElement;
[BinaryName="fullscreenElement", Deprecated="PrefixedFullscreenAPI"]
readonly attribute Element? mozFullScreenElement;
[Func="nsDocument::IsUnprefixedFullscreenEnabled"]
void exitFullscreen();
[BinaryName="exitFullscreen", Deprecated="PrefixedFullscreenAPI"]
void mozCancelFullScreen();
-
- // Gecko-specific fullscreen bits
- [Deprecated="PrefixedFullscreenAPI"]
- readonly attribute boolean mozFullScreen;
};
// http://dvcs.w3.org/hg/pointerlock/raw-file/default/index.html#extensions-to-the-document-interface
partial interface Document {
readonly attribute Element? mozPointerLockElement;
void mozExitPointerLock ();
};