dom/tests/mochitest/pointerlock/file_doubleLock.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

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_doubleLockCallBack.html</title>
michael@0 8 <script type="text/javascript"
michael@0 9 src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10 <script type="text/javascript"
michael@0 11 src="/tests/SimpleTest/EventUtils.js"></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 <style type="text/css">
michael@0 15 #test-element { background-color: #94E01B; width:100px; height:100px; }
michael@0 16 </style>
michael@0 17 </head>
michael@0 18 <body>
michael@0 19 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602">
michael@0 20 Mozilla Bug 633602</a>
michael@0 21 <div id="div"></div>
michael@0 22 <pre id="test">
michael@0 23 <script type="text/javascript">
michael@0 24 /*
michael@0 25 * Test for Bug 633602
michael@0 26 * If element requests pointerlock on itself while in pointerlock state
michael@0 27 * mozpointerlockchange event should be dispatched
michael@0 28 */
michael@0 29
michael@0 30 SimpleTest.waitForExplicitFinish();
michael@0 31
michael@0 32 var div = document.getElementById("div")
michael@0 33 , numberOfLocks = 0;
michael@0 34
michael@0 35 function runTests () {
michael@0 36 is(numberOfLocks, 2, "Requesting pointer lock on a locked element " +
michael@0 37 "should dispatch mozpointerlockchange event");
michael@0 38 }
michael@0 39
michael@0 40 document.addEventListener("mozpointerlockchange", function (e) {
michael@0 41 if (document.mozPointerLockElement === div) {
michael@0 42 if (numberOfLocks === 2) {
michael@0 43 document.mozCancelFullScreen();
michael@0 44 }
michael@0 45 else {
michael@0 46 numberOfLocks++;
michael@0 47 div.mozRequestPointerLock();
michael@0 48 }
michael@0 49 }
michael@0 50 }, false);
michael@0 51
michael@0 52 document.addEventListener("mozfullscreenchange", function (e) {
michael@0 53 if (document.mozFullScreenElement === div) {
michael@0 54 div.mozRequestPointerLock();
michael@0 55 }
michael@0 56 else {
michael@0 57 runTests();
michael@0 58 SimpleTest.finish();
michael@0 59 }
michael@0 60 }, false);
michael@0 61
michael@0 62 function start() {
michael@0 63 console.log('started');
michael@0 64 div.mozRequestFullScreen();
michael@0 65 }
michael@0 66 </script>
michael@0 67 </pre>
michael@0 68 </body>
michael@0 69 </html>

mercurial