Bug 992198 - TPS.Sync() fails for special options like 'wipeRemote' if the user is not logged in yet. r=jgriffin DONTBUILD

--HG--
extra : rebase_source : d4ff28171ebdd7d2a23e7cc395d7087831d30f96
This commit is contained in:
Henrik Skupin 2014-04-09 23:35:57 +02:00
parent 7eca30f98c
commit 9e1f72815b

View File

@ -42,27 +42,37 @@ var prefs = Cc["@mozilla.org/preferences-service;1"]
var mozmillInit = {}; var mozmillInit = {};
Cu.import('resource://mozmill/modules/init.js', mozmillInit); Cu.import('resource://mozmill/modules/init.js', mozmillInit);
const ACTION_ADD = "add"; // Options for wiping data during a sync
const ACTION_VERIFY = "verify"; const SYNC_RESET_CLIENT = "resetClient";
const ACTION_VERIFY_NOT = "verify-not"; const SYNC_WIPE_CLIENT = "wipeClient";
const ACTION_MODIFY = "modify"; const SYNC_WIPE_REMOTE = "wipeRemote";
const ACTION_SYNC = "sync";
const ACTION_DELETE = "delete";
const ACTION_PRIVATE_BROWSING = "private-browsing";
const ACTION_WIPE_REMOTE = "wipe-remote";
const ACTION_WIPE_SERVER = "wipe-server";
const ACTION_SET_ENABLED = "set-enabled";
const ACTIONS = [ACTION_ADD, ACTION_VERIFY, ACTION_VERIFY_NOT, // Actions a test can perform
ACTION_MODIFY, ACTION_SYNC, ACTION_DELETE, const ACTION_ADD = "add";
ACTION_PRIVATE_BROWSING, ACTION_WIPE_REMOTE, const ACTION_DELETE = "delete";
ACTION_WIPE_SERVER, ACTION_SET_ENABLED]; const ACTION_MODIFY = "modify";
const ACTION_PRIVATE_BROWSING = "private-browsing";
const ACTION_SET_ENABLED = "set-enabled";
const ACTION_SYNC = "sync";
const ACTION_SYNC_RESET_CLIENT = SYNC_RESET_CLIENT;
const ACTION_SYNC_WIPE_CLIENT = SYNC_WIPE_CLIENT;
const ACTION_SYNC_WIPE_REMOTE = SYNC_WIPE_REMOTE;
const ACTION_VERIFY = "verify";
const ACTION_VERIFY_NOT = "verify-not";
const SYNC_WIPE_CLIENT = "wipe-client"; const ACTIONS = [
const SYNC_WIPE_REMOTE = "wipe-remote"; ACTION_ADD,
const SYNC_WIPE_SERVER = "wipe-server"; ACTION_DELETE,
const SYNC_RESET_CLIENT = "reset-client"; ACTION_MODIFY,
const SYNC_START_OVER = "start-over"; ACTION_PRIVATE_BROWSING,
ACTION_SET_ENABLED,
ACTION_SYNC,
ACTION_SYNC_RESET_CLIENT,
ACTION_SYNC_WIPE_CLIENT,
ACTION_SYNC_WIPE_REMOTE,
ACTION_VERIFY,
ACTION_VERIFY_NOT,
];
const OBSERVER_TOPICS = ["fxaccounts:onlogin", const OBSERVER_TOPICS = ["fxaccounts:onlogin",
"fxaccounts:onlogout", "fxaccounts:onlogout",
@ -92,6 +102,7 @@ let TPS = {
_setupComplete: false, _setupComplete: false,
_syncActive: false, _syncActive: false,
_syncErrors: 0, _syncErrors: 0,
_syncWipeAction: null,
_tabsAdded: 0, _tabsAdded: 0,
_tabsFinished: 0, _tabsFinished: 0,
_test: null, _test: null,
@ -158,6 +169,12 @@ let TPS = {
case "weave:service:setup-complete": case "weave:service:setup-complete":
this._setupComplete = true; this._setupComplete = true;
if (this._syncWipeAction) {
Weave.Svc.Prefs.set("firstSync", this._syncWipeAction);
this._syncWipeAction = null;
}
break; break;
case "weave:service:sync:error": case "weave:service:sync:error":
@ -826,21 +843,24 @@ let TPS = {
this.waitForTracking(); this.waitForTracking();
}, },
Sync: function TPS__Sync(options) { /**
Logger.logInfo("executing Sync " + (options ? options : "")); * Triggers a sync operation
*
* @param {String} [wipeAction]
* Type of wipe to perform (resetClient, wipeClient, wipeRemote)
*
*/
Sync: function TPS__Sync(wipeAction) {
Logger.logInfo("Executing Sync" + (wipeAction ? ": " + wipeAction : ""));
if (options == SYNC_WIPE_REMOTE) { // Force a wipe action if requested. In case of an initial sync the pref
Weave.Svc.Prefs.set("firstSync", "wipeRemote"); // will be overwritten by Sync itself (see bug 992198), so ensure that we
// also handle it via the "weave:service:setup-complete" notification.
if (wipeAction) {
this._syncWipeAction = wipeAction;
Weave.Svc.Prefs.set("firstSync", wipeAction);
} }
else if (options == SYNC_WIPE_CLIENT) { else {
Weave.Svc.Prefs.set("firstSync", "wipeClient");
}
else if (options == SYNC_RESET_CLIENT) {
Weave.Svc.Prefs.set("firstSync", "resetClient");
}
else if (options) {
throw new Error("Unhandled options to Sync(): " + options);
} else {
Weave.Svc.Prefs.reset("firstSync"); Weave.Svc.Prefs.reset("firstSync");
} }
@ -848,7 +868,6 @@ let TPS = {
this._waitingForSync = true; this._waitingForSync = true;
this.StartAsyncOperation(); this.StartAsyncOperation();
Weave.Service.sync(); Weave.Service.sync();
}, },