Bug 1350135 - Fix failing TPS test_history_collision.js test r=markh

There were three issues here: The first is that the TPS's history module didn't
wait for PlacesUtils.history.remove's promise to resolve.

The second is that the SYNC_WIPE_REMOTE in the previous client would cause a
write to the clients collection, which would cause the next client to get a
"sync:collection_changed" push. This caused a sync of *only* the clients
collection upon reciept, which would prevent TPS from explicitly syncing all
engines.

The third is that TPS wasn't correctly handling the cases where logIn would
trigger a sync, which would cause a failure during the first sync of a session.
This would cause failures on other TPS tests as well.

MozReview-Commit-ID: LpqZ7Kt9fyy

--HG--
extra : rebase_source : f1d3c40e2ef4e09cce4d2ce8ae25f2c86ddfee45
This commit is contained in:
Thom Chiovoloni 2017-04-19 14:38:00 -04:00
Родитель 38210c8500
Коммит 8b9281c90a
4 изменённых файлов: 22 добавлений и 5 удалений

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

@ -403,7 +403,10 @@ Sync11Service.prototype = {
// Ideally this observer should be in the SyncScheduler, but it would require
// some work to know about the sync specific engines. We should move this there once it does.
case "sync:collection_changed":
if (data.includes("clients")) {
// We check if we're running TPS here to avoid TPS failing because it
// couldn't get to get the sync lock, due to us currently syncing the
// clients engine.
if (data.includes("clients") && !Svc.Prefs.get("testing.tps", false)) {
this.sync([]); // [] = clients collection only
}
break;

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

@ -175,7 +175,7 @@ var HistoryEntry = {
*/
Delete(item, usSinceEpoch) {
if ("uri" in item) {
PlacesUtils.history.remove(item.uri);
Async.promiseSpinningly(PlacesUtils.history.remove(item.uri));
} else if ("host" in item) {
PlacesUtils.history.removePagesFromHost(item.host, false);
} else if ("begin" in item && "end" in item) {

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

@ -269,7 +269,15 @@ var TPS = {
},
FinishAsyncOperation: function TPS__FinishAsyncOperation() {
this._operations_pending--;
// We fire a FinishAsyncOperation at the end of a sync finish (somewhat
// dubious, but we're consistent about it), but a sync may or may not be
// triggered during login, and it's hard for us to know (without e.g.
// auth/fxaccounts.jsm calling back into this module). So we just assume
// the FinishAsyncOperation without a StartAsyncOperation is fine, and works
// as if a StartAsyncOperation had been called.
if (this._operations_pending) {
this._operations_pending--;
}
if (!this.operations_pending) {
this._currentAction++;
Utils.nextTick(function() {
@ -1131,13 +1139,14 @@ var TPS = {
return;
}
// This might come during Authentication.signIn
this._triggeredSync = true;
Logger.logInfo("Setting client credentials and login.");
Authentication.signIn(this.config.fx_account);
this.waitForSetupComplete();
Logger.AssertEqual(Weave.Status.service, Weave.STATUS_OK, "Weave status OK");
this.waitForTracking();
// We get an initial sync at login time - let that complete.
this._triggeredSync = true;
// We might get an initial sync at login time - let that complete.
this.waitForSyncFinished();
},
@ -1149,6 +1158,10 @@ var TPS = {
*
*/
Sync: function TPS__Sync(wipeAction) {
if (this._syncActive) {
Logger.logInfo("WARNING: Sync currently active! Waiting, before triggering another");
this.waitForSyncFinished();
}
Logger.logInfo("Executing Sync" + (wipeAction ? ": " + wipeAction : ""));
// Force a wipe action if requested. In case of an initial sync the pref

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

@ -76,6 +76,7 @@ class TPSTestRunner(object):
'toolkit.startup.max_resumed_crashes': -1,
# hrm - not sure what the release/beta channels will do?
'xpinstall.signatures.required': False,
'services.sync.testing.tps': True,
}
debug_preferences = {