Tue, 06 Jan 2015 21:39:09 +0100
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.
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=633602
5 -->
6 <head>
7 <title>Bug 633602 - file_cursorPosEvents.html</title>
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js">
9 </script>
10 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
11 <script type="application/javascript" src="pointerlock_utils.js"></script>
12 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
13 <style type="text/css">
14 #child {
15 width: 100px;
16 height: 100px;
17 background-color:Green;
18 }
19 </style>
20 </head>
21 <body>
22 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602">
23 Mozilla Bug 633602</a>
25 <div id="parent">
26 <div id="child"></div>
27 </div>
29 <script type="application/javascript">
30 /*
31 * Test for Bug 633602
32 * Test will check to make sure that the following mouse events are no
33 * longer executed in pointer lock.
34 * - mouseover, mouseout, mouseenter, mouseleave
35 */
37 SimpleTest.waitForExplicitFinish();
39 function PointerEventStats() {
40 this.mouseEnter = false;
41 this.mouseLeave = false;
42 this.mouseOver = false;
43 this.mouseOut = false;
44 }
46 var parent
47 , child
48 , parentStats = new PointerEventStats()
49 , childStats = new PointerEventStats()
50 , isPointerLocked = false;
52 function runTests () {
53 ok(isPointerLocked, "expected mouse to be locked, but wasn't.");
55 is(childStats.mouseEnter, false,
56 "child's mouseenter should not be firing in Full Screen and Pointer Lock.");
57 is(childStats.mouseOver, false,
58 "child's mouseover should not be firing in Full Screen and Pointer Lock.");
59 is(childStats.mouseLeave, false,
60 "child's mouseleave should not be firing in Full Screen and Pointer Lock.");
61 is(childStats.mouseOut, false,
62 "child's mouseout should not be firing in Full Screen and Pointer Lock.");
64 is(parentStats.mouseEnter, false,
65 "parent's mouseenter should not be firing in Full Screen and Pointer Lock.");
66 is(parentStats.mouseOver, false,
67 "parent's mouseover should not be firing in Full Screen and Pointer Lock.");
68 is(parentStats.mouseLeave, false,
69 "parent's mouseleave should not be firing in Full Screen and Pointer Lock.");
70 is(parentStats.mouseOut, false,
71 "parent's mouseout should not be firing in Full Screen and Pointer Lock.");
72 }
74 var parentMoveListener = function () {
75 isPointerLocked = !!document.mozPointerLockElement;
76 removeEventListeners();
77 document.mozExitPointerLock();
78 };
80 var parentOutListener = function (e) {
81 parentStats.mouseOut = true;
82 };
83 var parentLeaveListener = function (e) {
84 parentStats.mouseLeave = true;
85 };
86 var parentOverListener = function (e) {
87 parentStats.mouseOver = true;
88 };
89 var parentEnterListener = function (e) {
90 parentStats.mouseEnter = true;
91 };
93 var childOutListener = function (e) {
94 childStats.mouseOut = true;
95 };
96 var childLeaveListener = function (e) {
97 childStats.mouseLeave = true;
98 };
99 var childOverListener = function (e) {
100 childStats.mouseOver = true;
101 };
102 var childEnterListener = function (e) {
103 childStats.mouseEnter = true;
104 };
106 function addEventListeners() {
107 parent.addEventListener("mousemove", parentMoveListener, false);
109 parent.addEventListener("mouseout", parentOutListener, false);
110 parent.addEventListener("mouseleave", parentLeaveListener, false);
111 parent.addEventListener("mouseover", parentOverListener, false);
112 parent.addEventListener("mouseenter", parentEnterListener, false);
114 child.addEventListener("mouseout", childOutListener, false);
115 child.addEventListener("mouseleave", childLeaveListener, false);
116 child.addEventListener("mouseover", childOverListener, false);
117 child.addEventListener("mouseenter", childEnterListener, false);
118 }
120 function removeEventListeners() {
121 parent.removeEventListener("mousemove", parentMoveListener, false);
123 parent.removeEventListener("mouseout", parentOutListener, false);
124 parent.removeEventListener("mouseleave", parentLeaveListener, false);
125 parent.removeEventListener("mouseover", parentOverListener, false);
126 parent.removeEventListener("mouseenter", parentEnterListener, false);
128 child.removeEventListener("mouseout", childOutListener, false);
129 child.removeEventListener("mouseleave", childLeaveListener, false);
130 child.removeEventListener("mouseover" , childOverListener, false);
131 child.removeEventListener("mouseenter", childEnterListener, false);
132 }
134 document.addEventListener("mozpointerlockchange", function (e) {
135 if (document.mozPointerLockElement === parent) {
136 addEventListeners();
137 synthesizeMouseAtCenter(child, { type: "mousemove" }, window);
138 }
139 else {
140 document.mozCancelFullScreen();
141 }
142 }, false);
144 document.addEventListener("mozfullscreenchange", function() {
145 if (document.mozFullScreenElement === parent) {
146 parent.mozRequestPointerLock();
147 }
148 else {
149 runTests();
150 SimpleTest.finish();
151 }
152 }, false);
154 function start() {
155 parent = document.getElementById("parent");
156 child = document.getElementById("child");
157 parent.mozRequestFullScreen();
158 }
159 </script>
160 </body>
161 </html>