mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 10:45:42 +00:00
084907c53f
Save the time the tracker adds a new changed id and use that to compare the age of the record on the server vs the age of the local change to decide if it's server wins or client wins. Fix up various direct uses of changedIDs to use the API and make the save-to-disk lazy to avoid excessive writes. Add a test to make sure addChangedID only increases in time.
26 lines
696 B
JavaScript
26 lines
696 B
JavaScript
Cu.import("resource://weave/trackers.js");
|
|
|
|
function run_test() {
|
|
let tracker = new Tracker();
|
|
let id = "the_id!";
|
|
|
|
_("Make sure nothing exists yet..");
|
|
do_check_eq(tracker.changedIDs[id], null);
|
|
|
|
_("Make sure adding of time 0 works");
|
|
tracker.addChangedID(id, 0);
|
|
do_check_eq(tracker.changedIDs[id], 0);
|
|
|
|
_("A newer time will replace the old 0");
|
|
tracker.addChangedID(id, 10);
|
|
do_check_eq(tracker.changedIDs[id], 10);
|
|
|
|
_("An older time will not replace the newer 10");
|
|
tracker.addChangedID(id, 5);
|
|
do_check_eq(tracker.changedIDs[id], 10);
|
|
|
|
_("Adding without time defaults to current time");
|
|
tracker.addChangedID(id);
|
|
do_check_true(tracker.changedIDs[id] > 10);
|
|
}
|