tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bookmark_decline_undecline.js (1446B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 const { Service } = ChromeUtils.importESModule(
      5  "resource://services-sync/service.sys.mjs"
      6 );
      7 
      8 // A stored reference to the collection won't be valid after disabling.
      9 function getBookmarkWBO(server, guid) {
     10  let coll = server.user("foo").collection("bookmarks");
     11  if (!coll) {
     12    return null;
     13  }
     14  return coll.wbo(guid);
     15 }
     16 
     17 add_task(async function test_decline_undecline() {
     18  let engine = Service.engineManager.get("bookmarks");
     19  let server = await serverForFoo(engine);
     20  await SyncTestingInfrastructure(server);
     21 
     22  try {
     23    let { guid: bzGuid } = await PlacesUtils.bookmarks.insert({
     24      parentGuid: PlacesUtils.bookmarks.menuGuid,
     25      url: "https://bugzilla.mozilla.org",
     26      index: PlacesUtils.bookmarks.DEFAULT_INDEX,
     27      title: "bugzilla",
     28    });
     29 
     30    ok(!getBookmarkWBO(server, bzGuid), "Shouldn't have been uploaded yet");
     31    await Service.sync();
     32    ok(getBookmarkWBO(server, bzGuid), "Should be present on server");
     33 
     34    engine.enabled = false;
     35    await Service.sync();
     36    ok(
     37      !getBookmarkWBO(server, bzGuid),
     38      "Shouldn't be present on server anymore"
     39    );
     40 
     41    engine.enabled = true;
     42    await Service.sync();
     43    ok(getBookmarkWBO(server, bzGuid), "Should be present on server again");
     44  } finally {
     45    await PlacesSyncUtils.bookmarks.reset();
     46    await promiseStopServer(server);
     47  }
     48 });