2018-01-30 02:20:18 +03:00
|
|
|
ChromeUtils.import("resource://testing-common/httpd.js");
|
2012-12-31 20:36:46 +04:00
|
|
|
|
|
|
|
var httpserver = null;
|
|
|
|
var geolocation = null;
|
|
|
|
var success = false;
|
|
|
|
var watchId = -1;
|
|
|
|
|
|
|
|
function geoHandler(metadata, response)
|
|
|
|
{
|
|
|
|
var georesponse = {
|
|
|
|
status: "OK",
|
|
|
|
location: {
|
|
|
|
lat: 42,
|
|
|
|
lng: 42,
|
|
|
|
},
|
|
|
|
accuracy: 42,
|
|
|
|
};
|
|
|
|
var position = JSON.stringify(georesponse);
|
|
|
|
response.processAsync();
|
|
|
|
response.setStatusLine("1.0", 200, "OK");
|
|
|
|
response.setHeader("Cache-Control", "no-cache", false);
|
|
|
|
response.setHeader("Content-Type", "aplication/x-javascript", false);
|
|
|
|
do_timeout(5000, function() {
|
|
|
|
response.write(position);
|
|
|
|
response.finish();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function successCallback() {
|
2017-12-21 13:08:17 +03:00
|
|
|
Assert.ok(false);
|
2012-12-31 20:36:46 +04:00
|
|
|
do_test_finished();
|
|
|
|
}
|
|
|
|
|
|
|
|
function errorCallback() {
|
2017-12-21 13:08:17 +03:00
|
|
|
Assert.ok(true);
|
2012-12-31 20:36:46 +04:00
|
|
|
do_test_finished();
|
|
|
|
}
|
|
|
|
|
|
|
|
function run_test()
|
|
|
|
{
|
|
|
|
do_test_pending();
|
|
|
|
|
|
|
|
if (Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
|
|
|
|
.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT) {
|
2013-09-28 15:25:46 +04:00
|
|
|
// XPCShell does not get a profile by default. The geolocation service
|
|
|
|
// depends on the settings service which uses IndexedDB and IndexedDB
|
|
|
|
// needs a place where it can store databases.
|
|
|
|
do_get_profile();
|
|
|
|
|
2013-07-10 07:45:02 +04:00
|
|
|
httpserver = new HttpServer();
|
|
|
|
httpserver.registerPathHandler("/geo", geoHandler);
|
|
|
|
httpserver.start(-1);
|
2012-12-31 20:36:46 +04:00
|
|
|
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
|
|
|
prefs.setBoolPref("geo.wifi.scan", false);
|
2013-07-10 07:45:02 +04:00
|
|
|
prefs.setCharPref("geo.wifi.uri", "http://localhost:" +
|
|
|
|
httpserver.identity.primaryPort + "/geo");
|
2013-12-02 19:27:57 +04:00
|
|
|
prefs.setBoolPref("dom.testing.ignore_ipc_principal", true);
|
2012-12-31 20:36:46 +04:00
|
|
|
}
|
|
|
|
|
2013-04-03 01:28:27 +04:00
|
|
|
geolocation = Cc["@mozilla.org/geolocation;1"].getService(Ci.nsISupports);
|
2012-12-31 20:36:46 +04:00
|
|
|
geolocation.getCurrentPosition(successCallback, errorCallback, {timeout: 2000});
|
|
|
|
}
|