mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 708965 - Improve TPS handling of Sync data deletion and test setup; r=rnewman
This commit is contained in:
parent
1bdae035b2
commit
52d7accb35
@ -51,7 +51,7 @@ var bookmarks_initial_2 = {
|
||||
|
||||
Phase('phase1', [
|
||||
[Bookmarks.add, bookmarks_initial_1],
|
||||
[Sync, SYNC_WIPE_SERVER],
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
Phase('phase2', [
|
||||
|
@ -55,7 +55,7 @@ var passwords_after_first_update = [
|
||||
|
||||
Phase('phase1', [
|
||||
[Passwords.add, passwords_initial],
|
||||
[Sync, SYNC_WIPE_SERVER],
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
Phase('phase2', [
|
||||
|
@ -47,7 +47,7 @@ var prefs2 = [
|
||||
Phase('phase1', [
|
||||
[Prefs.modify, prefs1],
|
||||
[Prefs.verify, prefs1],
|
||||
[Sync, SYNC_WIPE_SERVER],
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
// Sync profile2 and verify same prefs are present.
|
||||
|
@ -43,7 +43,7 @@ var bookmarks_initial = {
|
||||
Phase('phase1', [
|
||||
[Bookmarks.add, bookmarks_initial],
|
||||
[Bookmarks.verify, bookmarks_initial],
|
||||
[Sync, SYNC_WIPE_SERVER]
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
// Sync to profile2 and verify that all three bookmarks are present
|
||||
|
@ -119,7 +119,7 @@ var tabs1 = [
|
||||
|
||||
Phase('phase1', [
|
||||
[Tabs.add, tabs1],
|
||||
[Sync, SYNC_WIPE_SERVER]
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
Phase('phase2', [
|
||||
|
@ -65,7 +65,7 @@ var bookmarks_after_move = {
|
||||
Phase('phase1', [
|
||||
[Bookmarks.add, bookmarks_initial],
|
||||
[Bookmarks.verify, bookmarks_initial],
|
||||
[Sync, SYNC_WIPE_SERVER]
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
// Sync to profile2 and verify that all four bookmarks are present.
|
||||
|
@ -42,7 +42,7 @@ var tabs_absent = [
|
||||
|
||||
Phase('phase1', [
|
||||
[Tabs.add, tabs1],
|
||||
[Sync, SYNC_WIPE_SERVER]
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
Phase('phase2', [
|
||||
|
@ -33,7 +33,7 @@ var bookmarks_initial = {
|
||||
Phase('phase1', [
|
||||
[Bookmarks.add, bookmarks_initial],
|
||||
[Bookmarks.verify, bookmarks_initial],
|
||||
[Sync, SYNC_WIPE_SERVER]
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
// Sync to profile2 and verify that the bookmark folder is created, along
|
||||
|
@ -79,7 +79,7 @@ var bookmarks_to_delete = {
|
||||
Phase('phase1', [
|
||||
[Bookmarks.add, bookmarks_initial],
|
||||
[Bookmarks.verify, bookmarks_initial],
|
||||
[Sync, SYNC_WIPE_SERVER]
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
// sync to profile2 and verify that the bookmarks are present
|
||||
|
@ -78,7 +78,7 @@ var bookmarks_to_delete = {
|
||||
Phase('phase1', [
|
||||
[Bookmarks.add, bookmarks_initial],
|
||||
[Bookmarks.verify, bookmarks_initial],
|
||||
[Sync, SYNC_WIPE_SERVER],
|
||||
[Sync],
|
||||
]);
|
||||
|
||||
// Sync to profile2 and verify that the bookmarks are present. Delete
|
||||
@ -93,7 +93,7 @@ Phase('phase2', [
|
||||
// Using profile1, sync again with wipe-server set to true. Verify our
|
||||
// initial bookmarks are still all present.
|
||||
Phase('phase3', [
|
||||
[Sync, SYNC_WIPE_SERVER],
|
||||
[Sync, SYNC_WIPE_REMOTE],
|
||||
[Bookmarks.verify, bookmarks_initial]
|
||||
]);
|
||||
|
||||
|
@ -73,7 +73,7 @@ Phase('phase1', [
|
||||
[History.add, history1],
|
||||
[Sync],
|
||||
[History.add, history2],
|
||||
[Sync, SYNC_WIPE_SERVER]
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
Phase('phase2', [
|
||||
|
@ -135,7 +135,7 @@ Phase('phase1', [
|
||||
[Bookmarks.add, bookmarks_initial],
|
||||
[Prefs.modify, prefs1],
|
||||
[Prefs.verify, prefs1],
|
||||
[Sync, SYNC_WIPE_SERVER]
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
// Sync profile2 and verify same prefs,passwords and bookmarks are present.
|
||||
|
@ -53,7 +53,7 @@ var formdata_delete = [
|
||||
Phase('phase1', [
|
||||
[Formdata.add, formdata1],
|
||||
[Formdata.verify, formdata1],
|
||||
[Sync, SYNC_WIPE_SERVER],
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
Phase('phase2', [
|
||||
|
@ -152,7 +152,7 @@ var history_not = [
|
||||
|
||||
Phase('phase1', [
|
||||
[History.add, history1],
|
||||
[Sync, SYNC_WIPE_SERVER],
|
||||
[Sync],
|
||||
]);
|
||||
|
||||
Phase('phase2', [
|
||||
|
@ -99,12 +99,12 @@ var history_after_delete = [
|
||||
|
||||
Phase('phase1', [
|
||||
[History.add, history1],
|
||||
[Sync, SYNC_WIPE_SERVER]
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
Phase('phase2', [
|
||||
[History.add, history1],
|
||||
[Sync, SYNC_WIPE_SERVER]
|
||||
[Sync, SYNC_WIPE_REMOTE]
|
||||
]);
|
||||
|
||||
Phase('phase3', [
|
||||
|
@ -85,7 +85,7 @@ var passwords_after_second_update = [
|
||||
|
||||
Phase('phase1', [
|
||||
[Passwords.add, passwords_initial],
|
||||
[Sync, SYNC_WIPE_SERVER],
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
Phase('phase2', [
|
||||
|
@ -38,7 +38,7 @@ var prefs2 = [
|
||||
Phase('phase1', [
|
||||
[Prefs.modify, prefs1],
|
||||
[Prefs.verify, prefs1],
|
||||
[Sync, SYNC_WIPE_SERVER],
|
||||
[Sync],
|
||||
]);
|
||||
|
||||
Phase('phase2', [
|
||||
|
@ -49,7 +49,7 @@ var formdata2 = [
|
||||
Phase('phase1', [
|
||||
[Formdata.add, formdata1],
|
||||
[Formdata.verify, formdata1],
|
||||
[Sync, SYNC_WIPE_SERVER]
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
Phase('phase2', [
|
||||
|
@ -76,7 +76,7 @@ var passwords_after_second_change = [
|
||||
|
||||
Phase('phase1', [
|
||||
[Passwords.add, passwords_initial],
|
||||
[Sync, SYNC_WIPE_SERVER]
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
Phase('phase2', [
|
||||
|
@ -64,7 +64,7 @@ var tabs3 = [
|
||||
|
||||
Phase('phase1', [
|
||||
[Tabs.add, tabs1],
|
||||
[Sync, SYNC_WIPE_SERVER]
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
Phase('phase2', [
|
||||
|
@ -66,7 +66,7 @@ var tabs3 = [
|
||||
*/
|
||||
Phase('phase1', [
|
||||
[Tabs.add, tabs1],
|
||||
[Sync, SYNC_WIPE_SERVER]
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
Phase('phase2', [
|
||||
|
@ -378,7 +378,7 @@ Phase('phase1', [
|
||||
[Bookmarks.add, bookmarks_initial],
|
||||
[Passwords.add, passwords_initial],
|
||||
[History.add, history_initial],
|
||||
[Sync, SYNC_WIPE_SERVER],
|
||||
[Sync],
|
||||
]);
|
||||
|
||||
Phase('phase2', [
|
||||
|
@ -42,7 +42,7 @@ var tabs2 = [
|
||||
|
||||
Phase('phase1', [
|
||||
[Tabs.add, tabs1],
|
||||
[Sync, SYNC_WIPE_SERVER],
|
||||
[Sync]
|
||||
]);
|
||||
|
||||
Phase('phase2', [
|
||||
|
@ -49,9 +49,10 @@ CU.import("resource://services-sync/service.js");
|
||||
CU.import("resource://services-sync/util.js");
|
||||
var utils = {}; CU.import('resource://mozmill/modules/utils.js', utils);
|
||||
|
||||
const SYNC_WIPE_SERVER = "wipe-server";
|
||||
const SYNC_RESET_CLIENT = "reset-client";
|
||||
const SYNC_WIPE_CLIENT = "wipe-client";
|
||||
const SYNC_WIPE_CLIENT = "wipe-client";
|
||||
const SYNC_WIPE_REMOTE = "wipe-remote";
|
||||
const SYNC_WIPE_SERVER = "wipe-server";
|
||||
|
||||
var prefs = CC["@mozilla.org/preferences-service;1"]
|
||||
.getService(CI.nsIPrefBranch);
|
||||
@ -110,7 +111,7 @@ var TPS = {
|
||||
Sync: function TPS__Sync(options) {
|
||||
Logger.logInfo('Mozmill starting sync operation: ' + options);
|
||||
switch(options) {
|
||||
case SYNC_WIPE_SERVER:
|
||||
case SYNC_WIPE_REMOTE:
|
||||
Weave.Svc.Prefs.set("firstSync", "wipeRemote");
|
||||
break;
|
||||
case SYNC_WIPE_CLIENT:
|
||||
@ -127,10 +128,15 @@ var TPS = {
|
||||
return "Sync status not ok: " + Weave.Status.service;
|
||||
}
|
||||
|
||||
this._waitingForSync = true;
|
||||
this._syncErrors = 0;
|
||||
Weave.Service.sync();
|
||||
utils.waitFor(syncFinishedCallback, null, 20000, 500, TPS);
|
||||
|
||||
if (options == SYNC_WIPE_SERVER) {
|
||||
Weave.Service.wipeServer();
|
||||
} else {
|
||||
this._waitingForSync = true;
|
||||
Weave.Service.sync();
|
||||
utils.waitFor(syncFinishedCallback, null, 20000, 500, TPS);
|
||||
}
|
||||
return this._syncErrors;
|
||||
},
|
||||
};
|
||||
|
@ -40,11 +40,9 @@
|
||||
* listed symbols will exposed on import, and only when and where imported.
|
||||
*/
|
||||
|
||||
var EXPORTED_SYMBOLS = ["TPS"];
|
||||
let EXPORTED_SYMBOLS = ["TPS"];
|
||||
|
||||
const CC = Components.classes;
|
||||
const CI = Components.interfaces;
|
||||
const CU = Components.utils;
|
||||
const {classes: CC, interfaces: CI, utils: CU} = Components;
|
||||
|
||||
CU.import("resource://services-sync/service.js");
|
||||
CU.import("resource://services-sync/constants.js");
|
||||
@ -69,25 +67,29 @@ var prefs = CC["@mozilla.org/preferences-service;1"]
|
||||
var mozmillInit = {};
|
||||
CU.import('resource://mozmill/modules/init.js', mozmillInit);
|
||||
|
||||
const ACTION_ADD = "add";
|
||||
const ACTION_VERIFY = "verify";
|
||||
const ACTION_VERIFY_NOT = "verify-not";
|
||||
const ACTION_MODIFY = "modify";
|
||||
const ACTION_SYNC = "sync";
|
||||
const ACTION_DELETE = "delete";
|
||||
const ACTION_ADD = "add";
|
||||
const ACTION_VERIFY = "verify";
|
||||
const ACTION_VERIFY_NOT = "verify-not";
|
||||
const ACTION_MODIFY = "modify";
|
||||
const ACTION_SYNC = "sync";
|
||||
const ACTION_DELETE = "delete";
|
||||
const ACTION_PRIVATE_BROWSING = "private-browsing";
|
||||
const ACTION_WIPE_SERVER = "wipe-server";
|
||||
const ACTION_SETSTATE = "set-state";
|
||||
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,
|
||||
ACTION_MODIFY, ACTION_SYNC, ACTION_DELETE,
|
||||
ACTION_PRIVATE_BROWSING, ACTION_WIPE_SERVER,
|
||||
ACTION_SETSTATE];
|
||||
ACTION_PRIVATE_BROWSING, ACTION_WIPE_REMOTE,
|
||||
ACTION_WIPE_SERVER, ACTION_SET_ENABLED];
|
||||
|
||||
const SYNC_WIPE_SERVER = "wipe-server";
|
||||
const SYNC_WIPE_CLIENT = "wipe-client";
|
||||
const SYNC_WIPE_REMOTE = "wipe-remote";
|
||||
const SYNC_WIPE_SERVER = "wipe-server";
|
||||
const SYNC_RESET_CLIENT = "reset-client";
|
||||
const SYNC_WIPE_CLIENT = "wipe-client";
|
||||
const SYNC_START_OVER = "start-over";
|
||||
|
||||
var TPS =
|
||||
let TPS =
|
||||
{
|
||||
_waitingForSync: false,
|
||||
_test: null,
|
||||
@ -100,6 +102,7 @@ var TPS =
|
||||
_tabsFinished: 0,
|
||||
_phaselist: {},
|
||||
_operations_pending: 0,
|
||||
_loggedIn: false,
|
||||
|
||||
DumpError: function (msg) {
|
||||
this._errors++;
|
||||
@ -131,6 +134,7 @@ var TPS =
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case "weave:service:sync:finish":
|
||||
if (this._waitingForSync) {
|
||||
this._syncErrors = 0;
|
||||
@ -518,12 +522,24 @@ var TPS =
|
||||
this.DumpError("no profile defined for phase " + this._currentPhase);
|
||||
return;
|
||||
}
|
||||
Logger.logInfo("Starting phase " + parseInt(phase, 10) + "/" +
|
||||
Object.keys(this._phaselist).length);
|
||||
|
||||
Logger.logInfo("setting client.name to " + this.phases["phase" + this._currentPhase]);
|
||||
Weave.Svc.Prefs.set("client.name", this.phases["phase" + this._currentPhase]);
|
||||
|
||||
// wipe the server at the end of the final test phase
|
||||
if (this.phases["phase" + (parseInt(this._currentPhase) + 1)] == undefined)
|
||||
// TODO Phases should be defined in a data type that has strong
|
||||
// ordering, not by lexical sorting.
|
||||
let currentPhase = parseInt(this._currentPhase, 10);
|
||||
// Reset everything at the beginning of the test.
|
||||
if (currentPhase <= 1) {
|
||||
this_phase.unshift([this.ResetData]);
|
||||
}
|
||||
|
||||
// Wipe the server at the end of the final test phase.
|
||||
if (currentPhase >= Object.keys(this.phases).length) {
|
||||
this_phase.push([this.WipeServer]);
|
||||
}
|
||||
|
||||
// Store account details as prefs so they're accessible to the mozmill
|
||||
// framework.
|
||||
@ -573,9 +589,77 @@ var TPS =
|
||||
Logger.logInfo("set privateBrowsingEnabled: " + options);
|
||||
},
|
||||
|
||||
/**
|
||||
* Reset the client and server to an empty/pure state.
|
||||
*
|
||||
* All data on the server is wiped and replaced with new keys and local
|
||||
* client data. The local client is configured such that it is in sync
|
||||
* with the server and ready to handle changes.
|
||||
*
|
||||
* This is typically called at the beginning of every test to set up a clean
|
||||
* slate.
|
||||
*
|
||||
* This executes synchronously and doesn't return until things are in a good
|
||||
* state.
|
||||
*/
|
||||
ResetData: function ResetData() {
|
||||
this.Login(true);
|
||||
|
||||
Service.login();
|
||||
Service.wipeServer();
|
||||
Service.resetClient();
|
||||
Service.login();
|
||||
},
|
||||
|
||||
Login: function Login(force) {
|
||||
if (this._loggedIn && !force) {
|
||||
return;
|
||||
}
|
||||
|
||||
let account = this.config.account;
|
||||
if (!account) {
|
||||
this.DumperError("No account information found! Did you use a valid " +
|
||||
"config file?");
|
||||
return;
|
||||
}
|
||||
|
||||
if (account["serverURL"]) {
|
||||
Service.serverURL = account["serverURL"];
|
||||
}
|
||||
|
||||
Logger.logInfo("Setting client credentials.");
|
||||
if (account["admin-secret"]) {
|
||||
// if admin-secret is specified, we'll dynamically create
|
||||
// a new sync account
|
||||
Weave.Svc.Prefs.set("admin-secret", account["admin-secret"]);
|
||||
let suffix = account["account-suffix"];
|
||||
Service.account = "tps" + suffix + "@mozilla.com";
|
||||
Service.password = "tps" + suffix + "tps" + suffix;
|
||||
Service.passphrase = Weave.Utils.generatePassphrase();
|
||||
Service.createAccount(Service.account,
|
||||
Service.password,
|
||||
"dummy1", "dummy2");
|
||||
} else if (account["username"] && account["password"] &&
|
||||
account["passphrase"]) {
|
||||
Service.account = account["username"];
|
||||
Service.password = account["password"];
|
||||
Service.passphrase = account["passphrase"];
|
||||
} else {
|
||||
this.DumpError("Must specify admin-secret, or " +
|
||||
"username/password/passphrase in the config file");
|
||||
return;
|
||||
}
|
||||
|
||||
Service.login();
|
||||
Logger.AssertEqual(Weave.Status.service, Weave.STATUS_OK, "Weave status not OK");
|
||||
Weave.Svc.Obs.notify("weave:service:setup-complete");
|
||||
this._loggedIn = true;
|
||||
},
|
||||
|
||||
Sync: function TPS__Sync(options) {
|
||||
Logger.logInfo("executing Sync " + (options ? options : ""));
|
||||
if (options == SYNC_WIPE_SERVER) {
|
||||
|
||||
if (options == SYNC_WIPE_REMOTE) {
|
||||
Weave.Svc.Prefs.set("firstSync", "wipeRemote");
|
||||
}
|
||||
else if (options == SYNC_WIPE_CLIENT) {
|
||||
@ -584,61 +668,24 @@ var TPS =
|
||||
else if (options == SYNC_RESET_CLIENT) {
|
||||
Weave.Svc.Prefs.set("firstSync", "resetClient");
|
||||
}
|
||||
else {
|
||||
else if (options) {
|
||||
throw new Error("Unhandled options to Sync(): " + options);
|
||||
} else {
|
||||
Weave.Svc.Prefs.reset("firstSync");
|
||||
}
|
||||
if (this.config.account) {
|
||||
let account = this.config.account;
|
||||
if (account["serverURL"]) {
|
||||
Weave.Service.serverURL = account["serverURL"];
|
||||
}
|
||||
if (account["admin-secret"]) {
|
||||
// if admin-secret is specified, we'll dynamically create
|
||||
// a new sync account
|
||||
Weave.Svc.Prefs.set("admin-secret", account["admin-secret"]);
|
||||
let suffix = account["account-suffix"];
|
||||
Weave.Service.account = "tps" + suffix + "@mozilla.com";
|
||||
Weave.Service.password = "tps" + suffix + "tps" + suffix;
|
||||
Weave.Service.passphrase = Weave.Utils.generatePassphrase();
|
||||
Weave.Service.createAccount(Weave.Service.account,
|
||||
Weave.Service.password,
|
||||
"dummy1", "dummy2");
|
||||
Weave.Service.login();
|
||||
}
|
||||
else if (account["username"] && account["password"] &&
|
||||
account["passphrase"]) {
|
||||
Weave.Service.account = account["username"];
|
||||
Weave.Service.password = account["password"];
|
||||
Weave.Service.passphrase = account["passphrase"];
|
||||
Weave.Service.login();
|
||||
}
|
||||
else {
|
||||
this.DumpError("Must specify admin-secret, or " +
|
||||
"username/password/passphrase in the config file");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.DumpError("No account information found; did you use " +
|
||||
"a valid config file?");
|
||||
return;
|
||||
}
|
||||
Logger.AssertEqual(Weave.Status.service, Weave.STATUS_OK, "Weave status not OK");
|
||||
Weave.Svc.Obs.notify("weave:service:setup-complete");
|
||||
|
||||
this.Login(false);
|
||||
|
||||
this._waitingForSync = true;
|
||||
this.StartAsyncOperation();
|
||||
|
||||
Weave.Service.sync();
|
||||
},
|
||||
|
||||
WipeServer: function TPS__WipeServer() {
|
||||
Logger.logInfo("WipeServer()");
|
||||
Weave.Service.login();
|
||||
this.Login();
|
||||
Weave.Service.wipeServer();
|
||||
Logger.AssertEqual(Weave.Status.service, Weave.STATUS_OK, "Weave status not OK");
|
||||
this._waitingForSync = true;
|
||||
this.StartAsyncOperation();
|
||||
Weave.Service.sync();
|
||||
return;
|
||||
},
|
||||
};
|
||||
|
||||
@ -646,8 +693,8 @@ var Addons = {
|
||||
install: function Addons__install(addons) {
|
||||
TPS.HandleAddons(addons, ACTION_ADD);
|
||||
},
|
||||
setState: function Addons__setState(addons, state) {
|
||||
TPS.HandleAddons(addons, ACTION_SETSTATE, state);
|
||||
setEnabled: function Addons__setEnabled(addons, state) {
|
||||
TPS.HandleAddons(addons, ACTION_SET_ENABLED, state);
|
||||
},
|
||||
uninstall: function Addons__uninstall(addons) {
|
||||
TPS.HandleAddons(addons, ACTION_DELETE);
|
||||
|
Loading…
Reference in New Issue
Block a user