Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=633602 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Bug 633602 - file_nestedFullScreen.html</title> |
michael@0 | 8 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"> |
michael@0 | 9 | </script> |
michael@0 | 10 | <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"> |
michael@0 | 11 | </script> |
michael@0 | 12 | <script type="application/javascript" src="pointerlock_utils.js"></script> |
michael@0 | 13 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 14 | </head> |
michael@0 | 15 | <body> |
michael@0 | 16 | <a target="_blank" |
michael@0 | 17 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602"> |
michael@0 | 18 | Mozilla Bug 633602 |
michael@0 | 19 | </a> |
michael@0 | 20 | |
michael@0 | 21 | <div id="parentDiv"> |
michael@0 | 22 | <div id="childDiv"></div> |
michael@0 | 23 | </div> |
michael@0 | 24 | |
michael@0 | 25 | <script type="application/javascript"> |
michael@0 | 26 | /* |
michael@0 | 27 | * Test for Bug 633602 |
michael@0 | 28 | * Requesting fullscreen on a child element of the element with |
michael@0 | 29 | * the pointer locked should unlock the pointer |
michael@0 | 30 | */ |
michael@0 | 31 | |
michael@0 | 32 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 33 | |
michael@0 | 34 | var parentDiv = document.getElementById("parentDiv") |
michael@0 | 35 | , childDiv = document.getElementById("childDiv") |
michael@0 | 36 | , parentDivLocked = false |
michael@0 | 37 | , parentDivFullScreen = false |
michael@0 | 38 | , pointerLocked = false; |
michael@0 | 39 | |
michael@0 | 40 | function runTests () { |
michael@0 | 41 | ok(parentDivLocked, "After requesting pointerlock on parentDiv " + |
michael@0 | 42 | "document.mozPointerLockElement should be equal to " + |
michael@0 | 43 | " parentDiv element"); |
michael@0 | 44 | isnot(pointerLocked, true, "Requesting fullscreen on " + |
michael@0 | 45 | "childDiv while parentDiv still in fullscreen should " + |
michael@0 | 46 | "unlock the pointer"); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | document.addEventListener("mozpointerlockchange", function (e) { |
michael@0 | 50 | if (document.mozPointerLockElement === parentDiv) { |
michael@0 | 51 | parentDivLocked = true; |
michael@0 | 52 | childDiv.mozRequestFullScreen(); |
michael@0 | 53 | } |
michael@0 | 54 | }, false); |
michael@0 | 55 | |
michael@0 | 56 | document.addEventListener("mozfullscreenchange", function() { |
michael@0 | 57 | if (document.mozFullScreenElement === parentDiv) { |
michael@0 | 58 | if (parentDivFullScreen === true) { |
michael@0 | 59 | document.mozCancelFullScreen(); |
michael@0 | 60 | } |
michael@0 | 61 | parentDivFullScreen = true; |
michael@0 | 62 | parentDiv.mozRequestPointerLock(); |
michael@0 | 63 | } |
michael@0 | 64 | else if (document.mozFullScreenElement === childDiv) { |
michael@0 | 65 | pointerLocked = !!document.mozPointerLockElement; |
michael@0 | 66 | document.mozCancelFullScreen(); |
michael@0 | 67 | } |
michael@0 | 68 | else { |
michael@0 | 69 | runTests(); |
michael@0 | 70 | SimpleTest.finish(); |
michael@0 | 71 | } |
michael@0 | 72 | }, false); |
michael@0 | 73 | |
michael@0 | 74 | function start() { |
michael@0 | 75 | parentDiv.mozRequestFullScreen(); |
michael@0 | 76 | } |
michael@0 | 77 | </script> |
michael@0 | 78 | </body> |
michael@0 | 79 | </html> |