dom/tests/mochitest/pointerlock/file_approval.html

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--https://bugzilla.mozilla.org/show_bug.cgi?id=746885-->
michael@0 4 <head>
michael@0 5 <title>Bug 746885</title>
michael@0 6 <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
michael@0 7 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 8 <script type="application/javascript" src="pointerlock_utils.js"></script>
michael@0 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 10 </head>
michael@0 11 <body>
michael@0 12 <a target="_blank"
michael@0 13 href="https://bugzilla.mozilla.org/show_bug.cgi?id=746885">
michael@0 14 Mozilla Bug 746885
michael@0 15 </a>
michael@0 16 <div id="div"></div>
michael@0 17 <pre id="test">
michael@0 18 <script type="text/javascript">
michael@0 19 /*
michael@0 20 * Test for Bug 746885
michael@0 21 * When requesting pointer lock on a domain that doesn't have fullscreen
michael@0 22 * permission, the pointer lock request should be delayed until approval
michael@0 23 * has been granted.
michael@0 24 */
michael@0 25
michael@0 26 SimpleTest.waitForExplicitFinish();
michael@0 27
michael@0 28 // Ensure fullscreen won't be automatically granted for this document's domain.
michael@0 29 SpecialPowers.removeFullscreenAllowed(document);
michael@0 30
michael@0 31 var div = document.getElementById("div");
michael@0 32 var isApproved = false;
michael@0 33
michael@0 34 document.addEventListener("mozpointerlockchange",
michael@0 35 function (e) {
michael@0 36 is(isApproved, true, "Should only receive mozpointerlockchange when we've been approved for fullscreen.");
michael@0 37 document.mozCancelFullScreen();
michael@0 38 }, false);
michael@0 39
michael@0 40 function approveFullscreen() {
michael@0 41 isApproved = true;
michael@0 42 SpecialPowers.setFullscreenAllowed(document);
michael@0 43 }
michael@0 44
michael@0 45 document.addEventListener("mozfullscreenchange", function(e) {
michael@0 46 if (document.mozFullScreenElement === div) {
michael@0 47 // First entered fullscreen. Request pointer lock...
michael@0 48 div.mozRequestPointerLock();
michael@0 49 // ... But only approve fullscreen after a delay, giving the pointer
michael@0 50 // lock request time to run if it were going to. Note we need two timeouts
michael@0 51 // here to because if we were to fail and the pointer lock request were to
michael@0 52 // succeed without approval, we'd need to give it time to run, and time for
michael@0 53 // its asynchronously dispatched mozpointerlockchange to run.
michael@0 54 setTimeout(function(){ setTimeout(approveFullscreen, 0); }, 0);
michael@0 55 } else {
michael@0 56 SimpleTest.finish();
michael@0 57 }
michael@0 58 }, false);
michael@0 59
michael@0 60 function start() {
michael@0 61 div.mozRequestFullScreen();
michael@0 62 }
michael@0 63 </script>
michael@0 64 </pre>
michael@0 65 </body>
michael@0 66 </html>

mercurial