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=478911
5 -->
6 <head>
7 <title>Test for getCurrentPosition </title>
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <script type="text/javascript" src="geolocation_common.js"></script>
11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
12 </head>
13 <body>
14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=777594">Mozilla Bug 777594</a>
15 <p id="display"></p>
16 <div id="content" style="display: none">
18 </div>
19 <pre id="test">
20 <script class="testbody" type="text/javascript">
22 SimpleTest.waitForExplicitFinish();
24 resume_geolocationProvider(function() {
25 force_prompt(true, test1);
26 });
28 if (SpecialPowers.isMainProcess()) {
29 SpecialPowers.Cu.import("resource://gre/modules/SettingsChangeNotifier.jsm");
30 }
32 function test1() {
33 //This pushPermissions call is after pushPrefEnv call and pushPrefEnv calls follow after this
34 SpecialPowers.pushPermissions([{'type': 'settings-read', 'allow': true, 'context': document}, {'type': 'settings-write', 'allow': true, 'context': document}], test2);
35 }
37 var watchId;
38 function test2() {
39 ok(navigator.geolocation, "get geolocation object");
41 toggleGeolocationSetting(false, function() {
42 ok(true, "turned off geolocation via mozSettings");
43 setTimeout(function() {
44 watchId = navigator.geolocation.watchPosition(successCallbackAfterMozsettingOff,
45 failureCallbackAfterMozsettingOff);
46 }, 500); // need to wait a bit for all of these async callbacks to finish
47 });
48 }
50 function successCallbackAfterMozsettingOff(position) {
51 ok(false, "Success callback should not have been called after setting geolocation.enabled to false.");
53 navigator.geolocation.clearWatch(watchId);
54 toggleGeolocationSetting(true, function() {
55 ok(true, "turned on geolocation via mozSettings");
56 setTimeout(function() {
57 watchId = navigator.geolocation.watchPosition(successCallbackAfterMozsettingOn,
58 failureCallbackAfterMozsettingOn);
59 }, 500); // need to wait a bit for all of these async callbacks to finish
60 });
61 }
63 function failureCallbackAfterMozsettingOff(error) {
64 ok(true, "Geolocation didn't work after setting geolocation.enabled to false.");
66 navigator.geolocation.clearWatch(watchId);
67 toggleGeolocationSetting(true, function() {
68 ok(true, "turned on geolocation via mozSettings");
69 setTimeout(function() {
70 watchId = navigator.geolocation.watchPosition(successCallbackAfterMozsettingOn,
71 failureCallbackAfterMozsettingOn);
72 }, 500); // need to wait a bit for all of these async callbacks to finish
73 });
74 }
76 function successCallbackAfterMozsettingOn(position) {
77 ok(true, "Geolocation worked after setting geolocation.enabled to true.");
79 navigator.geolocation.clearWatch(watchId);
80 SimpleTest.finish();
81 }
83 function failureCallbackAfterMozsettingOn(error) {
84 ok(false, "Geolocation didn't work after setting geolocation.enabled to true.");
86 navigator.geolocation.clearWatch(watchId);
87 SimpleTest.finish();
88 }
90 </script>
91 </pre>
92 </body>
93 </html>