Bug 1126559 - don't allow resetting when that is not possible, r=MattN

MozReview-Commit-ID: F0m70XKQtT7

--HG--
extra : rebase_source : 6c9ba72a2585a49afb432af6474b9ef970fc9349
This commit is contained in:
Gijs Kruitbosch 2016-05-18 15:25:00 +01:00
Родитель af3dda948f
Коммит 65234fb791
2 изменённых файлов: 20 добавлений и 1 удалений

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

@ -622,7 +622,9 @@ this.UITour = {
case "resetFirefox": {
// Open a reset profile dialog window.
ResetProfile.openConfirmationDialog(window);
if (ResetProfile.resetSupported()) {
ResetProfile.openConfirmationDialog(window);
}
break;
}
@ -1939,6 +1941,9 @@ this.UITour = {
setup: Services.prefs.prefHasUserValue("services.sync.username"),
});
break;
case "canReset":
this.sendPageCallback(aMessageManager, aCallbackID, ResetProfile.resetSupported());
break;
default:
log.error("getConfiguration: Unknown configuration requested: " + aConfiguration);
break;

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

@ -8,6 +8,8 @@ add_task(setup_UITourTest);
// Test that a reset profile dialog appears when "resetFirefox" event is triggered
add_UITour_task(function* test_resetFirefox() {
let canReset = yield getConfigurationPromise("canReset");
ok(!canReset, "Shouldn't be able to reset from mochitest's temporary profile.");
let dialogPromise = new Promise((resolve) => {
let winWatcher = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
@ -28,7 +30,19 @@ add_UITour_task(function* test_resetFirefox() {
}
});
});
// make reset possible.
let profileService = Cc["@mozilla.org/toolkit/profile-service;1"].
getService(Ci.nsIToolkitProfileService);
let currentProfileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
let profileName = "mochitest-test-profile-temp-" + Date.now();
let tempProfile = profileService.createProfile(currentProfileDir, profileName);
canReset = yield getConfigurationPromise("canReset");
ok(canReset, "Should be able to reset from mochitest's temporary profile once it's in the profile manager.");
yield gContentAPI.resetFirefox();
yield dialogPromise;
tempProfile.remove(false);
canReset = yield getConfigurationPromise("canReset");
ok(!canReset, "Shouldn't be able to reset from mochitest's temporary profile once removed from the profile manager.");
});