author | Doug Turner <doug.turner@gmail.com> |
Mon, 29 Apr 2013 20:22:27 -0700 | |
changeset 130308 | 6117a8d5aebb14f27cdc1159096225b9b8564835 |
parent 130307 | a9a56206a0dc0b3ce880cf770f123b2ba6bc6b02 |
child 130309 | 03f3cbc57ba9c3067afdefcb17bcb0e90ca031aa |
push id | 24609 |
push user | emorley@mozilla.com |
push date | Tue, 30 Apr 2013 12:53:53 +0000 |
treeherder | mozilla-central@3fb2370f4871 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mvines |
bugs | 866893 |
milestone | 23.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -377,18 +377,16 @@ @BINPATH@/components/nsFilePicker.js #endif @BINPATH@/components/nsHelperAppDlg.manifest @BINPATH@/components/nsHelperAppDlg.js @BINPATH@/components/nsDownloadManagerUI.manifest @BINPATH@/components/nsDownloadManagerUI.js @BINPATH@/components/NetworkGeolocationProvider.manifest @BINPATH@/components/NetworkGeolocationProvider.js -@BINPATH@/components/GPSDGeolocationProvider.manifest -@BINPATH@/components/GPSDGeolocationProvider.js @BINPATH@/browser/components/nsSidebar.manifest @BINPATH@/browser/components/nsSidebar.js @BINPATH@/components/extensions.manifest @BINPATH@/components/addonManager.js @BINPATH@/components/amContentHandler.js @BINPATH@/components/amWebInstallListener.js @BINPATH@/components/nsBlocklistService.js #ifdef MOZ_UPDATER
--- a/dom/src/geolocation/nsGeolocation.cpp +++ b/dom/src/geolocation/nsGeolocation.cpp @@ -574,33 +574,33 @@ nsGeolocationRequest::GetPrincipal() { if (!mLocator) { return nullptr; } return mLocator->GetPrincipal(); } bool -nsGeolocationRequest::Update(nsIDOMGeoPosition* aPosition, bool aIsBetter) +nsGeolocationRequest::Update(nsIDOMGeoPosition* aPosition) { if (!mAllowed) { return false; } // Only dispatch callbacks if this is the first position for this request, or // if the accuracy is as good or improving. // // This ensures that all listeners get at least one position callback, particularly // in the case when newly detected positions are all less accurate than the cached one. // // Fixes bug 596481 nsCOMPtr<nsIRunnable> ev; - if (mIsFirstUpdate || aIsBetter) { + if (mIsFirstUpdate) { mIsFirstUpdate = false; ev = new RequestSendLocationEvent(aPosition, - aIsBetter, + true, this, mIsWatchPositionRequest ? nullptr : mLocator); } else { ev = new RequestRestartTimerEvent(this); } NS_DispatchToMainThread(ev); return true; } @@ -661,27 +661,16 @@ nsresult nsGeolocationService::Init() return NS_ERROR_FAILURE; } if (XRE_GetProcessType() == GeckoProcessType_Content) { sGeoInitPending = false; return NS_OK; } - nsCOMPtr<nsIGeolocationProvider> provider = do_GetService(NS_GEOLOCATION_PROVIDER_CONTRACTID); - if (provider) { - mProviders.AppendObject(provider); - } - - // look up any providers that were registered via the category manager - nsCOMPtr<nsICategoryManager> catMan(do_GetService("@mozilla.org/categorymanager;1")); - if (!catMan) { - return NS_ERROR_FAILURE; - } - // check if the geolocation service is enable from settings nsCOMPtr<nsISettingsService> settings = do_GetService("@mozilla.org/settingsService;1"); if (settings) { nsCOMPtr<nsISettingsServiceLock> settingsLock; nsresult rv = settings->CreateLock(getter_AddRefs(settingsLock)); NS_ENSURE_SUCCESS(rv, rv); @@ -699,69 +688,36 @@ nsresult nsGeolocationService::Init() nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService(); if (!obs) { return NS_ERROR_FAILURE; } obs->AddObserver(this, "quit-application", false); obs->AddObserver(this, "mozsettings-changed", false); - nsCOMPtr<nsISimpleEnumerator> geoproviders; - catMan->EnumerateCategory("geolocation-provider", getter_AddRefs(geoproviders)); - if (geoproviders) { - - bool hasMore; - while (NS_SUCCEEDED(geoproviders->HasMoreElements(&hasMore)) && hasMore) { - nsCOMPtr<nsISupports> elem; - geoproviders->GetNext(getter_AddRefs(elem)); - - nsCOMPtr<nsISupportsCString> elemString = do_QueryInterface(elem); - - nsAutoCString name; - elemString->GetData(name); - - nsXPIDLCString spec; - catMan->GetCategoryEntry("geolocation-provider", name.get(), getter_Copies(spec)); - - provider = do_GetService(spec); - if (provider) { - mProviders.AppendObject(provider); - } - } - } - - // we should move these providers outside of this file! dft - #ifdef MOZ_MAEMO_LIBLOCATION - provider = new MaemoLocationProvider(); - if (provider) { - mProviders.AppendObject(provider); - } + mProvider = new MaemoLocationProvider(); #endif #ifdef MOZ_ENABLE_QTMOBILITY - provider = new QTMLocationProvider(); - if (provider) { - mProviders.AppendObject(provider); - } + mProvider = new QTMLocationProvider(); #endif #ifdef MOZ_WIDGET_ANDROID - provider = new AndroidLocationProvider(); - if (provider) { - mProviders.AppendObject(provider); - } + mProvider = new AndroidLocationProvider(); #endif #ifdef MOZ_WIDGET_GONK - provider = do_GetService(GONK_GPS_GEOLOCATION_PROVIDER_CONTRACTID); - if (provider) { - mProviders.AppendObject(provider); + mProvider = do_GetService(GONK_GPS_GEOLOCATION_PROVIDER_CONTRACTID); +#endif + + nsCOMPtr<nsIGeolocationProvider> providerOveride = do_GetService(NS_GEOLOCATION_PROVIDER_CONTRACTID); + if (providerOveride) { + mProvider = providerOveride; } -#endif return NS_OK; } nsGeolocationService::~nsGeolocationService() { } @@ -859,116 +815,24 @@ nsGeolocationService::Observe(nsISupport } return NS_ERROR_FAILURE; } NS_IMETHODIMP nsGeolocationService::Update(nsIDOMGeoPosition *aSomewhere) { - // here we have to determine this aSomewhere is a "better" - // position than any previously recv'ed. - - bool isBetter = IsBetterPosition(aSomewhere); - - if (isBetter) { - SetCachedPosition(aSomewhere); - } + SetCachedPosition(aSomewhere); for (uint32_t i = 0; i< mGeolocators.Length(); i++) { - mGeolocators[i]->Update(aSomewhere, isBetter); + mGeolocators[i]->Update(aSomewhere); } return NS_OK; } -bool -nsGeolocationService::IsBetterPosition(nsIDOMGeoPosition *aSomewhere) -{ - if (!aSomewhere) { - return false; - } - - if (mProviders.Count() == 1 || !mLastPosition) { - return true; - } - - nsCOMPtr<nsIDOMGeoPositionCoords> coords; - mLastPosition->GetCoords(getter_AddRefs(coords)); - if (!coords) { - return false; - } - - double oldAccuracy; - nsresult rv = coords->GetAccuracy(&oldAccuracy); - NS_ENSURE_SUCCESS(rv, false); - - double oldLat, oldLon; - rv = coords->GetLongitude(&oldLon); - NS_ENSURE_SUCCESS(rv, false); - - rv = coords->GetLatitude(&oldLat); - NS_ENSURE_SUCCESS(rv, false); - - aSomewhere->GetCoords(getter_AddRefs(coords)); - if (!coords) { - return false; - } - - double newAccuracy; - rv = coords->GetAccuracy(&newAccuracy); - NS_ENSURE_SUCCESS(rv, false); - - double newLat, newLon; - rv = coords->GetLongitude(&newLon); - NS_ENSURE_SUCCESS(rv, false); - - rv = coords->GetLatitude(&newLat); - NS_ENSURE_SUCCESS(rv, false); - - // Latitude and longitude is reported in degrees. - // However, it is easier to work in radian: - // see: http://en.wikipedia.org/wiki/Radian - double radsInDeg = M_PI / 180.0; - - newLat *= radsInDeg; - newLon *= radsInDeg; - oldLat *= radsInDeg; - oldLon *= radsInDeg; - - // WGS84 equatorial radius of earth = 6378137m - // http://en.wikipedia.org/wiki/WGS84 - double radius = 6378137; - - // We want to calculate the "Great Circle distance" - // between the point (lat1, lon1) and (lat2, lon2). We - // will use the spherical law of cosines to the triangle - // formed by our two points and the north pole. - // - // a = sin ( lat1 ) * sin ( lat2 ) + cos ( lat1 ) * cos (lat2) * cos (lon1 - lon2) - // R = radius of circle - // distance = arccos ( a ) * R - // - // http://en.wikipedia.org/wiki/Great-circle_distance - - double delta = acos( (sin(newLat) * sin(oldLat)) + - (cos(newLat) * cos(oldLat) * cos(oldLon - newLon)) ) * radius; - - // The threshold is when the distance between the two - // positions exceeds the worse (larger value) of the two - // accuracies. - double max_accuracy = std::max(oldAccuracy, newAccuracy); - if (delta > max_accuracy) - return true; - - // check to see if the aSomewhere position is more accurate - if (oldAccuracy >= newAccuracy) - return true; - - return false; -} void nsGeolocationService::SetCachedPosition(nsIDOMGeoPosition* aPosition) { mLastPosition = aPosition; } nsIDOMGeoPosition* @@ -997,24 +861,26 @@ nsGeolocationService::StartDevice(nsIPri } // Start them up! nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService(); if (!obs) { return NS_ERROR_FAILURE; } - for (int32_t i = 0; i < mProviders.Count(); i++) { - mProviders[i]->Startup(); - mProviders[i]->Watch(this, aRequestPrivate); - obs->NotifyObservers(mProviders[i], - "geolocation-device-events", - NS_LITERAL_STRING("starting").get()); + if (!mProvider) { + return NS_ERROR_FAILURE; } + mProvider->Startup(); + mProvider->Watch(this, aRequestPrivate); + obs->NotifyObservers(mProvider, + "geolocation-device-events", + NS_LITERAL_STRING("starting").get()); + return NS_OK; } void nsGeolocationService::SetDisconnectTimer() { if (!mDisconnectTimer) { mDisconnectTimer = do_CreateInstance("@mozilla.org/timer;1"); @@ -1045,25 +911,21 @@ nsGeolocationService::SetHigherAccuracy( if (XRE_GetProcessType() == GeckoProcessType_Content) { ContentChild* cpc = ContentChild::GetSingleton(); cpc->SendSetGeolocationHigherAccuracy(highRequired); return; } if (!mHigherAccuracy && highRequired) { - for (int32_t i = 0; i < mProviders.Count(); i++) { - mProviders[i]->SetHighAccuracy(true); - } + mProvider->SetHighAccuracy(true); } if (mHigherAccuracy && !highRequired) { - for (int32_t i = 0; i < mProviders.Count(); i++) { - mProviders[i]->SetHighAccuracy(false); - } + mProvider->SetHighAccuracy(false); } mHigherAccuracy = highRequired; } void nsGeolocationService::StopDevice() { @@ -1078,22 +940,24 @@ nsGeolocationService::StopDevice() return; // bail early } nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService(); if (!obs) { return; } - for (int32_t i = 0; i < mProviders.Count(); i++) { - mProviders[i]->Shutdown(); - obs->NotifyObservers(mProviders[i], - "geolocation-device-events", - NS_LITERAL_STRING("shutdown").get()); + if (!mProvider) { + return; } + + mProvider->Shutdown(); + obs->NotifyObservers(mProvider, + "geolocation-device-events", + NS_LITERAL_STRING("shutdown").get()); } nsRefPtr<nsGeolocationService> nsGeolocationService::sService; already_AddRefed<nsGeolocationService> nsGeolocationService::GetGeolocationService() { nsRefPtr<nsGeolocationService> result; @@ -1272,31 +1136,31 @@ Geolocation::RemoveRequest(nsGeolocation // ever called WatchPosition() and we do not want to mess // around with the ordering of the array. Instead, just // mark the request as "cleared". aRequest->MarkCleared(); } void -Geolocation::Update(nsIDOMGeoPosition *aSomewhere, bool aIsBetter) +Geolocation::Update(nsIDOMGeoPosition *aSomewhere) { if (!WindowOwnerStillExists()) { return Shutdown(); } for (uint32_t i = mPendingCallbacks.Length(); i> 0; i--) { - if (mPendingCallbacks[i-1]->Update(aSomewhere, aIsBetter)) { + if (mPendingCallbacks[i-1]->Update(aSomewhere)) { mPendingCallbacks.RemoveElementAt(i-1); } } // notify everyone that is watching for (uint32_t i = 0; i< mWatchingCallbacks.Length(); i++) { - mWatchingCallbacks[i]->Update(aSomewhere, aIsBetter); + mWatchingCallbacks[i]->Update(aSomewhere); } } void Geolocation::SetCachedPosition(Position* aPosition) { mCachedPosition = aPosition; }
--- a/dom/src/geolocation/nsGeolocation.h +++ b/dom/src/geolocation/nsGeolocation.h @@ -66,18 +66,17 @@ class nsGeolocationRequest const mozilla::dom::GeoPositionCallback& callback, const mozilla::dom::GeoPositionErrorCallback& errorCallback, mozilla::idl::GeoPositionOptions* aOptions, bool watchPositionRequest = false, int32_t watchId = 0); void Shutdown(); // Called by the geolocation device to notify that a location has changed. - // isBetter: the accuracy is as good or better than the previous position. - bool Update(nsIDOMGeoPosition* aPosition, bool aIsBetter); + bool Update(nsIDOMGeoPosition* aPosition); void SendLocation(nsIDOMGeoPosition* location, bool aCachePosition); void MarkCleared(); bool WantsHighAccuracy() {return mOptions && mOptions->enableHighAccuracy;} bool IsActive() {return !mCleared;} bool Allowed() {return mAllowed;} void SetTimeoutTimer(); nsIPrincipal* GetPrincipal(); @@ -130,17 +129,16 @@ public: void HandleMozsettingValue(const bool aValue); // Management of the Geolocation objects void AddLocator(mozilla::dom::Geolocation* locator); void RemoveLocator(mozilla::dom::Geolocation* locator); void SetCachedPosition(nsIDOMGeoPosition* aPosition); nsIDOMGeoPosition* GetCachedPosition(); - bool IsBetterPosition(nsIDOMGeoPosition *aSomewhere); // Find and startup a geolocation device (gps, nmea, etc.) nsresult StartDevice(nsIPrincipal* aPrincipal, bool aRequestPrivate); // Stop the started geolocation device (gps, nmea, etc.) void StopDevice(); // create, or reinitalize the callback timer @@ -155,17 +153,17 @@ private: ~nsGeolocationService(); // Disconnect timer. When this timer expires, it clears all pending callbacks // and closes down the provider, unless we are watching a point, and in that // case, we disable the disconnect timer. nsCOMPtr<nsITimer> mDisconnectTimer; // The object providing geo location information to us. - nsCOMArray<nsIGeolocationProvider> mProviders; + nsCOMPtr<nsIGeolocationProvider> mProvider; // mGeolocators are not owned here. Their constructor // adds them to this list, and their destructor removes // them from this list. nsTArray<mozilla::dom::Geolocation*> mGeolocators; // This is the last geo position that we have seen. nsCOMPtr<nsIDOMGeoPosition> mLastPosition; @@ -197,17 +195,17 @@ public: nsIDOMWindow* GetParentObject() const; virtual JSObject* WrapObject(JSContext *aCtx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE; int32_t WatchPosition(PositionCallback& aCallback, PositionErrorCallback* aErrorCallback, const PositionOptions& aOptions, ErrorResult& aRv); void GetCurrentPosition(PositionCallback& aCallback, PositionErrorCallback* aErrorCallback, const PositionOptions& aOptions, ErrorResult& aRv); // Called by the geolocation device to notify that a location has changed. - void Update(nsIDOMGeoPosition* aPosition, bool aIsBetter); + void Update(nsIDOMGeoPosition* aPosition); void SetCachedPosition(Position* aPosition); Position* GetCachedPosition(); // Returns true if any of the callbacks are repeating bool HasActiveCallbacks(); // Remove request from all callbacks arrays
deleted file mode 100644 --- a/dom/system/GPSDGeolocationProvider.js +++ /dev/null @@ -1,204 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); - -const Ci = Components.interfaces; -const Cc = Components.classes; - -var gLoggingEnabled = false; - -function LOG(aMsg) { - if (gLoggingEnabled) - { - aMsg = ("*** GPSD GEO: " + aMsg); - Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService).logStringMessage(aMsg); - dump(aMsg); - } -} - -function GeoPositionCoordsObject(latitude, longitude, altitude, accuracy, altitudeAccuracy, heading, speed) { - - this.latitude = latitude; - this.longitude = longitude; - this.altitude = altitude; - this.accuracy = accuracy; - this.altitudeAccuracy = altitudeAccuracy; - this.heading = heading; - this.speed = speed; - -}; - -GeoPositionCoordsObject.prototype = { - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPositionCoords]), - - // Class Info is required to be able to pass objects back into the DOM. - classInfo: XPCOMUtils.generateCI({interfaces: [Ci.nsIDOMGeoPositionCoords], - flags: Ci.nsIClassInfo.DOM_OBJECT, - classDescription: "Geoposition Coordinate Object"}), - - latitude: null, - longitude: null, - altitude: null, - accuracy: null, - altitudeAccuracy: null, - heading: null, - speed: null, - -}; - -function GeoPositionObject(latitude, longitude, altitude, accuracy, altitudeAccuracy, heading, speed, timestamp) { - this.coords = new GeoPositionCoordsObject(latitude, longitude, altitude, accuracy, altitudeAccuracy, heading, speed); - this.timestamp = timestamp; -}; - -GeoPositionObject.prototype = { - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPosition]), - - // Class Info is required to be able to pass objects back into the DOM. - classInfo: XPCOMUtils.generateCI({interfaces: [Ci.nsIDOMGeoPosition], - flags: Ci.nsIClassInfo.DOM_OBJECT, - classDescription: "Geoposition Object"}), - - coords: null, - timestamp: null, - -}; - -function GPSDProvider() { - this.prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch).QueryInterface(Ci.nsIPrefService); - - try { - gLoggingEnabled = this.prefService.getBoolPref("geo.gpsd.logging.enabled"); - } catch (e) {} -}; - -GPSDProvider.prototype = { - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIGeolocationProvider]), - - classID: Components.ID("{0A3BE523-0F2A-32CC-CCD8-1E5986D5A79D}"), - - prefService: null, - - transport: null, - outputStream: null, - inputStream: null, - - startup: function() { - - LOG("startup called\n"); - var socketTransportService = Cc["@mozilla.org/network/socket-transport-service;1"].getService(Ci.nsISocketTransportService); - - var hostIPAddr = "127.0.0.1"; - var hostPort = "2947"; - - try { - hostIPAddr = this.prefService.getCharPref("geo.gpsd.host.ipaddr"); - } catch (e) {} - - try { - hostPort = this.prefService.getCharPref("geo.gpsd.host.port"); - } catch (e) {} - - LOG("Host info: " + hostIPAddr + ":" + hostPort + "\n"); - - this.transport = socketTransportService.createTransport(null, 0, hostIPAddr, hostPort, null); - - // Alright to open streams here as they are non-blocking by default - this.outputStream = this.transport.openOutputStream(0,0,0); - this.inputStream = this.transport.openInputStream(0,0,0); - - }, - - shutdown: function() { - LOG("shutdown called\n"); - this.outputStream.close(); - this.inputStream.close(); - this.transport.close(Components.results.NS_OK); - }, - - watch: function(c, isPrivate) { - LOG("watch called\n"); - try { - // Go into "watcher" mode - var mode = '?WATCH={"enable":true,"json":true}'; - this.outputStream.write(mode, mode.length); - } catch (e) { return; } - - var dataListener = { - onStartRequest: function(request, context) {}, - onStopRequest: function(request, context, status) {}, - onDataAvailable: function(request, context, inputStream, offset, count) { - - var sInputStream = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(Ci.nsIScriptableInputStream); - sInputStream.init(inputStream); - - var responseSentence = sInputStream.read(count); - - var response = null; - try { - response = JSON.parse(responseSentence); - } catch (e) { return; } - - // is the right kind of sentence? - if (response.class != 'TPV') { - //don't do anything - return; - } - - // is there a fix? - if (response.mode == '1') { - // don't do anything - return; - } - - LOG("Got info: " + responseSentence); - - // The API requires these values, if one is missing - // we return without updating the position. - if (response.time && response.lat && response.lon - && response.epx && response.epy) { - var timestamp = response.time; // UTC - var latitude = response.lat; // degrees - var longitude = response.lon; // degrees - var horizontalError = Math.max(response.epx,response.epy); } // meters - else { return; } - - // Altitude is optional, but if it's present, so must be vertical precision. - var altitude = null; - var verticalError = null; - if (response.alt && response.epv) { - altitude = response.alt; // meters - verticalError = response.epv; // meters - } - - var speed = null; - if (response.speed) { var speed = response.speed; } // meters/sec - - var course = null; - if (response.track) { var course = response.track; } // degrees - - var geoPos = new GeoPositionObject(latitude, longitude, altitude, horizontalError, verticalError, course, speed, timestamp); - - c.update(geoPos); - LOG("Position updated:" + timestamp + "," + latitude + "," + longitude + "," - + horizontalError + "," + altitude + "," + verticalError + "," + course - + "," + speed); - - } - - }; - - var pump = Cc["@mozilla.org/network/input-stream-pump;1"].createInstance(Ci.nsIInputStreamPump); - pump.init(this.inputStream, -1, -1, 0, 0, false); - pump.asyncRead(dataListener, null); - - }, - -}; - -this.NSGetFactory = XPCOMUtils.generateNSGetFactory([GPSDProvider]);
deleted file mode 100644 --- a/dom/system/GPSDGeolocationProvider.manifest +++ /dev/null @@ -1,3 +0,0 @@ -component {0A3BE523-0F2A-32CC-CCD8-1E5986D5A79D} GPSDGeolocationProvider.js -contract @mozilla.org/geolocation/gpsd/provider;1 {0A3BE523-0F2A-32CC-CCD8-1E5986D5A79D} -category geolocation-provider GPSDProvider @mozilla.org/geolocation/gpsd/provider;1
--- a/dom/system/Makefile.in +++ b/dom/system/Makefile.in @@ -32,18 +32,16 @@ LOCAL_INCLUDES += \ $(NULL) # On Systems that have build in geolocation providers, # we really do not need these. ifneq (Android,$(OS_TARGET)) EXTRA_COMPONENTS = \ NetworkGeolocationProvider.js \ NetworkGeolocationProvider.manifest \ - GPSDGeolocationProvider.js \ - GPSDGeolocationProvider.manifest \ $(NULL) endif ifeq (gonk,$(MOZ_WIDGET_TOOLKIT)) EXTRA_COMPONENTS = \ NetworkGeolocationProvider.js \ NetworkGeolocationProvider.manifest \ $(NULL)
deleted file mode 100644 --- a/dom/tests/unit/test_geo_provider_accuracy.js +++ /dev/null @@ -1,81 +0,0 @@ -const Cc = Components.classes; -const Ci = Components.interfaces; - -const providerCID = Components.ID("{14aa4b81-e266-45cb-88f8-89595dece114}"); -const providerContract = "@mozilla.org/geolocation/unittest/geoprovider;1"; - -const categoryName = "geolocation-provider"; - -var provider = { - QueryInterface: function eventsink_qi(iid) { - if (iid.equals(Components.interfaces.nsISupports) || - iid.equals(Components.interfaces.nsIFactory) || - iid.equals(Components.interfaces.nsIGeolocationProvider)) - return this; - throw Components.results.NS_ERROR_NO_INTERFACE; - }, - createInstance: function eventsink_ci(outer, iid) { - if (outer) - throw Components.results.NS_ERROR_NO_AGGREGATION; - return this.QueryInterface(iid); - }, - lockFactory: function eventsink_lockf(lock) { - throw Components.results.NS_ERROR_NOT_IMPLEMENTED; - }, - startup: function() { - }, - watch: function(callback, isPrivate) { - do_execute_soon(function() { - callback.update({coords: {latitude: 42, longitude: 42}, timestamp: 0}); - }); - }, - shutdown: function() { - }, - setHighAccuracy: function(enable) { - if (enable) { - this._seenHigh = true; - } else { - this._seenNotHigh = true; - } - }, - _seenHigh: false, - _seenNotHigh: false -}; - -let runningInParent = true; -try { - runningInParent = Components.classes["@mozilla.org/xre/runtime;1"]. - getService(Components.interfaces.nsIXULRuntime).processType - == Components.interfaces.nsIXULRuntime.PROCESS_TYPE_DEFAULT; -} -catch (e) { } - -var geolocation; -function run_test() -{ - do_test_pending(); - - if (runningInParent) { - Components.manager.nsIComponentRegistrar.registerFactory(providerCID, - "Unit test geo provider", providerContract, provider); - var catMan = Components.classes["@mozilla.org/categorymanager;1"] - .getService(Components.interfaces.nsICategoryManager); - catMan.nsICategoryManager.addCategoryEntry(categoryName, "unit test", - providerContract, false, true); - - var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); - prefs.setBoolPref("geo.testing.ignore_ipc_principal", true); - prefs.setBoolPref("geo.wifi.scan", false); - } - - geolocation = Cc["@mozilla.org/geolocation;1"].createInstance(Ci.nsISupports); - geolocation.getCurrentPosition(function() { - geolocation.getCurrentPosition(function() { - if (runningInParent) { - do_check_true(provider._seenNotHigh); - do_check_true(provider._seenHigh); - } - do_test_finished(); - }, null, {enableHighAccuracy: false, maxAge: 0}); - }, null, {enableHighAccuracy: true, maxAge: 0}); -} \ No newline at end of file
deleted file mode 100644 --- a/dom/tests/unit/test_geo_provider_accuracy_wrap.js +++ /dev/null @@ -1,62 +0,0 @@ -const Cc = Components.classes; -const Ci = Components.interfaces; - -const providerCID = Components.ID("{14aa4b81-e266-45cb-88f8-89595dece114}"); -const providerContract = "@mozilla.org/geolocation/unittest/geoprovider;1"; - -const categoryName = "geolocation-provider"; - -var provider = { - QueryInterface: function eventsink_qi(iid) { - if (iid.equals(Components.interfaces.nsISupports) || - iid.equals(Components.interfaces.nsIFactory) || - iid.equals(Components.interfaces.nsIGeolocationProvider)) - return this; - throw Components.results.NS_ERROR_NO_INTERFACE; - }, - createInstance: function eventsink_ci(outer, iid) { - if (outer) - throw Components.results.NS_ERROR_NO_AGGREGATION; - return this.QueryInterface(iid); - }, - lockFactory: function eventsink_lockf(lock) { - throw Components.results.NS_ERROR_NOT_IMPLEMENTED; - }, - startup: function() { - }, - watch: function(callback, isPrivate) { - do_execute_soon(function() { - callback.update({coords: {latitude: 42, longitude: 42}, timestamp: 0}); - }); - }, - shutdown: function() { - }, - setHighAccuracy: function(enable) { - if (enable) { - this._seenHigh = true; - } else { - this._seenNotHigh = true; - } - }, - _seenHigh: false, - _seenNotHigh: false -}; - -function run_test() -{ - Components.manager.nsIComponentRegistrar.registerFactory(providerCID, - "Unit test geo provider", providerContract, provider); - var catMan = Components.classes["@mozilla.org/categorymanager;1"] - .getService(Components.interfaces.nsICategoryManager); - catMan.nsICategoryManager.addCategoryEntry(categoryName, "unit test", - providerContract, false, true); - - var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); - prefs.setBoolPref("geo.testing.ignore_ipc_principal", true); - prefs.setBoolPref("geo.wifi.scan", false); - run_test_in_child("test_geo_provider_accuracy.js", function() { - do_check_true(provider._seenNotHigh); - do_check_true(provider._seenHigh); - do_test_finished(); - }); -} \ No newline at end of file
deleted file mode 100644 --- a/dom/tests/unit/test_multiple_geo_listeners.js +++ /dev/null @@ -1,70 +0,0 @@ -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; -const Cr = Components.results; - -Cu.import("resource://testing-common/httpd.js"); - -var httpserver = null; -var geolocation = null; -var success = false; -var watchId = -1; - -let gAccuracy = 42; -function geoHandler(metadata, response) -{ - var georesponse = { - status: "OK", - location: { - lat: 0.45, - lng: 0.45, - }, - accuracy: gAccuracy, - }; - var position = JSON.stringify(georesponse); - response.setStatusLine("1.0", 200, "OK"); - response.setHeader("Cache-Control", "no-cache", false); - response.setHeader("Content-Type", "aplication/x-javascript", false); - response.write(position); -} - -function errorCallback() { - do_check_true(false); - do_test_finished(); -} - -function run_test() -{ - do_test_pending(); - - httpserver = new HttpServer(); - httpserver.registerPathHandler("/geo", geoHandler); - httpserver.start(4444); - - if (Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime) - .processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT) { - var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); - prefs.setBoolPref("geo.wifi.scan", false); - prefs.setCharPref("geo.wifi.uri", "http://localhost:4444/geo"); - prefs.setBoolPref("geo.testing.ignore_ipc_principal", true); - } - - let timesCalled = 0; - geolocation = Cc["@mozilla.org/geolocation;1"].createInstance(Ci.nsISupports); - geolocation.watchPosition(function(pos) { - do_check_eq(++timesCalled, 1); - do_check_eq(pos.coords.accuracy, gAccuracy); - - gAccuracy = 420; - geolocation2 = Cc["@mozilla.org/geolocation;1"].createInstance(Ci.nsISupports); - geolocation2.getCurrentPosition(function(pos) { - do_check_eq(pos.coords.accuracy, gAccuracy); - - gAccuracy = 400; - geolocation2.getCurrentPosition(function(pos) { - do_check_eq(pos.coords.accuracy, 42); - do_test_finished(); - }, errorCallback); - }, errorCallback, {maximumAge: 0}); - }, errorCallback, {maximumAge: 0}); -}
deleted file mode 100644 --- a/dom/tests/unit/test_multiple_geo_listeners_wrap.js +++ /dev/null @@ -1,10 +0,0 @@ -const Cc = Components.classes; -const Ci = Components.interfaces; - -function run_test() { - var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); - prefs.setBoolPref("geo.wifi.scan", false); - prefs.setCharPref("geo.wifi.uri", "http://localhost:4444/geo"); - prefs.setBoolPref("geo.testing.ignore_ipc_principal", true); - run_test_in_child("test_multiple_geo_listeners.js"); -} \ No newline at end of file
--- a/dom/tests/unit/xpcshell.ini +++ b/dom/tests/unit/xpcshell.ini @@ -5,14 +5,8 @@ tail = [test_bug319968.js] [test_bug465752.js] [test_geolocation_provider.js] # Bug 684962: test hangs consistently on Android skip-if = os == "android" [test_geolocation_timeout.js] [test_geolocation_timeout_wrap.js] skip-if = os == "mac" -[test_geo_provider_accuracy.js] -[test_geo_provider_accuracy_wrap.js] -skip-if = os == "mac" -[test_multiple_geo_listeners.js] -[test_multiple_geo_listeners_wrap.js] -skip-if = os == "mac"
--- a/mobile/android/installer/package-manifest.in +++ b/mobile/android/installer/package-manifest.in @@ -301,18 +301,16 @@ @BINPATH@/components/nsFilePicker.js #endif @BINPATH@/components/nsHelperAppDlg.manifest @BINPATH@/components/nsHelperAppDlg.js @BINPATH@/components/nsDownloadManagerUI.manifest @BINPATH@/components/nsDownloadManagerUI.js @BINPATH@/components/NetworkGeolocationProvider.manifest @BINPATH@/components/NetworkGeolocationProvider.js -@BINPATH@/components/GPSDGeolocationProvider.manifest -@BINPATH@/components/GPSDGeolocationProvider.js @BINPATH@/components/nsSidebar.manifest @BINPATH@/components/nsSidebar.js @BINPATH@/components/extensions.manifest @BINPATH@/components/addonManager.js @BINPATH@/components/amContentHandler.js @BINPATH@/components/amWebInstallListener.js @BINPATH@/components/nsBlocklistService.js