1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/pointerlock/file_approval.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!--https://bugzilla.mozilla.org/show_bug.cgi?id=746885--> 1.7 +<head> 1.8 + <title>Bug 746885</title> 1.9 + <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.10 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.11 + <script type="application/javascript" src="pointerlock_utils.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 +</head> 1.14 +<body> 1.15 + <a target="_blank" 1.16 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=746885"> 1.17 + Mozilla Bug 746885 1.18 + </a> 1.19 + <div id="div"></div> 1.20 + <pre id="test"> 1.21 + <script type="text/javascript"> 1.22 + /* 1.23 + * Test for Bug 746885 1.24 + * When requesting pointer lock on a domain that doesn't have fullscreen 1.25 + * permission, the pointer lock request should be delayed until approval 1.26 + * has been granted. 1.27 + */ 1.28 + 1.29 + SimpleTest.waitForExplicitFinish(); 1.30 + 1.31 + // Ensure fullscreen won't be automatically granted for this document's domain. 1.32 + SpecialPowers.removeFullscreenAllowed(document); 1.33 + 1.34 + var div = document.getElementById("div"); 1.35 + var isApproved = false; 1.36 + 1.37 + document.addEventListener("mozpointerlockchange", 1.38 + function (e) { 1.39 + is(isApproved, true, "Should only receive mozpointerlockchange when we've been approved for fullscreen."); 1.40 + document.mozCancelFullScreen(); 1.41 + }, false); 1.42 + 1.43 + function approveFullscreen() { 1.44 + isApproved = true; 1.45 + SpecialPowers.setFullscreenAllowed(document); 1.46 + } 1.47 + 1.48 + document.addEventListener("mozfullscreenchange", function(e) { 1.49 + if (document.mozFullScreenElement === div) { 1.50 + // First entered fullscreen. Request pointer lock... 1.51 + div.mozRequestPointerLock(); 1.52 + // ... But only approve fullscreen after a delay, giving the pointer 1.53 + // lock request time to run if it were going to. Note we need two timeouts 1.54 + // here to because if we were to fail and the pointer lock request were to 1.55 + // succeed without approval, we'd need to give it time to run, and time for 1.56 + // its asynchronously dispatched mozpointerlockchange to run. 1.57 + setTimeout(function(){ setTimeout(approveFullscreen, 0); }, 0); 1.58 + } else { 1.59 + SimpleTest.finish(); 1.60 + } 1.61 + }, false); 1.62 + 1.63 + function start() { 1.64 + div.mozRequestFullScreen(); 1.65 + } 1.66 + </script> 1.67 + </pre> 1.68 +</body> 1.69 +</html>