dom/tests/mochitest/pointerlock/file_infiniteMovement.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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_movementXY.html</title>
michael@0 8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js">
michael@0 9 </script>
michael@0 10 <script type="text/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 <div id="div"></div>
michael@0 21 <pre id="test">
michael@0 22 <script type="application/javascript">
michael@0 23 /*
michael@0 24 * Test for Bug 633602
michael@0 25 * This test checks if mozMovementX and mozMovementY
michael@0 26 * are present in a mouse event object.
michael@0 27 * It also checks the values for mozMovementXY.
michael@0 28 * They should be equal to the current screenXY minus
michael@0 29 * the last screenXY
michael@0 30 * This test will also test that the incremental movement is
michael@0 31 * not constrained to the width of the screen.
michael@0 32 */
michael@0 33
michael@0 34 SimpleTest.waitForExplicitFinish();
michael@0 35
michael@0 36 var div = document.getElementById("div")
michael@0 37 , divCenterWidth = 0
michael@0 38 , divCenterHeight = 0
michael@0 39 , totalMovementX = 0
michael@0 40 , totalMovementY = 0;
michael@0 41
michael@0 42 function runTests () {
michael@0 43 ok(totalMovementX > div.getBoundingClientRect().width,
michael@0 44 "Should have moved more than one screen's worth in width." +
michael@0 45 "TotalX: " + totalMovementX + " Screensize X: " + div.getBoundingClientRect().width);
michael@0 46 ok(totalMovementY > div.getBoundingClientRect().height,
michael@0 47 "Should have moved more than one screen's worth in height." +
michael@0 48 "TotalY: " + totalMovementY + " Screensize Y: " + div.getBoundingClientRect().height);
michael@0 49 }
michael@0 50
michael@0 51 var firstMoveListener = function (e) {
michael@0 52 div.removeEventListener("mousemove", firstMoveListener, false);
michael@0 53 div.addEventListener("mousemove", secondMoveListener, false);
michael@0 54
michael@0 55 synthesizeMouse(div,(divCenterWidth/2) * 3,
michael@0 56 (divCenterHeight/2) * 3, {
michael@0 57 type: "mousemove"
michael@0 58 }, window);
michael@0 59 }
michael@0 60
michael@0 61 var secondMoveListener = function (e) {
michael@0 62 totalMovementX = divCenterWidth + ((divCenterWidth / 2) * 3);
michael@0 63 totalMovementY = divCenterHeight + ((divCenterHeight / 2) * 3);
michael@0 64
michael@0 65 div.removeEventListener("mousemove", secondMoveListener, false);
michael@0 66 document.mozCancelFullScreen();
michael@0 67 }
michael@0 68
michael@0 69 document.addEventListener("mozpointerlockchange", function (e) {
michael@0 70 if (document.mozPointerLockElement === div) {
michael@0 71 div.addEventListener("mousemove", firstMoveListener, false);
michael@0 72
michael@0 73 divCenterWidth = Math.round(div.getBoundingClientRect().width / 2);
michael@0 74 divCenterHeight = Math.round(div.getBoundingClientRect().height / 2);
michael@0 75
michael@0 76 synthesizeMouse(div, divCenterWidth, divCenterHeight, {
michael@0 77 type: "mousemove"
michael@0 78 }, window);
michael@0 79 }
michael@0 80 }, false);
michael@0 81
michael@0 82 document.addEventListener("mozfullscreenchange", function() {
michael@0 83 if (document.mozFullScreenElement === div) {
michael@0 84 div.mozRequestPointerLock();
michael@0 85 }
michael@0 86 else {
michael@0 87 runTests();
michael@0 88 SimpleTest.finish();
michael@0 89 }
michael@0 90 }, false);
michael@0 91
michael@0 92 function start() {
michael@0 93 div.mozRequestFullScreen();
michael@0 94 }
michael@0 95 </script>
michael@0 96 </pre>
michael@0 97 </body>
michael@0 98 </html>

mercurial