Bug 1941128 - Turn off network.dns.native_https_query on Mac again
[gecko.git] / dom / tests / unit / test_geolocation_reset_accuracy.js
blob3cb3374e09a2ef765a238144fed214d7f2b10e2d
1 const providerCID = Components.ID("{14aa4b81-e266-45cb-88f8-89595dece114}");
2 const providerContract = "@mozilla.org/geolocation/provider;1";
4 const categoryName = "geolocation-provider";
6 var provider = {
7   QueryInterface: ChromeUtils.generateQI([
8     "nsIFactory",
9     "nsIGeolocationProvider",
10   ]),
11   createInstance: function eventsink_ci(iid) {
12     return this.QueryInterface(iid);
13   },
14   startup() {},
15   watch() {},
16   shutdown() {},
17   setHighAccuracy(enable) {
18     this._isHigh = enable;
19     if (enable) {
20       this._seenHigh = true;
21       executeSoon(stop_high_accuracy_watch);
22     }
23   },
24   _isHigh: false,
25   _seenHigh: false,
28 function successCallback() {
29   Assert.ok(false);
30   do_test_finished();
33 function errorCallback() {
34   Assert.ok(false);
35   do_test_finished();
38 var geolocation;
39 var watchID2;
41 function run_test() {
42   if (runningInParent) {
43     // XPCShell does not get a profile by default. The geolocation service
44     // depends on the settings service which uses IndexedDB and IndexedDB
45     // needs a place where it can store databases.
46     do_get_profile();
48     Components.manager.nsIComponentRegistrar.registerFactory(
49       providerCID,
50       "Unit test geo provider",
51       providerContract,
52       provider
53     );
55     Services.catMan.addCategoryEntry(
56       categoryName,
57       "unit test",
58       providerContract,
59       false,
60       true
61     );
63     Services.prefs.setBoolPref("geo.provider.network.scan", false);
64   }
66   do_test_pending();
68   geolocation = Cc["@mozilla.org/geolocation;1"].createInstance(Ci.nsISupports);
69   geolocation.watchPosition(successCallback, errorCallback);
70   watchID2 = geolocation.watchPosition(successCallback, errorCallback, {
71     enableHighAccuracy: true,
72   });
74   if (!runningInParent) {
75     do_await_remote_message("high_acc_enabled", stop_high_accuracy_watch);
76   }
79 function stop_high_accuracy_watch() {
80   geolocation.clearWatch(watchID2);
81   check_results();
82   do_test_finished();
85 function check_results() {
86   if (runningInParent) {
87     // check the provider was set to high accuracy during the test
88     Assert.ok(provider._seenHigh);
89     // check the provider is not currently set to high accuracy
90     Assert.ok(!provider._isHigh);
91   }
92   do_test_finished();