Bug 1321571 - ensureKeysFor_posts_new_keys pushes keys too many times, r=markh
authorEthan Glasser-Camp <eglassercamp@mozilla.com>
Wed, 28 Dec 2016 15:38:01 -0500
changeset 327853 418194476bdd131ddcb679b527a637045bcea933
parent 327852 b5af607d2990cbd7d1ddbad75b3d1b427f3ec34c
child 327854 567712330cde4a00ba08551b876584349300edd8
push id85304
push userphilringnalda@gmail.com
push dateWed, 04 Jan 2017 02:47:06 +0000
treeherdermozilla-inbound@6176579defcb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh
bugs1321571
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
toolkit/components/extensions/test/xpcshell/test_ext_storage_sync.js
--- 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}`);
     });
   });
 });