Bug 1321571 - ensureKeysFor_posts_new_keys pushes keys too many times, r?markh
The kinto.js library assumes that all records coming from the server
will have a last_modified date, and copy it before checking for
equality. That date was missing here because I mocked a fake Kinto
server, so the code to check that the conflict was resolved
successfully got confused.
MozReview-Commit-ID: G4MAIAv1fJf
--- a/toolkit/components/extensions/test/xpcshell/test_ext_storage_sync.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_storage_sync.js
@@ -491,29 +491,26 @@ add_task(function* ensureKeysFor_posts_n
assertPostedNewRecord(post);
const body = yield assertPostedEncryptedKeys(post);
ok(body.keys.collections[extensionId], `keys object should have a key for ${extensionId}`);
// Try adding another key to make sure that the first post was
// OK, even on a new profile.
yield cryptoCollection._clear();
server.clearPosts();
- // Restore the first posted keyring
- server.addRecordInPast("storage-sync-crypto", post.body.data);
+ // Restore the first posted keyring, but add a last_modified date
+ const firstPostedKeyring = Object.assign({}, post.body.data, {last_modified: server.etag});
+ server.addRecordInPast("storage-sync-crypto", firstPostedKeyring);
const extensionId2 = uuid();
newKeys = yield ExtensionStorageSync.ensureKeysFor([extensionId2]);
ok(newKeys.hasKeysFor([extensionId]), `didn't forget key for ${extensionId}`);
ok(newKeys.hasKeysFor([extensionId2]), `new key generated for ${extensionId2}`);
posts = server.getPosts();
- // FIXME: some kind of bug where we try to repush the
- // server_wins version multiple times in a single sync. We
- // actually push 5 times as of this writing.
- // See bug 1321571.
- // equal(posts.length, 1);
+ equal(posts.length, 1);
const newPost = posts[posts.length - 1];
const newBody = yield assertPostedEncryptedKeys(newPost);
ok(newBody.keys.collections[extensionId], `keys object should have a key for ${extensionId}`);
ok(newBody.keys.collections[extensionId2], `keys object should have a key for ${extensionId2}`);
});
});
});