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.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=850442 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for getCurrentPosition </title> |
michael@0 | 8 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <script type="text/javascript" src="geolocation_common.js"></script> |
michael@0 | 10 | |
michael@0 | 11 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 12 | </head> |
michael@0 | 13 | <body> |
michael@0 | 14 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=850442">Mozilla Bug 850442</a> |
michael@0 | 15 | <p id="display"></p> |
michael@0 | 16 | <div id="content" style="display: none"> |
michael@0 | 17 | |
michael@0 | 18 | </div> |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | <script class="testbody" type="text/javascript"> |
michael@0 | 21 | |
michael@0 | 22 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 23 | |
michael@0 | 24 | resume_geolocationProvider(function() { |
michael@0 | 25 | force_prompt(true, function () { |
michael@0 | 26 | set_network_request_cache_enabled(false, function() { |
michael@0 | 27 | test1(); |
michael@0 | 28 | }); |
michael@0 | 29 | }); |
michael@0 | 30 | }); |
michael@0 | 31 | |
michael@0 | 32 | function done() { |
michael@0 | 33 | set_network_request_cache_enabled(true, function() { |
michael@0 | 34 | resume_geolocationProvider(function() { |
michael@0 | 35 | SimpleTest.finish(); |
michael@0 | 36 | }); |
michael@0 | 37 | }); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | function errorCallback(err) { |
michael@0 | 41 | ok(false, "error callback should not have been called"); |
michael@0 | 42 | done(); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function testCachedPosition() { |
michael@0 | 46 | var cached = null; |
michael@0 | 47 | navigator.geolocation.getCurrentPosition(function(pos) { |
michael@0 | 48 | // get cached position |
michael@0 | 49 | cached = pos; |
michael@0 | 50 | |
michael@0 | 51 | navigator.geolocation.getCurrentPosition(function(pos) { |
michael@0 | 52 | // force use of cached position, make sure |
michael@0 | 53 | // it's equal to what we have |
michael@0 | 54 | is(pos, cached, "position should be equal to cached position"); |
michael@0 | 55 | resume_geolocationProvider(function() { |
michael@0 | 56 | navigator.geolocation.getCurrentPosition(function(pos) { |
michael@0 | 57 | // force new position, can't be the one we have |
michael@0 | 58 | isnot(pos, cached, "new position should be different from the cached"); |
michael@0 | 59 | done(); |
michael@0 | 60 | }, errorCallback, {maximumAge: 0}); |
michael@0 | 61 | }); |
michael@0 | 62 | }, errorCallback, {maximumAge: 21600000}); |
michael@0 | 63 | }, errorCallback, {maximumAge: 21600000}); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | // ensure we have a position in cache, |
michael@0 | 67 | // and stop receiving new positions once we do so the |
michael@0 | 68 | // cache doesn't change |
michael@0 | 69 | var watchID; |
michael@0 | 70 | function test1() { |
michael@0 | 71 | watchID = navigator.geolocation.watchPosition( |
michael@0 | 72 | function(pos) { |
michael@0 | 73 | info("Stopping geolocation provider"); |
michael@0 | 74 | stop_geolocationProvider(function() {}); |
michael@0 | 75 | }, function(err) { |
michael@0 | 76 | is(err.code, err.TIMEOUT, "got TIMEOUT for watchPosition"); |
michael@0 | 77 | |
michael@0 | 78 | // no new positions in a while, |
michael@0 | 79 | // the cache should be stable now. |
michael@0 | 80 | navigator.geolocation.clearWatch(watchID); |
michael@0 | 81 | testCachedPosition(); |
michael@0 | 82 | }, {maximumAge: 0, timeout: 1000} |
michael@0 | 83 | ); |
michael@0 | 84 | } |
michael@0 | 85 | </script> |
michael@0 | 86 | </pre> |
michael@0 | 87 | </body> |
michael@0 | 88 | </html> |
michael@0 | 89 |