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 | <!--https://bugzilla.mozilla.org/show_bug.cgi?id=633602--> |
michael@0 | 4 | <head> |
michael@0 | 5 | <title>Bug 633602</title> |
michael@0 | 6 | <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"> |
michael@0 | 7 | </script> |
michael@0 | 8 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"> |
michael@0 | 9 | </script> |
michael@0 | 10 | <script type="application/javascript" src="pointerlock_utils.js"></script> |
michael@0 | 11 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 12 | </head> |
michael@0 | 13 | <body> |
michael@0 | 14 | <a target="_blank" |
michael@0 | 15 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602"> |
michael@0 | 16 | Mozilla Bug 633602 |
michael@0 | 17 | </a> |
michael@0 | 18 | <div id="div"></div> |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | <script type="text/javascript"> |
michael@0 | 21 | /* |
michael@0 | 22 | * Test for Bug 633602 |
michael@0 | 23 | * Escape key should unlock the pointer |
michael@0 | 24 | */ |
michael@0 | 25 | |
michael@0 | 26 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 27 | |
michael@0 | 28 | var div = document.getElementById("div") |
michael@0 | 29 | , pointerUnLocked = false; |
michael@0 | 30 | |
michael@0 | 31 | function runTests () { |
michael@0 | 32 | ok(pointerUnLocked, "Pressing Escape key should unlock the pointer"); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | document.addEventListener("mozpointerlockchange", function (e) { |
michael@0 | 36 | if (document.mozPointerLockElement === div) { |
michael@0 | 37 | synthesizeKey("VK_ESCAPE", {}); |
michael@0 | 38 | } |
michael@0 | 39 | else { |
michael@0 | 40 | pointerUnLocked = true; |
michael@0 | 41 | document.mozCancelFullScreen(); |
michael@0 | 42 | } |
michael@0 | 43 | }, false); |
michael@0 | 44 | |
michael@0 | 45 | document.addEventListener("mozfullscreenchange", function(e) { |
michael@0 | 46 | if (document.mozFullScreenElement === div) { |
michael@0 | 47 | div.mozRequestPointerLock(); |
michael@0 | 48 | } |
michael@0 | 49 | else { |
michael@0 | 50 | runTests(); |
michael@0 | 51 | SimpleTest.finish(); |
michael@0 | 52 | } |
michael@0 | 53 | }, false); |
michael@0 | 54 | |
michael@0 | 55 | function start() { |
michael@0 | 56 | div.mozRequestFullScreen(); |
michael@0 | 57 | } |
michael@0 | 58 | </script> |
michael@0 | 59 | </pre> |
michael@0 | 60 | </body> |
michael@0 | 61 | </html> |