2010-12-06 15:51:38 -08:00
|
|
|
Cu.import("resource://services-sync/engines.js");
|
2010-08-06 08:31:21 -07:00
|
|
|
Cu.import("resource://services-sync/engines/bookmarks.js");
|
|
|
|
Cu.import("resource://services-sync/util.js");
|
|
|
|
|
|
|
|
function run_test() {
|
2010-12-06 15:51:38 -08:00
|
|
|
Engines.register(BookmarksEngine);
|
|
|
|
let engine = Engines.get("bookmarks");
|
2010-08-06 14:25:59 -07:00
|
|
|
engine._store.wipe();
|
|
|
|
|
2010-08-06 08:31:21 -07:00
|
|
|
_("Verify we've got an empty tracker to work with.");
|
2010-08-06 14:25:59 -07:00
|
|
|
let tracker = engine._tracker;
|
2010-08-06 08:31:21 -07:00
|
|
|
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
|
|
|
|
|
|
|
let folder = Svc.Bookmark.createFolder(Svc.Bookmark.bookmarksMenuFolder,
|
|
|
|
"Test Folder",
|
|
|
|
Svc.Bookmark.DEFAULT_INDEX);
|
|
|
|
function createBmk() {
|
|
|
|
Svc.Bookmark.insertBookmark(folder,
|
|
|
|
Utils.makeURI("http://getfirefox.com"),
|
|
|
|
Svc.Bookmark.DEFAULT_INDEX,
|
|
|
|
"Get Firefox!");
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
_("Create bookmark. Won't show because we haven't started tracking yet");
|
|
|
|
createBmk();
|
|
|
|
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
|
|
|
|
|
|
|
_("Tell the tracker to start tracking changes.");
|
|
|
|
Svc.Obs.notify("weave:engine:start-tracking");
|
|
|
|
createBmk();
|
2010-12-06 15:51:56 -08:00
|
|
|
// We expect two changed items because the containing folder
|
|
|
|
// changed as well (new child).
|
|
|
|
do_check_eq([id for (id in tracker.changedIDs)].length, 2);
|
2010-08-06 08:31:21 -07:00
|
|
|
|
|
|
|
_("Notifying twice won't do any harm.");
|
|
|
|
Svc.Obs.notify("weave:engine:start-tracking");
|
|
|
|
createBmk();
|
2010-12-06 15:51:56 -08:00
|
|
|
do_check_eq([id for (id in tracker.changedIDs)].length, 3);
|
2010-08-06 08:31:21 -07:00
|
|
|
|
|
|
|
_("Let's stop tracking again.");
|
|
|
|
tracker.clearChangedIDs();
|
|
|
|
Svc.Obs.notify("weave:engine:stop-tracking");
|
|
|
|
createBmk();
|
|
|
|
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
|
|
|
|
|
|
|
_("Notifying twice won't do any harm.");
|
|
|
|
Svc.Obs.notify("weave:engine:stop-tracking");
|
|
|
|
createBmk();
|
|
|
|
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
|
|
|
} finally {
|
|
|
|
_("Clean up.");
|
2010-08-06 14:25:59 -07:00
|
|
|
engine._store.wipe();
|
2010-08-06 08:31:21 -07:00
|
|
|
}
|
|
|
|
}
|