Bug 1126559 - don't allow resetting when that is not possible, r?MattN
MozReview-Commit-ID: F0m70XKQtT7
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -617,17 +617,19 @@ this.UITour = {
// We want to replace the current tab.
browser.loadURI("about:accounts?" + p.toString());
break;
}
case "resetFirefox": {
// Open a reset profile dialog window.
- ResetProfile.openConfirmationDialog(window);
+ if (ResetProfile.resetSupported()) {
+ ResetProfile.openConfirmationDialog(window);
+ }
break;
}
case "addNavBarWidget": {
// Add a widget to the toolbar
let targetPromise = this.getTarget(window, data.name);
targetPromise.then(target => {
this.addNavBarWidget(target, messageManager, data.callbackID);
@@ -1934,16 +1936,19 @@ this.UITour = {
this.sendPageCallback(aMessageManager, aCallbackID, data);
});
break;
case "sync":
this.sendPageCallback(aMessageManager, aCallbackID, {
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;
}
},
setConfiguration: function(aWindow, aConfiguration, aValue) {
switch (aConfiguration) {
--- a/browser/components/uitour/test/browser_UITour_resetProfile.js
+++ b/browser/components/uitour/test/browser_UITour_resetProfile.js
@@ -3,16 +3,18 @@
var gTestTab;
var gContentAPI;
var gContentWindow;
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);
winWatcher.registerNotification(function onOpen(subj, topic, data) {
if (topic == "domwindowopened" && subj instanceof Ci.nsIDOMWindow) {
subj.addEventListener("load", function onLoad() {
subj.removeEventListener("load", onLoad);
if (subj.document.documentURI ==
@@ -23,12 +25,24 @@ add_UITour_task(function* test_resetFire
"Reset Firefox event opened a reset profile window.");
subj.close();
resolve();
}
});
}
});
});
+
+ // 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.");
});