Permalink
Browse files

Unlocks the mouse when nested element receives fullscreen

  • Loading branch information...
1 parent 9d76a36 commit c89eda6106ba244a9385ae223cf36966adce6472 @diogogmt committed Dec 13, 2011
@@ -8869,6 +8869,12 @@ nsDocument::RequestFullScreen(Element* aElement, bool aWasCallerChrome)
nsIDocument::ExitFullScreen(false);
}
+ // If a document is already in fullscreen, then unlocks the mouse
+ // before setting a new document to fullscreen
+ if (fullScreenDoc) {
+ MaybeUnlockMouse(fullScreenDoc);
+ }
+
// Remember the root document, so that if a full-screen document is hidden
// we can reset full-screen state in the remaining visible full-screen documents.
sFullScreenRootDoc = do_GetWeakReference(nsContentUtils::GetRootDocument(this));
@@ -66,6 +66,7 @@ _TEST_FILES = \
file_userPref.html \
file_syntheticMouseEvent.html \
file_targetOutOfFocus.html \
+ file_nestedFullScreen.html \
$(NULL)
libs:: $(_TEST_FILES)
@@ -0,0 +1,69 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=633602
+-->
+<head>
+ <title>Test for Bug 633602</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+ <script type="text/javascript" src="mouselock_util.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body onload="start();">
+ <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602">Mozilla Bug 633602</a>
+ <p id="display"></p>
+ <div id="content" style="display: none">
+ </div>
+
+ <div id="parentDiv">
+ <div id="childDiv">
+ </div>
+ </div>
+
+ <pre id="test">
+ <script type="application/javascript">
+ /** Test for Bug 633602 **/
+ SimpleTest.waitForExplicitFinish();
+
+ var pointer = navigator.pointer;
+ var parentDiv;
+ var childDiv;
+ var finish = false;
+
+ document.addEventListener("mozfullscreenchange", function() {
+ // Must call document.mozCancelFullScreen twice, since there are
+ // two nested elements in fullscreen mode
+ if (finish) {
+ finish = false;
+ // Cancel fullscreen on parentDiv
+ document.mozCancelFullScreen();
+ SimpleTest.finish();
+ } else if (document.mozFullScreenElement === parentDiv) {
+ pointer.lock(parentDiv, function () {
+ // Mouse should be locked to the parentDiv
+ ok (pointer.islocked, "Mouse should be locked to parentDiv");
+ childDiv.mozRequestFullScreen();
+ });
+ } else if (document.mozFullScreenElement === childDiv) {
+ // Mouse wasn't locked to childDiv, it was locked to parentDiv
+ // If childDiv receives fullscreen, mouse should be unlocked
+ is(pointer.islocked(), false, "Mouse shouldn't be locked to childDiv");
+ finish = true;
+ // Cancel fullscreen on childDiv
+ document.mozCancelFullScreen();
+ }
+ }, false);
+
+ function start() {
+ parentDiv = document.getElementById("parentDiv");
+ childDiv = document.getElementById("childDiv");
+
+ SimpleTest.waitForFocus(function() {
+ parentDiv.mozRequestFullScreen();
+ });
+ }
+ </script>
+ </pre>
+</body>
+</html>
@@ -47,7 +47,8 @@
"file_defaultUnlock.html",
"file_MouseEvents.html",
"file_movement.html",
- "file_targetOutOfFocus.html"
+ "file_targetOutOfFocus.html",
+ "file_nestedFullScreen.html"
];
var testWindow = null;

0 comments on commit c89eda6

Please sign in to comment.