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 <!--https://bugzilla.mozilla.org/show_bug.cgi?id=746885-->
4 <head>
5 <title>Bug 746885</title>
6 <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
7 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
8 <script type="application/javascript" src="pointerlock_utils.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
10 </head>
11 <body>
12 <a target="_blank"
13 href="https://bugzilla.mozilla.org/show_bug.cgi?id=746885">
14 Mozilla Bug 746885
15 </a>
16 <div id="div"></div>
17 <pre id="test">
18 <script type="text/javascript">
19 /*
20 * Test for Bug 746885
21 * When requesting pointer lock on a domain that doesn't have fullscreen
22 * permission, the pointer lock request should be delayed until approval
23 * has been granted.
24 */
26 SimpleTest.waitForExplicitFinish();
28 // Ensure fullscreen won't be automatically granted for this document's domain.
29 SpecialPowers.removeFullscreenAllowed(document);
31 var div = document.getElementById("div");
32 var isApproved = false;
34 document.addEventListener("mozpointerlockchange",
35 function (e) {
36 is(isApproved, true, "Should only receive mozpointerlockchange when we've been approved for fullscreen.");
37 document.mozCancelFullScreen();
38 }, false);
40 function approveFullscreen() {
41 isApproved = true;
42 SpecialPowers.setFullscreenAllowed(document);
43 }
45 document.addEventListener("mozfullscreenchange", function(e) {
46 if (document.mozFullScreenElement === div) {
47 // First entered fullscreen. Request pointer lock...
48 div.mozRequestPointerLock();
49 // ... But only approve fullscreen after a delay, giving the pointer
50 // lock request time to run if it were going to. Note we need two timeouts
51 // here to because if we were to fail and the pointer lock request were to
52 // succeed without approval, we'd need to give it time to run, and time for
53 // its asynchronously dispatched mozpointerlockchange to run.
54 setTimeout(function(){ setTimeout(approveFullscreen, 0); }, 0);
55 } else {
56 SimpleTest.finish();
57 }
58 }, false);
60 function start() {
61 div.mozRequestFullScreen();
62 }
63 </script>
64 </pre>
65 </body>
66 </html>