dom/tests/mochitest/pointerlock/file_movementXY.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 * Checks if mozMovementX and mozMovementY are present
michael@0 26 * in the 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 */
michael@0 31
michael@0 32 SimpleTest.waitForExplicitFinish();
michael@0 33
michael@0 34 function MouseMovementStats() {
michael@0 35 this.screenX = false;
michael@0 36 this.screenY = false;
michael@0 37 this.mozMovementX = false;
michael@0 38 this.mozMovementY = false;
michael@0 39 }
michael@0 40
michael@0 41 var div = document.getElementById("div")
michael@0 42 , divCenterWidth = 0
michael@0 43 , divCenterHeight = 0
michael@0 44 , mozMovementX = false
michael@0 45 , mozMovementY = false
michael@0 46 , firstMove = new MouseMovementStats()
michael@0 47 , secondMove = new MouseMovementStats();
michael@0 48
michael@0 49 function runTests () {
michael@0 50 ok(mozMovementX && mozMovementY, "mozMovementX and " +
michael@0 51 "mozMovementY should exist in mouse events objects.");
michael@0 52 is(secondMove.mozMovementX, secondMove.screenX - firstMove.screenX,
michael@0 53 "mozMovementX should be equal to eNow.screenX-ePrevious.screenX");
michael@0 54 is(secondMove.mozMovementY, secondMove.screenY - firstMove.screenY,
michael@0 55 "mozMovementY should be equal to eNow.screenY-ePrevious.screenY");
michael@0 56 }
michael@0 57
michael@0 58 var moveMouse = function(e) {
michael@0 59 mozMovementX = ("mozMovementX" in e);
michael@0 60 mozMovementY = ("mozMovementY" in e);
michael@0 61
michael@0 62 div.removeEventListener("mousemove", moveMouse, false);
michael@0 63 div.addEventListener("mousemove", moveMouseAgain, false);
michael@0 64
michael@0 65 firstMove.screenX = e.screenX;
michael@0 66 firstMove.screenY = e.screenY;
michael@0 67
michael@0 68 divCenterWidth = Math.round(div.getBoundingClientRect().width / 2);
michael@0 69 divCenterHeight = Math.round(div.getBoundingClientRect().height / 2);
michael@0 70
michael@0 71 synthesizeMouse(div, (divCenterWidth + 10), (divCenterHeight + 10), {
michael@0 72 type: "mousemove"
michael@0 73 }, window);
michael@0 74 };
michael@0 75
michael@0 76 var moveMouseAgain = function(e) {
michael@0 77 secondMove.screenX = e.screenX;
michael@0 78 secondMove.screenY = e.screenY;
michael@0 79 secondMove.mozMovementX = e.mozMovementX;
michael@0 80 secondMove.mozMovementY = e.mozMovementY;
michael@0 81
michael@0 82 div.removeEventListener("mousemove", moveMouseAgain, false);
michael@0 83 document.mozCancelFullScreen();
michael@0 84 };
michael@0 85
michael@0 86 function fullscreenchange() {
michael@0 87 if (document.mozFullScreenElement === div) {
michael@0 88 var screenX = window.screenX;
michael@0 89 var screenY = window.screenY;
michael@0 90 if (screenX != 0 || screenY != 0) {
michael@0 91 todo(screenX == 0 && screenY == 0,
michael@0 92 "We should only receive fullscreenchange once we've finished fullscreen transition");
michael@0 93 setTimeout(fullscreenchange, 250);
michael@0 94 return;
michael@0 95 }
michael@0 96 div.addEventListener("mousemove", moveMouse, false);
michael@0 97 synthesizeMouseAtCenter(div, {type: "mousemove"}, window);
michael@0 98 }
michael@0 99 else {
michael@0 100 runTests();
michael@0 101 SimpleTest.finish();
michael@0 102 }
michael@0 103 }
michael@0 104
michael@0 105 document.addEventListener("mozfullscreenchange", fullscreenchange, false);
michael@0 106
michael@0 107 function start() {
michael@0 108 div.mozRequestFullScreen();
michael@0 109 }
michael@0 110 </script>
michael@0 111 </pre>
michael@0 112 </body>
michael@0 113 </html>

mercurial