Bug 890217 - Add a test for syncing IMAP URLs. r?tcsc draft
authorKit Cambridge <kit@yakshaving.ninja>
Fri, 20 Oct 2017 08:55:52 -0700
changeset 684068 6225ecdb080fbf23d6b128262f877b3a7d29b792
parent 682898 a04860cd9c8895aaaadaa32efec5e8b2cdcd24e8
child 736798 0c358c1892f7277b77192c204866dc71bb15a393
push id85539
push userbmo:kit@mozilla.com
push dateFri, 20 Oct 2017 18:37:10 +0000
reviewerstcsc
bugs890217
milestone58.0a1
Bug 890217 - Add a test for syncing IMAP URLs. r?tcsc MozReview-Commit-ID: KBVInzYk1Rr
services/sync/tests/unit/test_bookmark_engine.js
--- a/services/sync/tests/unit/test_bookmark_engine.js
+++ b/services/sync/tests/unit/test_bookmark_engine.js
@@ -786,8 +786,71 @@ add_task(async function test_sync_dateAd
   } finally {
     await store.wipe();
     Svc.Prefs.resetBranch("");
     Service.recordManager.clearCache();
     await PlacesSyncUtils.bookmarks.reset();
     await promiseStopServer(server);
   }
 });
+
+// Bug 890217.
+add_task(async function test_sync_imap_URLs() {
+  await Service.recordManager.clearCache();
+  await PlacesSyncUtils.bookmarks.reset();
+  let engine = new BookmarksEngine(Service);
+  await engine.initialize();
+  let store  = engine._store;
+  let server = await serverForFoo(engine);
+  await SyncTestingInfrastructure(server);
+
+  let collection = server.user("foo").collection("bookmarks");
+
+  Svc.Obs.notify("weave:engine:start-tracking");   // We skip usual startup...
+
+  try {
+    collection.insert("menu", encryptPayload({
+      id: "menu",
+      type: "folder",
+      parentid: "places",
+      title: "Bookmarks Menu",
+      children: ["bookmarkAAAA"],
+    }));
+    collection.insert("bookmarkAAAA", encryptPayload({
+      id: "bookmarkAAAA",
+      type: "bookmark",
+      parentid: "menu",
+      bmkUri: "imap://vs@eleven.vs.solnicky.cz:993/fetch%3EUID%3E/" +
+              "INBOX%3E56291?part=1.2&type=image/jpeg&filename=" +
+              "invalidazPrahy.jpg",
+      title: "invalidazPrahy.jpg (JPEG Image, 1280x1024 pixels) - Scaled (71%)",
+    }));
+
+    await PlacesUtils.bookmarks.insert({
+      guid: "bookmarkBBBB",
+      parentGuid: PlacesUtils.bookmarks.toolbarGuid,
+      url: "imap://eleven.vs.solnicky.cz:993/fetch%3EUID%3E/" +
+           "CURRENT%3E2433?part=1.2&type=text/html&filename=TomEdwards.html",
+      title: "TomEdwards.html",
+    });
+
+    await sync_engine_and_validate_telem(engine, false);
+
+    let aInfo = await PlacesUtils.bookmarks.fetch("bookmarkAAAA");
+    equal(aInfo.url.href, "imap://vs@eleven.vs.solnicky.cz:993/" +
+      "fetch%3EUID%3E/INBOX%3E56291?part=1.2&type=image/jpeg&filename=" +
+      "invalidazPrahy.jpg",
+      "Remote bookmark A with IMAP URL should exist locally");
+
+    let bPayload = JSON.parse(JSON.parse(
+      collection.payload("bookmarkBBBB")).ciphertext);
+    equal(bPayload.bmkUri, "imap://eleven.vs.solnicky.cz:993/" +
+      "fetch%3EUID%3E/CURRENT%3E2433?part=1.2&type=text/html&filename=" +
+      "TomEdwards.html",
+      "Local bookmark B with IMAP URL should exist remotely");
+  } finally {
+    await store.wipe();
+    Svc.Prefs.resetBranch("");
+    Service.recordManager.clearCache();
+    await PlacesSyncUtils.bookmarks.reset();
+    await promiseStopServer(server);
+  }
+});