1 const { HttpServer
} = ChromeUtils
.importESModule(
2 "resource://testing-common/httpd.sys.mjs"
6 var geolocation
= null;
10 function terminate(succ
) {
12 geolocation
.clearWatch(watchID
);
15 function successCallback() {
18 function errorCallback() {
23 QueryInterface
: ChromeUtils
.generateQI(["nsIObserver"]),
25 observe(subject
, topic
, data
) {
26 if (data
== "shutdown") {
29 if (!this._numProviders
) {
30 httpserver
.stop(function () {
35 } else if (data
== "starting") {
44 function geoHandler(metadata
, response
) {
53 var position
= JSON
.stringify(georesponse
);
54 response
.setStatusLine("1.0", 200, "OK");
55 response
.setHeader("Cache-Control", "no-cache", false);
56 response
.setHeader("Content-Type", "aplication/x-javascript", false);
57 response
.write(position
);
61 // XPCShell does not get a profile by default. The geolocation service
62 // depends on the settings service which uses IndexedDB and IndexedDB
63 // needs a place where it can store databases.
66 // only kill this test when shutdown is called on the provider.
69 httpserver
= new HttpServer();
70 httpserver
.registerPathHandler("/geo", geoHandler
);
73 Services
.prefs
.setCharPref(
74 "geo.provider.network.url",
75 "http://localhost:" + httpserver
.identity
.primaryPort
+ "/geo"
77 Services
.prefs
.setBoolPref("geo.provider.network.scan", false);
79 var obs
= Cc
["@mozilla.org/observer-service;1"].getService();
80 obs
= obs
.QueryInterface(Ci
.nsIObserverService
);
81 obs
.addObserver(observer
, "geolocation-device-events");
83 geolocation
= Cc
["@mozilla.org/geolocation;1"].getService(Ci
.nsISupports
);
84 watchID
= geolocation
.watchPosition(successCallback
, errorCallback
);