Bug 1218627 - Removing MozSettings API from Geo (and fixing randomly failing tests).
MozReview-Commit-ID: J74XihIkeHH
--- a/dom/geolocation/nsGeolocation.cpp
+++ b/dom/geolocation/nsGeolocation.cpp
@@ -5,17 +5,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsXULAppAPI.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/Telemetry.h"
#include "nsAutoPtr.h"
-#include "nsISettingsService.h"
#include "nsGeolocation.h"
#include "nsDOMClassInfoID.h"
#include "nsComponentManagerUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsContentUtils.h"
#include "nsContentPermissionHelper.h"
#include "nsIDocument.h"
@@ -27,17 +26,16 @@
#include "mozilla/Hal.h"
#include "mozilla/Services.h"
#include "mozilla/Unused.h"
#include "mozilla/Preferences.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/dom/Event.h"
#include "mozilla/WeakPtr.h"
#include "mozilla/dom/PermissionMessageUtils.h"
-#include "mozilla/dom/SettingChangeNotificationBinding.h"
#include "mozilla/dom/WakeLock.h"
class nsIPrincipal;
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidLocationProvider.h"
#endif
@@ -57,19 +55,16 @@ class nsIPrincipal;
#include "WindowsLocationProvider.h"
#include "mozilla/WindowsVersion.h"
#endif
// Some limit to the number of get or watch geolocation requests
// that a window can make.
#define MAX_GEO_REQUESTS_PER_WINDOW 1500
-// The settings key.
-#define GEO_SETTINGS_ENABLED "geolocation.enabled"
-
using mozilla::Unused; // <snicker>
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::hal;
class nsGeolocationRequest final
: public nsIContentPermissionRequest
, public nsIGeolocationUpdate
@@ -145,63 +140,16 @@ CreatePositionOptionsCopy(const Position
geoOptions->mEnableHighAccuracy = aOptions.mEnableHighAccuracy;
geoOptions->mMaximumAge = aOptions.mMaximumAge;
geoOptions->mTimeout = aOptions.mTimeout;
return geoOptions;
}
-class GeolocationSettingsCallback : public nsISettingsServiceCallback
-{
- virtual ~GeolocationSettingsCallback() {
- MOZ_COUNT_DTOR(GeolocationSettingsCallback);
- }
-
-public:
- NS_DECL_ISUPPORTS
-
- GeolocationSettingsCallback() {
- MOZ_COUNT_CTOR(GeolocationSettingsCallback);
- }
-
- NS_IMETHOD Handle(const nsAString& aName, JS::Handle<JS::Value> aResult) override
- {
- MOZ_ASSERT(NS_IsMainThread());
-
- // The geolocation is enabled by default:
- bool value = true;
- if (aResult.isBoolean()) {
- value = aResult.toBoolean();
- }
-
- MozSettingValue(value);
- return NS_OK;
- }
-
- NS_IMETHOD HandleError(const nsAString& aName) override
- {
- NS_WARNING("Unable to get value for '" GEO_SETTINGS_ENABLED "'");
-
- // Default it's enabled:
- MozSettingValue(true);
- return NS_OK;
- }
-
- void MozSettingValue(const bool aValue)
- {
- RefPtr<nsGeolocationService> gs = nsGeolocationService::GetGeolocationService();
- if (gs) {
- gs->HandleMozsettingValue(aValue);
- }
- }
-};
-
-NS_IMPL_ISUPPORTS(GeolocationSettingsCallback, nsISettingsServiceCallback)
-
class RequestPromptEvent : public Runnable
{
public:
RequestPromptEvent(nsGeolocationRequest* aRequest, nsWeakPtr aWindow)
: mRequest(aRequest)
, mWindow(aWindow)
{
}
@@ -377,22 +325,24 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContentPermissionRequest)
NS_INTERFACE_MAP_ENTRY(nsIContentPermissionRequest)
NS_INTERFACE_MAP_ENTRY(nsIGeolocationUpdate)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsGeolocationRequest)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsGeolocationRequest)
NS_IMPL_CYCLE_COLLECTION(nsGeolocationRequest, mCallback, mErrorCallback, mLocator)
+
void
nsGeolocationRequest::Notify()
{
SetTimeoutTimer();
NotifyErrorAndShutdown(nsIDOMGeoPositionError::TIMEOUT);
}
+
void
nsGeolocationRequest::NotifyErrorAndShutdown(uint16_t aErrorCode)
{
MOZ_ASSERT(!mShutdown, "timeout after shutdown");
if (!mIsWatchPositionRequest) {
Shutdown();
mLocator->RemoveRequest(this);
}
@@ -554,16 +504,17 @@ nsGeolocationRequest::Allow(JS::HandleVa
NS_IMETHODIMP
nsGeolocationRequest::GetRequester(nsIContentPermissionRequester** aRequester)
{
NS_ENSURE_ARG_POINTER(aRequester);
nsCOMPtr<nsIContentPermissionRequester> requester = mRequester;
requester.forget(aRequester);
+
return NS_OK;
}
void
nsGeolocationRequest::SetTimeoutTimer()
{
StopTimeoutTimer();
@@ -633,32 +584,34 @@ nsGeolocationRequest::SendLocation(nsIDO
nsIDOMGeoPositionCallback* callback = mCallback.GetXPCOMCallback();
MOZ_ASSERT(callback);
callback->HandleEvent(aPosition);
}
SetTimeoutTimer();
MOZ_ASSERT(mShutdown || mIsWatchPositionRequest,
"non-shutdown getCurrentPosition request after callback!");
}
+
nsIPrincipal*
nsGeolocationRequest::GetPrincipal()
{
if (!mLocator) {
return nullptr;
}
return mLocator->GetPrincipal();
}
NS_IMETHODIMP
nsGeolocationRequest::Update(nsIDOMGeoPosition* aPosition)
{
nsCOMPtr<nsIRunnable> ev = new RequestSendLocationEvent(aPosition, this);
NS_DispatchToMainThread(ev);
return NS_OK;
}
+
NS_IMETHODIMP
nsGeolocationRequest::NotifyError(uint16_t aErrorCode)
{
MOZ_ASSERT(NS_IsMainThread());
RefPtr<PositionError> positionError = new PositionError(mLocator, aErrorCode);
positionError->NotifyCallback(mErrorCallback);
return NS_OK;
}
@@ -690,16 +643,17 @@ NS_IMPL_ISUPPORTS(nsGeolocationRequest::
NS_IMETHODIMP
nsGeolocationRequest::TimerCallbackHolder::Notify(nsITimer*)
{
if (mRequest && mRequest->mLocator) {
RefPtr<nsGeolocationRequest> request(mRequest);
request->Notify();
}
+
return NS_OK;
}
////////////////////////////////////////////////////
// nsGeolocationService
////////////////////////////////////////////////////
NS_INTERFACE_MAP_BEGIN(nsGeolocationService)
@@ -708,59 +662,38 @@ NS_INTERFACE_MAP_BEGIN(nsGeolocationServ
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(nsGeolocationService)
NS_IMPL_RELEASE(nsGeolocationService)
static bool sGeoEnabled = true;
-static bool sGeoInitPending = true;
static int32_t sProviderTimeout = 6000; // Time, in milliseconds, to wait for the location provider to spin up.
nsresult nsGeolocationService::Init()
{
Preferences::AddIntVarCache(&sProviderTimeout, "geo.timeout", sProviderTimeout);
Preferences::AddBoolVarCache(&sGeoEnabled, "geo.enabled", sGeoEnabled);
if (!sGeoEnabled) {
return NS_ERROR_FAILURE;
}
if (XRE_IsContentProcess()) {
- sGeoInitPending = false;
return NS_OK;
}
- // 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(nullptr, getter_AddRefs(settingsLock));
- NS_ENSURE_SUCCESS(rv, rv);
-
- RefPtr<GeolocationSettingsCallback> callback = new GeolocationSettingsCallback();
- rv = settingsLock->Get(GEO_SETTINGS_ENABLED, callback);
- NS_ENSURE_SUCCESS(rv, rv);
- } else {
- // If we cannot obtain the settings service, we continue
- // assuming that the geolocation is enabled:
- sGeoInitPending = false;
- }
-
// geolocation service can be enabled -> now register observer
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
if (!obs) {
return NS_ERROR_FAILURE;
}
obs->AddObserver(this, "xpcom-shutdown", false);
- obs->AddObserver(this, "mozsettings-changed", false);
#ifdef MOZ_WIDGET_ANDROID
mProvider = new AndroidLocationProvider();
#endif
#ifdef MOZ_WIDGET_GONK
// GonkGPSGeolocationProvider can be started at boot up time for initialization reasons.
// do_getService gets hold of the already initialized component and starts
@@ -811,82 +744,35 @@ nsresult nsGeolocationService::Init()
return NS_OK;
}
nsGeolocationService::~nsGeolocationService()
{
}
-void
-nsGeolocationService::HandleMozsettingChanged(nsISupports* aSubject)
-{
- // The string that we're interested in will be a JSON string that looks like:
- // {"key":"gelocation.enabled","value":true}
-
- RootedDictionary<SettingChangeNotification> setting(RootingCx());
- if (!WrappedJSToDictionary(aSubject, setting)) {
- return;
- }
- if (!setting.mKey.EqualsASCII(GEO_SETTINGS_ENABLED)) {
- return;
- }
- if (!setting.mValue.isBoolean()) {
- return;
- }
-
- HandleMozsettingValue(setting.mValue.toBoolean());
-}
-
-void
-nsGeolocationService::HandleMozsettingValue(const bool aValue)
-{
- if (!aValue) {
- // turn things off
- StopDevice();
- Update(nullptr);
- mLastPosition.position = nullptr;
- sGeoEnabled = false;
- } else {
- sGeoEnabled = true;
- }
-
- if (sGeoInitPending) {
- sGeoInitPending = false;
- for (uint32_t i = 0, length = mGeolocators.Length(); i < length; ++i) {
- mGeolocators[i]->ServiceReady();
- }
- }
-}
-
NS_IMETHODIMP
nsGeolocationService::Observe(nsISupports* aSubject,
const char* aTopic,
const char16_t* aData)
{
if (!strcmp("xpcom-shutdown", aTopic)) {
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
if (obs) {
obs->RemoveObserver(this, "xpcom-shutdown");
- obs->RemoveObserver(this, "mozsettings-changed");
}
for (uint32_t i = 0; i< mGeolocators.Length(); i++) {
mGeolocators[i]->Shutdown();
}
StopDevice();
return NS_OK;
}
- if (!strcmp("mozsettings-changed", aTopic)) {
- HandleMozsettingChanged(aSubject);
- return NS_OK;
- }
-
if (!strcmp("timer-callback", aTopic)) {
// decide if we can close down the service.
for (uint32_t i = 0; i< mGeolocators.Length(); i++)
if (mGeolocators[i]->HasActiveCallbacks()) {
SetDisconnectTimer();
return NS_OK;
}
@@ -900,21 +786,24 @@ nsGeolocationService::Observe(nsISupport
}
NS_IMETHODIMP
nsGeolocationService::Update(nsIDOMGeoPosition *aSomewhere)
{
if (aSomewhere) {
SetCachedPosition(aSomewhere);
}
+
for (uint32_t i = 0; i< mGeolocators.Length(); i++) {
mGeolocators[i]->Update(aSomewhere);
}
+
return NS_OK;
}
+
NS_IMETHODIMP
nsGeolocationService::NotifyError(uint16_t aErrorCode)
{
for (uint32_t i = 0; i < mGeolocators.Length(); i++) {
mGeolocators[i]->NotifyError(aErrorCode);
}
return NS_OK;
}
@@ -930,17 +819,17 @@ CachedPositionAndAccuracy
nsGeolocationService::GetCachedPosition()
{
return mLastPosition;
}
nsresult
nsGeolocationService::StartDevice(nsIPrincipal *aPrincipal)
{
- if (!sGeoEnabled || sGeoInitPending) {
+ if (!sGeoEnabled) {
return NS_ERROR_NOT_AVAILABLE;
}
// we do not want to keep the geolocation devices online
// indefinitely. Close them down after a reasonable period of
// inactivivity
SetDisconnectTimer();
@@ -981,17 +870,16 @@ void
nsGeolocationService::StopDisconnectTimer()
{
if (mDisconnectTimer) {
mDisconnectTimer->Cancel();
mDisconnectTimer = nullptr;
}
}
-
void
nsGeolocationService::SetDisconnectTimer()
{
if (!mDisconnectTimer) {
mDisconnectTimer = do_CreateInstance("@mozilla.org/timer;1");
} else {
mDisconnectTimer->Cancel();
}
@@ -1004,51 +892,47 @@ nsGeolocationService::SetDisconnectTimer
bool
nsGeolocationService::HighAccuracyRequested()
{
for (uint32_t i = 0; i < mGeolocators.Length(); i++) {
if (mGeolocators[i]->HighAccuracyRequested()) {
return true;
}
}
+
return false;
}
void
nsGeolocationService::UpdateAccuracy(bool aForceHigh)
{
bool highRequired = aForceHigh || HighAccuracyRequested();
if (XRE_IsContentProcess()) {
ContentChild* cpc = ContentChild::GetSingleton();
if (cpc->IsAlive()) {
cpc->SendSetGeolocationHigherAccuracy(highRequired);
}
+
return;
}
- if (!mHigherAccuracy && highRequired) {
- mProvider->SetHighAccuracy(true);
- }
-
- if (mHigherAccuracy && !highRequired) {
- mProvider->SetHighAccuracy(false);
- }
-
+ mProvider->SetHighAccuracy(!mHigherAccuracy && highRequired);
mHigherAccuracy = highRequired;
}
void
nsGeolocationService::StopDevice()
{
StopDisconnectTimer();
if (XRE_IsContentProcess()) {
ContentChild* cpc = ContentChild::GetSingleton();
cpc->SendRemoveGeolocationListener();
+
return; // bail early
}
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
if (!obs) {
return;
}
@@ -1067,23 +951,25 @@ nsGeolocationService::StopDevice()
StaticRefPtr<nsGeolocationService> nsGeolocationService::sService;
already_AddRefed<nsGeolocationService>
nsGeolocationService::GetGeolocationService()
{
RefPtr<nsGeolocationService> result;
if (nsGeolocationService::sService) {
result = nsGeolocationService::sService;
+
return result.forget();
}
result = new nsGeolocationService();
if (NS_FAILED(result->Init())) {
return nullptr;
}
+
ClearOnShutdown(&nsGeolocationService::sService);
nsGeolocationService::sService = result;
return result.forget();
}
void
nsGeolocationService::AddLocator(Geolocation* aLocator)
{
@@ -1178,31 +1064,31 @@ Geolocation::Init(nsPIDOMWindowInner* aC
// If no aContentDom was passed into us, we are being used
// by chrome/c++ and have no mOwner, no mPrincipal, and no need
// to prompt.
mService = nsGeolocationService::GetGeolocationService();
if (mService) {
mService->AddLocator(this);
}
+
return NS_OK;
}
bool
Geolocation::ContainsRequest(nsGeolocationRequest* aRequest)
{
- if (aRequest->IsWatch()) {
- if (mWatchingCallbacks.Contains(aRequest)) {
+ if (aRequest->IsWatch() && mWatchingCallbacks.Contains(aRequest)) {
return true;
- }
- } else {
- if (mPendingCallbacks.Contains(aRequest)) {
- return true;
- }
}
+
+ if (mPendingCallbacks.Contains(aRequest)) {
+ return true;
+ }
+
return false;
}
NS_IMETHODIMP
Geolocation::HandleEvent(nsIDOMEvent* aEvent)
{
@@ -1216,33 +1102,37 @@ Geolocation::HandleEvent(nsIDOMEvent* aE
MOZ_ASSERT(doc);
if (doc->Hidden()) {
WakeLockInformation info;
GetWakeLockInfo(NS_LITERAL_STRING("gps"), &info);
MOZ_ASSERT(XRE_IsContentProcess());
ContentChild* cpc = ContentChild::GetSingleton();
+
if (!info.lockingProcesses().Contains(cpc->GetID())) {
cpc->SendRemoveGeolocationListener();
mService->StopDisconnectTimer();
}
- } else {
- mService->SetDisconnectTimer();
+
+ return NS_OK;
+ }
+
+ mService->SetDisconnectTimer();
- // We will unconditionally allow all the requests in the callbacks
- // because if a request is put into either of these two callbacks,
- // it means that it has been allowed before.
- // That's why when we resume them, we unconditionally allow them again.
- for (uint32_t i = 0, length = mWatchingCallbacks.Length(); i < length; ++i) {
- mWatchingCallbacks[i]->Allow(JS::UndefinedHandleValue);
- }
- for (uint32_t i = 0, length = mPendingCallbacks.Length(); i < length; ++i) {
- mPendingCallbacks[i]->Allow(JS::UndefinedHandleValue);
- }
+ // We will unconditionally allow all the requests in the callbacks
+ // because if a request is put into either of these two callbacks,
+ // it means that it has been allowed before.
+ // That's why when we resume them, we unconditionally allow them again.
+ for (uint32_t i = 0, length = mWatchingCallbacks.Length(); i < length; ++i) {
+ mWatchingCallbacks[i]->Allow(JS::UndefinedHandleValue);
+ }
+
+ for (uint32_t i = 0, length = mPendingCallbacks.Length(); i < length; ++i) {
+ mPendingCallbacks[i]->Allow(JS::UndefinedHandleValue);
}
return NS_OK;
}
void
Geolocation::Shutdown()
{
@@ -1333,25 +1223,28 @@ Geolocation::Update(nsIDOMGeoPosition *a
mPendingCallbacks[i-1]->Update(aSomewhere);
RemoveRequest(mPendingCallbacks[i-1]);
}
// notify everyone that is watching
for (uint32_t i = 0; i < mWatchingCallbacks.Length(); i++) {
mWatchingCallbacks[i]->Update(aSomewhere);
}
+
return NS_OK;
}
+
NS_IMETHODIMP
Geolocation::NotifyError(uint16_t aErrorCode)
{
if (!WindowOwnerStillExists()) {
Shutdown();
return NS_OK;
}
+
mozilla::Telemetry::Accumulate(mozilla::Telemetry::GEOLOCATION_ERROR, true);
for (uint32_t i = mPendingCallbacks.Length(); i > 0; i--) {
mPendingCallbacks[i-1]->NotifyErrorAndShutdown(aErrorCode);
//NotifyErrorAndShutdown() removes the request from the array
}
// notify everyone that is watching
@@ -1365,27 +1258,29 @@ Geolocation::NotifyError(uint16_t aError
bool
Geolocation::IsAlreadyCleared(nsGeolocationRequest* aRequest)
{
for (uint32_t i = 0, length = mClearedWatchIDs.Length(); i < length; ++i) {
if (mClearedWatchIDs[i] == aRequest->WatchId()) {
return true;
}
}
+
return false;
}
bool
Geolocation::ClearPendingRequest(nsGeolocationRequest* aRequest)
{
if (aRequest->IsWatch() && this->IsAlreadyCleared(aRequest)) {
this->NotifyAllowedRequest(aRequest);
this->ClearWatch(aRequest->WatchId());
return true;
}
+
return false;
}
void
Geolocation::GetCurrentPosition(PositionCallback& aCallback,
PositionErrorCallback* aErrorCallback,
const PositionOptions& aOptions,
ErrorResult& aRv)
@@ -1438,21 +1333,16 @@ Geolocation::GetCurrentPosition(GeoPosit
NS_DispatchToMainThread(ev);
return NS_OK;
}
if (!mOwner && !nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
return NS_ERROR_FAILURE;
}
- if (sGeoInitPending) {
- mPendingRequests.AppendElement(request);
- return NS_OK;
- }
-
return GetCurrentPositionReady(request);
}
nsresult
Geolocation::GetCurrentPositionReady(nsGeolocationRequest* aRequest)
{
if (mOwner) {
if (!RegisterRequestWithPrompt(aRequest)) {
@@ -1530,21 +1420,16 @@ Geolocation::WatchPosition(GeoPositionCa
NS_DispatchToMainThread(ev);
return NS_OK;
}
if (!mOwner && !nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
return NS_ERROR_FAILURE;
}
- if (sGeoInitPending) {
- mPendingRequests.AppendElement(request);
- return NS_OK;
- }
-
return WatchPositionReady(request);
}
nsresult
Geolocation::WatchPositionReady(nsGeolocationRequest* aRequest)
{
if (mOwner) {
if (!RegisterRequestWithPrompt(aRequest))
--- a/dom/geolocation/nsGeolocation.h
+++ b/dom/geolocation/nsGeolocation.h
@@ -67,19 +67,16 @@ public:
NS_DECL_NSIOBSERVER
nsGeolocationService() {
mHigherAccuracy = false;
}
nsresult Init();
- void HandleMozsettingChanged(nsISupports* aSubject);
- 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);
CachedPositionAndAccuracy GetCachedPosition();
// Find and startup a geolocation device (gps, nmea, etc.)
deleted file mode 100644
--- a/dom/tests/mochitest/geolocation/chrome.ini
+++ /dev/null
@@ -1,9 +0,0 @@
-[DEFAULT]
-support-files =
- geolocation.html
- geolocation_common.js
-
-[test_mozsettings.html]
-skip-if = buildapp == 'b2g' || toolkit == 'android'
-[test_mozsettingsWatch.html]
-skip-if = buildapp == 'b2g' || toolkit == 'android'
--- a/dom/tests/mochitest/geolocation/geolocation_common.js
+++ b/dom/tests/mochitest/geolocation/geolocation_common.js
@@ -84,20 +84,8 @@ function check_geolocation(location) {
// optional ok("speed" in coords, "Check to see if there is a speed");
ok (Math.abs(location.coords.latitude - 37.41857) < 0.001, "lat matches known value");
ok (Math.abs(location.coords.longitude + 122.08769) < 0.001, "lon matches known value");
// optional ok(location.coords.altitude == 42, "alt matches known value");
// optional ok(location.coords.altitudeAccuracy == 42, "alt acc matches known value");
}
-function toggleGeolocationSetting(value, callback) {
- var mozSettings = window.navigator.mozSettings;
- var lock = mozSettings.createLock();
-
- var geoenabled = {"geolocation.enabled": value};
-
- req = lock.set(geoenabled);
- req.onsuccess = function () {
- ok(true, "set done");
- callback();
- }
-}
deleted file mode 100644
--- a/dom/tests/mochitest/geolocation/test_mozsettings.html
+++ /dev/null
@@ -1,83 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=478911
--->
-<head>
- <title>Test for getCurrentPosition </title>
- <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
- <script type="text/javascript" src="geolocation_common.js"></script>
-
-<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=777594">Mozilla Bug 777594</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-SimpleTest.waitForExplicitFinish();
-SimpleTest.requestFlakyTimeout("untriaged");
-
-var timeToWaitMs = 1000;
-
-resume_geolocationProvider(function() {
- force_prompt(true, test2);
-});
-
-SpecialPowers.importInMainProcess("resource://gre/modules/SettingsRequestManager.jsm");
-
-function test2() {
- ok(navigator.geolocation, "get geolocation object");
-
- toggleGeolocationSetting(false, function() {
- ok(true, "turned off geolocation via mozSettings");
- setTimeout(function() {
- navigator.geolocation.getCurrentPosition(successCallbackAfterMozsettingOff,
- failureCallbackAfterMozsettingOff);
- }, timeToWaitMs); // need to wait a bit for all of these async callbacks to finish
- });
-}
-
-function successCallbackAfterMozsettingOff(position) {
- ok(false, "Success callback should not have been called after setting geolocation.enabled to false.");
-
- toggleGeolocationSetting(true, function() {
- ok(true, "turned on geolocation via mozSettings");
- setTimeout(function() {
- navigator.geolocation.getCurrentPosition(successCallbackAfterMozsettingOn,
- failureCallbackAfterMozsettingOn);
- }, timeToWaitMs); // need to wait a bit for all of these async callbacks to finish
- });
-}
-
-function failureCallbackAfterMozsettingOff(error) {
- ok(true, "Geolocation didn't work after setting geolocation.enabled to false.");
-
- toggleGeolocationSetting(true, function() {
- ok(true, "turned on geolocation via mozSettings");
- setTimeout(function() {
- navigator.geolocation.getCurrentPosition(successCallbackAfterMozsettingOn,
- failureCallbackAfterMozsettingOn);
- }, timeToWaitMs); // need to wait a bit for all of these async callbacks to finish
- });
-}
-
-function successCallbackAfterMozsettingOn(position) {
- ok(true, "Geolocation worked after setting geolocation.enabled to true.");
- SimpleTest.finish();
-}
-
-function failureCallbackAfterMozsettingOn(error) {
- ok(false, "Geolocation didn't work after setting geolocation.enabled to true.");
- SimpleTest.finish();
-}
-
-</script>
-</pre>
-</body>
-</html>
-
deleted file mode 100644
--- a/dom/tests/mochitest/geolocation/test_mozsettingsWatch.html
+++ /dev/null
@@ -1,88 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=478911
--->
-<head>
- <title>Test for getCurrentPosition </title>
- <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
- <script type="text/javascript" src="geolocation_common.js"></script>
-
-<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=777594">Mozilla Bug 777594</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-SimpleTest.waitForExplicitFinish();
-SimpleTest.requestFlakyTimeout("untriaged");
-
-resume_geolocationProvider(function() {
- force_prompt(true, test2);
-});
-
-SpecialPowers.importInMainProcess("resource://gre/modules/SettingsRequestManager.jsm");
-
-var watchId;
-function test2() {
- ok(navigator.geolocation, "get geolocation object");
-
- toggleGeolocationSetting(false, function() {
- ok(true, "turned off geolocation via mozSettings");
- setTimeout(function() {
- watchId = navigator.geolocation.watchPosition(successCallbackAfterMozsettingOff,
- failureCallbackAfterMozsettingOff);
- }, 500); // need to wait a bit for all of these async callbacks to finish
- });
-}
-
-function successCallbackAfterMozsettingOff(position) {
- ok(false, "Success callback should not have been called after setting geolocation.enabled to false.");
-
- navigator.geolocation.clearWatch(watchId);
- toggleGeolocationSetting(true, function() {
- ok(true, "turned on geolocation via mozSettings");
- setTimeout(function() {
- watchId = navigator.geolocation.watchPosition(successCallbackAfterMozsettingOn,
- failureCallbackAfterMozsettingOn);
- }, 500); // need to wait a bit for all of these async callbacks to finish
- });
-}
-
-function failureCallbackAfterMozsettingOff(error) {
- ok(true, "Geolocation didn't work after setting geolocation.enabled to false.");
-
- navigator.geolocation.clearWatch(watchId);
- toggleGeolocationSetting(true, function() {
- ok(true, "turned on geolocation via mozSettings");
- setTimeout(function() {
- watchId = navigator.geolocation.watchPosition(successCallbackAfterMozsettingOn,
- failureCallbackAfterMozsettingOn);
- }, 500); // need to wait a bit for all of these async callbacks to finish
- });
-}
-
-function successCallbackAfterMozsettingOn(position) {
- ok(true, "Geolocation worked after setting geolocation.enabled to true.");
-
- navigator.geolocation.clearWatch(watchId);
- SimpleTest.finish();
-}
-
-function failureCallbackAfterMozsettingOn(error) {
- ok(false, "Geolocation didn't work after setting geolocation.enabled to true.");
-
- navigator.geolocation.clearWatch(watchId);
- SimpleTest.finish();
-}
-
-</script>
-</pre>
-</body>
-</html>
-
--- a/dom/tests/moz.build
+++ b/dom/tests/moz.build
@@ -29,17 +29,16 @@ MOCHITEST_MANIFESTS += [
'mochitest/webcomponents/mochitest.ini',
'mochitest/whatwg/mochitest.ini',
]
MOCHITEST_CHROME_MANIFESTS += [
'mochitest/beacon/chrome.ini',
'mochitest/chrome/chrome.ini',
'mochitest/general/chrome.ini',
- 'mochitest/geolocation/chrome.ini',
'mochitest/localstorage/chrome.ini',
'mochitest/notification/chrome.ini',
'mochitest/sessionstorage/chrome.ini',
'mochitest/whatwg/chrome.ini',
]
if CONFIG['MOZ_GAMEPAD']:
MOCHITEST_MANIFESTS += [