diff --git a/services/sync/tps/extensions/tps/resource/modules/forms.jsm b/services/sync/tps/extensions/tps/resource/modules/forms.jsm index 396a1048583d..4ed985a689ed 100644 --- a/services/sync/tps/extensions/tps/resource/modules/forms.jsm +++ b/services/sync/tps/extensions/tps/resource/modules/forms.jsm @@ -118,12 +118,12 @@ var FormDB = { * * Initializes instance properties. */ -function FormData(props, usSinceEpoch) { +function FormData(props, msSinceEpoch) { this.fieldname = null; this.value = null; this.date = 0; this.newvalue = null; - this.usSinceEpoch = usSinceEpoch; + this.usSinceEpoch = msSinceEpoch * 1000; for (var prop in props) { if (prop in this) diff --git a/services/sync/tps/extensions/tps/resource/modules/history.jsm b/services/sync/tps/extensions/tps/resource/modules/history.jsm index af87cc69bfdb..866763579eab 100644 --- a/services/sync/tps/extensions/tps/resource/modules/history.jsm +++ b/services/sync/tps/extensions/tps/resource/modules/history.jsm @@ -49,35 +49,22 @@ var HistoryEntry = { * the time the current Crossweave run was started * @return nothing */ - async Add(item, usSinceEpoch) { + async Add(item, msSinceEpoch) { Logger.AssertTrue("visits" in item && "uri" in item, "History entry in test file must have both 'visits' " + "and 'uri' properties"); - let uri = Services.io.newURI(item.uri); let place = { - uri, + url: item.uri, visits: [] }; for (let visit of item.visits) { - place.visits.push({ - visitDate: usSinceEpoch + (visit.date * 60 * 60 * 1000 * 1000), - transitionType: visit.type - }); + let date = new Date(Math.round(msSinceEpoch + visit.date * 60 * 60 * 1000)); + place.visits.push({ date, transition: visit.type }); } if ("title" in item) { place.title = item.title; } - return new Promise((resolve, reject) => { - PlacesUtils.asyncHistory.updatePlaces(place, { - handleError() { - reject(new Error("Error adding history entry")); - }, - handleResult() {}, - handleCompletion() { - resolve(); - } - }); - }); + return PlacesUtils.history.insert(place); }, /** @@ -90,15 +77,15 @@ var HistoryEntry = { * the time the current Crossweave run was started * @return true if all the visits for the uri are found, otherwise false */ - async Find(item, usSinceEpoch) { + async Find(item, msSinceEpoch) { Logger.AssertTrue("visits" in item && "uri" in item, "History entry in test file must have both 'visits' " + "and 'uri' properties"); let curvisits = await PlacesSyncUtils.history.fetchVisitsForURL(item.uri); for (let visit of curvisits) { for (let itemvisit of item.visits) { - let expectedDate = itemvisit.date * 60 * 60 * 1000 * 1000 - + usSinceEpoch; + // Note: in microseconds. + let expectedDate = itemvisit.date * 60 * 60 * 1000 * 1000 + msSinceEpoch * 1000; if (visit.type == itemvisit.type && visit.date == expectedDate) { itemvisit.found = true; } @@ -126,7 +113,7 @@ var HistoryEntry = { * the time the current Crossweave run was started * @return nothing */ - async Delete(item, usSinceEpoch) { + async Delete(item, msSinceEpoch) { if ("uri" in item) { let removedAny = await PlacesUtils.history.remove(item.uri); if (!removedAny) { @@ -135,7 +122,6 @@ var HistoryEntry = { } else if ("host" in item) { await PlacesUtils.history.removePagesFromHost(item.host, false); } else if ("begin" in item && "end" in item) { - let msSinceEpoch = parseInt(usSinceEpoch / 1000); let filter = { beginDate: new Date(msSinceEpoch + (item.begin * 60 * 60 * 1000)), endDate: new Date(msSinceEpoch + (item.end * 60 * 60 * 1000)) diff --git a/services/sync/tps/extensions/tps/resource/tps.jsm b/services/sync/tps/extensions/tps/resource/tps.jsm index 81f87dca9f28..6b8fb245b42b 100644 --- a/services/sync/tps/extensions/tps/resource/tps.jsm +++ b/services/sync/tps/extensions/tps/resource/tps.jsm @@ -130,7 +130,7 @@ var TPS = { _tabsFinished: 0, _test: null, _triggeredSync: false, - _usSinceEpoch: 0, + _msSinceEpoch: 0, _requestedQuit: false, shouldValidateAddons: false, shouldValidateBookmarks: false, @@ -377,7 +377,7 @@ var TPS = { for (let datum of data) { Logger.logInfo("executing action " + action.toUpperCase() + " on form entry " + JSON.stringify(datum)); - let formdata = new FormData(datum, this._usSinceEpoch); + let formdata = new FormData(datum, this._msSinceEpoch); switch (action) { case ACTION_ADD: await formdata.Create(); @@ -409,17 +409,17 @@ var TPS = { " on history entry " + entryString); switch (action) { case ACTION_ADD: - await HistoryEntry.Add(entry, this._usSinceEpoch); + await HistoryEntry.Add(entry, this._msSinceEpoch); break; case ACTION_DELETE: - await HistoryEntry.Delete(entry, this._usSinceEpoch); + await HistoryEntry.Delete(entry, this._msSinceEpoch); break; case ACTION_VERIFY: - Logger.AssertTrue((await HistoryEntry.Find(entry, this._usSinceEpoch)), + Logger.AssertTrue((await HistoryEntry.Find(entry, this._msSinceEpoch)), "Uri visits not found in history database: " + entryString); break; case ACTION_VERIFY_NOT: - Logger.AssertTrue(!(await HistoryEntry.Find(entry, this._usSinceEpoch)), + Logger.AssertTrue(!(await HistoryEntry.Find(entry, this._msSinceEpoch)), "Uri visits found in history database, but they shouldn't be: " + entryString); break; default: @@ -818,7 +818,7 @@ var TPS = { // Places dislikes it if we add visits in the future. We pretend the // real time is 1 minute ago to avoid issues caused by places using a // different clock than the one that set the seconds_since_epoch pref. - this._usSinceEpoch = (this.seconds_since_epoch - 60) * 1000 * 1000; + this._msSinceEpoch = (this.seconds_since_epoch - 60) * 1000; } else { this.DumpError("seconds-since-epoch not set"); return;