Bug 816850 - Don't call nsGeolocation::Shutdown() when disabled via settings. r=dougt

This commit is contained in:
Kan-Ru Chen (陳侃如) 2012-12-03 17:13:48 +08:00
Родитель 72355190ff
Коммит b77847b588
3 изменённых файлов: 58 добавлений и 20 удалений

Просмотреть файл

@ -740,10 +740,8 @@ void
nsGeolocationService::HandleMozsettingValue(const bool aValue)
{
if (!aValue) {
// turn things off
for (uint32_t i = 0; i< mGeolocators.Length(); i++) {
mGeolocators[i]->Shutdown();
}
// Do not shutdown the mGeolocators, but instead just stop the
// device and do a final update of null. See bug #816850.
StopDevice();
Update(nullptr);
mLastPosition = nullptr;

Просмотреть файл

@ -42,30 +42,50 @@ SpecialPowers.addPermission("settings-read", true, document);
SpecialPowers.addPermission("settings-write", true, document);
SpecialPowers.Cu.import("resource://gre/modules/SettingsChangeNotifier.jsm");
ok(navigator.geolocation, "get geolocation object");
toggleGeolocationSetting(false, function() {
ok(true, "turned off geolocation via mozSettings");
setTimeout(function() {
navigator.geolocation.getCurrentPosition(successCallbackAfterMozsetting, failureCallbackAfterMozsetting);
navigator.geolocation.getCurrentPosition(successCallbackAfterMozsettingOff, failureCallbackAfterMozsettingOff);
}, 500); // need to wait a bit for all of these async callbacks to finish
});
function successCallbackAfterMozsetting(position) {
function successCallbackAfterMozsettingOff(position) {
ok(false, "Success callback should not have been called after setting geolocation.enabled to false.");
toggleGeolocationSetting(true, function() {
reset_prompt();
SimpleTest.finish();
ok(true, "turned on geolocation via mozSettings");
setTimeout(function() {
navigator.geolocation.watchPosition(successCallbackAfterMozsettingOn, failureCallbackAfterMozsettingOn);
}, 500); // need to wait a bit for all of these async callbacks to finish
});
}
function failureCallbackAfterMozsetting(error) {
function failureCallbackAfterMozsettingOff(error) {
ok(true, "Geolocation didn't work after setting geolocation.enabled to false.");
toggleGeolocationSetting(true, function() {
reset_prompt();
SimpleTest.finish();
ok(true, "turned on geolocation via mozSettings");
setTimeout(function() {
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.");
reset_prompt();
SimpleTest.finish();
}
function failureCallbackAfterMozsettingOn(error) {
ok(false, "Geolocation didn't work after setting geolocation.enabled to true.");
reset_prompt();
SimpleTest.finish();
}
</script>
</pre>

Просмотреть файл

@ -42,30 +42,50 @@ SpecialPowers.addPermission("settings-read", true, document);
SpecialPowers.addPermission("settings-write", true, document);
SpecialPowers.Cu.import("resource://gre/modules/SettingsChangeNotifier.jsm");
ok(navigator.geolocation, "get geolocation object");
toggleGeolocationSetting(false, function() {
ok(true, "turned off geolocation via mozSettings");
setTimeout(function() {
navigator.geolocation.watchPosition(successCallbackAfterMozsetting, failureCallbackAfterMozsetting);
navigator.geolocation.watchPosition(successCallbackAfterMozsettingOff, failureCallbackAfterMozsettingOff);
}, 500); // need to wait a bit for all of these async callbacks to finish
});
function successCallbackAfterMozsetting(position) {
function successCallbackAfterMozsettingOff(position) {
ok(false, "Success callback should not have been called after setting geolocation.enabled to false.");
toggleGeolocationSetting(true, function() {
reset_prompt();
SimpleTest.finish();
ok(true, "turned on geolocation via mozSettings");
setTimeout(function() {
navigator.geolocation.watchPosition(successCallbackAfterMozsettingOn, failureCallbackAfterMozsettingOn);
}, 500); // need to wait a bit for all of these async callbacks to finish
});
}
function failureCallbackAfterMozsetting(error) {
function failureCallbackAfterMozsettingOff(error) {
ok(true, "Geolocation didn't work after setting geolocation.enabled to false.");
toggleGeolocationSetting(true, function() {
reset_prompt();
SimpleTest.finish();
ok(true, "turned on geolocation via mozSettings");
setTimeout(function() {
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.");
reset_prompt();
SimpleTest.finish();
}
function failureCallbackAfterMozsettingOn(error) {
ok(false, "Geolocation didn't work after setting geolocation.enabled to true.");
reset_prompt();
SimpleTest.finish();
}
</script>
</pre>