Bug 1389717 - Ensure `HistoryStore#changeItemID` waits for `fetchURLInfoForGuid`. r=tcsc
MozReview-Commit-ID: CAVdgurQxPj
--- a/services/sync/modules/engines/history.js
+++ b/services/sync/modules/engines/history.js
@@ -153,17 +153,21 @@ HistoryStore.prototype = {
return this.setGUID(uri);
}
// If the URI doesn't have a GUID and we didn't create one for it.
return null;
},
async changeItemID(oldID, newID) {
- this.setGUID(await PlacesSyncUtils.history.fetchURLInfoForGuid(oldID).url, newID);
+ let info = await PlacesSyncUtils.history.fetchURLInfoForGuid(oldID);
+ if (!info) {
+ throw new Error(`Can't change ID for nonexistent history entry ${oldID}`);
+ }
+ this.setGUID(info.url, newID);
},
async getAllIDs() {
let urls = await PlacesSyncUtils.history.getAllURLs({ since: new Date((Date.now() - THIRTY_DAYS_IN_MS)), limit: MAX_HISTORY_UPLOAD });
let urlsByGUID = {};
for (let url of urls) {
let guid = await this.GUIDForUri(url, true);