tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_geolocation_reset_accuracy_wrap.js (1536B)


      1 const providerCID = Components.ID("{14aa4b81-e266-45cb-88f8-89595dece114}");
      2 const providerContract = "@mozilla.org/geolocation/provider;1";
      3 
      4 const categoryName = "geolocation-provider";
      5 
      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      do_send_remote_message("high_acc_enabled");
     22    }
     23  },
     24  _isHigh: false,
     25  _seenHigh: false,
     26 };
     27 
     28 function run_test() {
     29  // XPCShell does not get a profile by default. The ContentParent
     30  // depends on the remote settings service which uses IndexedDB and
     31  // IndexedDB needs a place where it can store databases.
     32  do_get_profile();
     33 
     34  Components.manager.nsIComponentRegistrar.registerFactory(
     35    providerCID,
     36    "Unit test geo provider",
     37    providerContract,
     38    provider
     39  );
     40 
     41  Services.catMan.addCategoryEntry(
     42    categoryName,
     43    "unit test",
     44    providerContract,
     45    false,
     46    true
     47  );
     48 
     49  Services.prefs.setBoolPref("geo.provider.network.scan", false);
     50 
     51  run_test_in_child("test_geolocation_reset_accuracy.js", check_results);
     52 }
     53 
     54 function check_results() {
     55  // check the provider was set to high accuracy during the test
     56  Assert.ok(provider._seenHigh);
     57  // check the provider is not currently set to high accuracy
     58  Assert.ok(!provider._isHigh);
     59 
     60  do_test_finished();
     61 }