Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 const Cc = Components.classes;
2 const Ci = Components.interfaces;
4 const providerCID = Components.ID("{14aa4b81-e266-45cb-88f8-89595dece114}");
5 const providerContract = "@mozilla.org/geolocation/provider;1";
7 const categoryName = "geolocation-provider";
9 var provider = {
10 QueryInterface: function eventsink_qi(iid) {
11 if (iid.equals(Components.interfaces.nsISupports) ||
12 iid.equals(Components.interfaces.nsIFactory) ||
13 iid.equals(Components.interfaces.nsIGeolocationProvider))
14 return this;
15 throw Components.results.NS_ERROR_NO_INTERFACE;
16 },
17 createInstance: function eventsink_ci(outer, iid) {
18 if (outer)
19 throw Components.results.NS_ERROR_NO_AGGREGATION;
20 return this.QueryInterface(iid);
21 },
22 lockFactory: function eventsink_lockf(lock) {
23 throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
24 },
25 startup: function() {
26 },
27 watch: function() {
28 },
29 shutdown: function() {
30 },
31 setHighAccuracy: function(enable) {
32 this._isHigh = enable;
33 if (enable) {
34 this._seenHigh = true;
35 do_send_remote_message('high_acc_enabled');
36 }
37 },
38 _isHigh: false,
39 _seenHigh: false
40 };
42 function run_test()
43 {
44 // XPCShell does not get a profile by default. The geolocation service
45 // depends on the settings service which uses IndexedDB and IndexedDB
46 // needs a place where it can store databases.
47 do_get_profile();
49 Components.manager.nsIComponentRegistrar.registerFactory(providerCID,
50 "Unit test geo provider", providerContract, provider);
51 var catMan = Components.classes["@mozilla.org/categorymanager;1"]
52 .getService(Components.interfaces.nsICategoryManager);
53 catMan.nsICategoryManager.addCategoryEntry(categoryName, "unit test",
54 providerContract, false, true);
56 var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
57 prefs.setBoolPref("dom.testing.ignore_ipc_principal", true);
58 prefs.setBoolPref("geo.wifi.scan", false);
60 run_test_in_child("test_geolocation_reset_accuracy.js", check_results);
61 }
63 function check_results()
64 {
65 // check the provider was set to high accuracy during the test
66 do_check_true(provider._seenHigh);
67 // check the provider is not currently set to high accuracy
68 do_check_false(provider._isHigh);
70 do_test_finished();
71 }