Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 Cu.import("resource://gre/modules/Log.jsm");
5 Cu.import("resource://services-sync/engines/forms.js");
6 Cu.import("resource://services-sync/service.js");
7 Cu.import("resource://services-sync/util.js");
9 function run_test() {
10 _("Verify we've got an empty tracker to work with.");
11 let engine = new FormEngine(Service);
12 let tracker = engine._tracker;
13 // Don't do asynchronous writes.
14 tracker.persistChangedIDs = false;
16 do_check_empty(tracker.changedIDs);
17 Log.repository.rootLogger.addAppender(new Log.DumpAppender());
19 function addEntry(name, value) {
20 engine._store.create({name: name, value: value});
21 }
22 function removeEntry(name, value) {
23 guid = engine._findDupe({name: name, value: value});
24 engine._store.remove({id: guid});
25 }
27 try {
28 _("Create an entry. Won't show because we haven't started tracking yet");
29 addEntry("name", "John Doe");
30 do_check_empty(tracker.changedIDs);
32 _("Tell the tracker to start tracking changes.");
33 Svc.Obs.notify("weave:engine:start-tracking");
34 removeEntry("name", "John Doe");
35 addEntry("email", "john@doe.com");
36 do_check_attribute_count(tracker.changedIDs, 2);
38 _("Notifying twice won't do any harm.");
39 Svc.Obs.notify("weave:engine:start-tracking");
40 addEntry("address", "Memory Lane");
41 do_check_attribute_count(tracker.changedIDs, 3);
43 _("Let's stop tracking again.");
44 tracker.clearChangedIDs();
45 Svc.Obs.notify("weave:engine:stop-tracking");
46 removeEntry("address", "Memory Lane");
47 do_check_empty(tracker.changedIDs);
49 _("Notifying twice won't do any harm.");
50 Svc.Obs.notify("weave:engine:stop-tracking");
51 removeEntry("email", "john@doe.com");
52 do_check_empty(tracker.changedIDs);
54 } finally {
55 _("Clean up.");
56 engine._store.wipe();
57 }
58 }