Backout a74bd5095902, Bug 959405 - Please update the Buri Moz-central, 1.3, 1.2 with...
[gecko.git] / dom / tests / unit / test_geolocation_reset_accuracy_wrap.js
blob84a4ac27db878723a4bb343a64d0bd0730fa8ad9
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
42 function run_test()
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);
63 function check_results()
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();