merge upstream changes
authorDan Mills <thunder@mozilla.com>
Thu, 26 Jun 2008 16:38:00 -0700
changeset 44782 69a9be37804d07fb26e84b533e2714769ebc6095
parent 44781 7a757923e07af6978411193a676b64354672db2b (current diff)
parent 44780 5256cb9e1cb4cbc981c06cea13ee1dcb69f1a607 (diff)
child 44783 6b9b62796296e89cae7d8f96dc3337fcc5a40287
child 44788 fe37a870f262c2b397da5c28d5707e4ac65b4c9b
child 44792 b7e38d8492281fb6f06ba52e6cd38355f1435a45
push idunknown
push userunknown
push dateunknown
merge upstream changes
--- a/services/sync/modules/stores.js
+++ b/services/sync/modules/stores.js
@@ -163,17 +163,18 @@ SnapshotStore.prototype = {
       // special-case guid changes
       let newGUID = command.data.GUID,
       oldGUID = command.GUID;
 
       this._data[newGUID] = this._data[oldGUID];
       delete this._data[oldGUID];
 
       for (let GUID in this._data) {
-        if (this._data[GUID].parentGUID == oldGUID)
+        if (("parentGUID" in this._data[GUID]) &&
+            (this._data[GUID].parentGUID == oldGUID))
           this._data[GUID].parentGUID = newGUID;
       }
     }
     for (let prop in command.data) {
       if (prop == "GUID")
         continue;
       this._data[command.GUID][prop] = command.data[prop];
     }
--- a/services/sync/tests/unit/test_bookmark_syncing.js
+++ b/services/sync/tests/unit/test_bookmark_syncing.js
@@ -69,17 +69,38 @@ function run_test() {
   let zoogleBm = bms.insertBookmark(bms.bookmarksMenuFolder,
                                     uri("http://www.zoogle.com"),
                                     -1,
                                     "Zoogle");
   bms.setItemGUID(zoogleBm, "zoogle-bookmark-guid");
 
   syncTesting.doSync("add bookmark on second computer and resync");
 
+  syncTesting.saveClientState("second computer");
+
   syncTesting.restoreClientState("first computer");
   syncTesting.doSync("re-sync on first computer");
 
+  let binkBm1 = bms.insertBookmark(bms.bookmarksMenuFolder,
+                                   uri("http://www.bink.com"),
+                                   -1,
+                                   "Bink");
+  bms.setItemGUID(binkBm1, "bink-bookmark-guid-1");
+
+  syncTesting.doSync("add bookmark 'bink' on first computer and resync");
+  syncTesting.restoreClientState("second computer");
+
+  let binkBm2 = bms.insertBookmark(bms.bookmarksMenuFolder,
+                                   uri("http://www.bink.com"),
+                                   -1,
+                                   "Bink");
+
+  bms.setItemGUID(binkBm2, "bink-bookmark-guid-2");
+
+  syncTesting.doSync("Manually add same bookmark 'bink', but with " +
+                     + "different GUID, to second computer and resync");
+
   // --------
   // Teardown
   // --------
 
   cleanUp();
 }
--- a/services/sync/tests/unit/test_bookmark_syncing.log.expected
+++ b/services/sync/tests/unit/test_bookmark_syncing.log.expected
@@ -258,11 +258,100 @@ Service.BStore	TRACE	Processing command:
 Service.BStore	DEBUG	 -> creating bookmark "Zoogle"
 Service.SnapStore	INFO	Saving snapshot to disk
 Testing	INFO	Opening 'weave/snapshots/bookmarks.json' for writing.
 Testing	INFO	Writing data to local file 'weave/snapshots/bookmarks.json': {"version":3,"GUID":"fake-guid-0","snapshot":{"yoogle-bookmark-guid":{"parentGUID":"menu","index":0,"type":"bookmark","title":"Yoogle","URI":"http://www.yoogle.com/","tags":[],"keyword":null},"boogle-bookmark-guid":{"parentGUID":"menu","index":1,"type":"bookmark","title":"Boogle","URI":"http://www.boogle.com/","tags":[],"keyword":null},"menu":{"type":"folder"},"toolbar":{"type":"folder"},"unfiled":{"type":"folder"},"zoogle-bookmark-guid":{"parentGUID":"menu","index":2,"type":"bookmark","title":"Zoogle","URI":"http://www.zoogle.com/","tags":[],"keyword":null}}}
 Service.BmkEngine	INFO	Actual changes for server: 0
 Service.BmkEngine	DEBUG	Actual changes for server: []
 Service.BmkEngine	INFO	Sync complete
 Testing	INFO	Step 're-sync on first computer' succeeded.
+Testing	INFO	-----------------------------------------
+Testing	INFO	Step 'add bookmark 'bink' on first computer and resync' starting.
+Testing	INFO	-----------------------------------------
+Testing	INFO	Opening 'weave/snapshots/bookmarks.json' for reading.
+Testing	INFO	Reading from stream.
+Service.SnapStore	INFO	Read saved snapshot from disk
+Service.BmkEngine	INFO	Beginning sync
+Testing	INFO	HTTP MKCOL on user-data/bookmarks/deltas
+Service.RemoteStore	DEBUG	Downloading status file
+Testing	INFO	HTTP GET from user-data/bookmarks/status.json, returning status 200
+Service.Resource	DEBUG	GET request successful
+Service.JsonFilter	DEBUG	Decoding JSON data
+Service.RemoteStore	DEBUG	Downloading status file... done
+Service.BmkEngine	INFO	Local snapshot version: 3
+Service.BmkEngine	INFO	Server maxVersion: 3
+Service.RemoteStore	DEBUG	Using last sync snapshot as server snapshot (snap version == max version)
+Service.RemoteStore	TRACE	Local snapshot version == server maxVersion
+Service.BmkEngine	INFO	Reconciling client/server updates
+Service.BMSync	DEBUG	Reconciling 1 against 0 commands
+Service.BmkEngine	INFO	Changes for client: 0
+Service.BmkEngine	INFO	Predicted changes for server: 1
+Service.BmkEngine	INFO	Client conflicts: 0
+Service.BmkEngine	INFO	Server conflicts: 0
+Service.BmkEngine	INFO	Actual changes for server: 1
+Service.BmkEngine	DEBUG	Actual changes for server: [{"action":"create","GUID":"bink-bookmark-guid-1","depth":1,"parents":["menu"],"data":{"parentGUID":"menu","index":3,"type":"bookmark","title":"Bink","URI":"http://www.bink.com/","tags":[],"keyword":null}}]
+Service.BmkEngine	INFO	Uploading changes to server
+Service.JsonFilter	DEBUG	Encoding data as JSON
+Service.CryptoFilter	DEBUG	Encrypting data
+Service.Crypto	DEBUG	NOT encrypting data
+Testing	INFO	HTTP PUT to user-data/bookmarks/deltas/4 with data: [{"action":"create","GUID":"bink-bookmark-guid-1","depth":1,"parents":["menu"],"data":{"parentGUID":"menu","index":3,"type":"bookmark","title":"Bink","URI":"http://www.bink.com/","tags":[],"keyword":null}}]
+Service.ResourceSet	DEBUG	PUT request successful
+Service.JsonFilter	DEBUG	Encoding data as JSON
+Testing	INFO	HTTP PUT to user-data/bookmarks/status.json with data: {"GUID":"fake-guid-0","formatVersion":2,"snapVersion":0,"maxVersion":4,"snapEncryption":"none","deltasEncryption":"none","itemCount":7}
+Service.Resource	DEBUG	PUT request successful
+Service.BmkEngine	INFO	Successfully updated deltas and status on server
+Service.SnapStore	INFO	Saving snapshot to disk
+Testing	INFO	Opening 'weave/snapshots/bookmarks.json' for writing.
+Testing	INFO	Writing data to local file 'weave/snapshots/bookmarks.json': {"version":4,"GUID":"fake-guid-0","snapshot":{"yoogle-bookmark-guid":{"parentGUID":"menu","index":0,"type":"bookmark","title":"Yoogle","URI":"http://www.yoogle.com/","tags":[],"keyword":null},"boogle-bookmark-guid":{"parentGUID":"menu","index":1,"type":"bookmark","title":"Boogle","URI":"http://www.boogle.com/","tags":[],"keyword":null},"zoogle-bookmark-guid":{"parentGUID":"menu","index":2,"type":"bookmark","title":"Zoogle","URI":"http://www.zoogle.com/","tags":[],"keyword":null},"bink-bookmark-guid-1":{"parentGUID":"menu","index":3,"type":"bookmark","title":"Bink","URI":"http://www.bink.com/","tags":[],"keyword":null},"menu":{"type":"folder"},"toolbar":{"type":"folder"},"unfiled":{"type":"folder"}}}
+Service.BmkEngine	INFO	Sync complete
+Testing	INFO	Step 'add bookmark 'bink' on first computer and resync' succeeded.
+Testing	INFO	-----------------------------------------
+Testing	INFO	Step 'restore client state of second computer' starting.
+Testing	INFO	-----------------------------------------
+Service.BStore	TRACE	Processing command: {"action":"create","GUID":"yoogle-bookmark-guid","depth":1,"parents":["menu"],"data":{"parentGUID":"menu","index":0,"type":"bookmark","title":"Yoogle","URI":"http://www.yoogle.com/","tags":[],"keyword":null}}
+Service.BStore	DEBUG	 -> creating bookmark "Yoogle"
+Service.BStore	TRACE	Processing command: {"action":"create","GUID":"boogle-bookmark-guid","depth":1,"parents":["menu"],"data":{"parentGUID":"menu","index":1,"type":"bookmark","title":"Boogle","URI":"http://www.boogle.com/","tags":[],"keyword":null}}
+Service.BStore	DEBUG	 -> creating bookmark "Boogle"
+Service.BStore	TRACE	Processing command: {"action":"create","GUID":"zoogle-bookmark-guid","depth":1,"parents":["menu"],"data":{"parentGUID":"menu","index":2,"type":"bookmark","title":"Zoogle","URI":"http://www.zoogle.com/","tags":[],"keyword":null}}
+Service.BStore	DEBUG	 -> creating bookmark "Zoogle"
+Testing	INFO	Step 'restore client state of second computer' succeeded.
+Testing	INFO	-----------------------------------------
+Testing	INFO	Step 'Manually add same bookmark 'bink', but with NaN' starting.
+Testing	INFO	-----------------------------------------
+Testing	INFO	Opening 'weave/snapshots/bookmarks.json' for reading.
+Testing	INFO	Reading from stream.
+Service.SnapStore	INFO	Read saved snapshot from disk
+Service.BmkEngine	INFO	Beginning sync
+Testing	INFO	HTTP MKCOL on user-data/bookmarks/deltas
+Service.RemoteStore	DEBUG	Downloading status file
+Testing	INFO	HTTP GET from user-data/bookmarks/status.json, returning status 200
+Service.Resource	DEBUG	GET request successful
+Service.JsonFilter	DEBUG	Decoding JSON data
+Service.RemoteStore	DEBUG	Downloading status file... done
+Service.BmkEngine	INFO	Local snapshot version: 3
+Service.BmkEngine	INFO	Server maxVersion: 4
+Service.RemoteStore	DEBUG	Using last sync snapshot as starting point for server snapshot
+Service.RemoteStore	INFO	Downloading server deltas
+Testing	INFO	HTTP GET from user-data/bookmarks/deltas/4, returning status 200
+Service.ResourceSet	DEBUG	GET request successful
+Service.CryptoFilter	DEBUG	Decrypting data
+Service.Crypto	DEBUG	NOT decrypting data
+Service.JsonFilter	DEBUG	Decoding JSON data
+Service.SnapStore	TRACE	Processing command: {"action":"create","GUID":"bink-bookmark-guid-1","depth":1,"parents":["menu"],"data":{"parentGUID":"menu","index":3,"type":"bookmark","title":"Bink","URI":"http://www.bink.com/","tags":[],"keyword":null}}
+Service.BmkEngine	INFO	Reconciling client/server updates
+Service.BMSync	DEBUG	Reconciling 1 against 1 commands
+Service.BmkEngine	INFO	Changes for client: 1
+Service.BmkEngine	INFO	Predicted changes for server: 0
+Service.BmkEngine	INFO	Client conflicts: 0
+Service.BmkEngine	INFO	Server conflicts: 0
+Service.BmkEngine	INFO	Applying changes locally
+Service.SnapStore	TRACE	Processing command: {"action":"edit","GUID":"bink-bookmark-guid-2","data":{"GUID":"bink-bookmark-guid-1"}}
+Service.BStore	TRACE	Processing command: {"action":"edit","GUID":"bink-bookmark-guid-2","data":{"GUID":"bink-bookmark-guid-1"}}
+Service.SnapStore	INFO	Saving snapshot to disk
+Testing	INFO	Opening 'weave/snapshots/bookmarks.json' for writing.
+Testing	INFO	Writing data to local file 'weave/snapshots/bookmarks.json': {"version":4,"GUID":"fake-guid-0","snapshot":{"yoogle-bookmark-guid":{"parentGUID":"menu","index":0,"type":"bookmark","title":"Yoogle","URI":"http://www.yoogle.com/","tags":[],"keyword":null},"boogle-bookmark-guid":{"parentGUID":"menu","index":1,"type":"bookmark","title":"Boogle","URI":"http://www.boogle.com/","tags":[],"keyword":null},"zoogle-bookmark-guid":{"parentGUID":"menu","index":2,"type":"bookmark","title":"Zoogle","URI":"http://www.zoogle.com/","tags":[],"keyword":null},"menu":{"type":"folder"},"toolbar":{"type":"folder"},"unfiled":{"type":"folder"},"bink-bookmark-guid-1":{"parentGUID":"menu","index":3,"type":"bookmark","title":"Bink","URI":"http://www.bink.com/","tags":[],"keyword":null}}}
+Service.BmkEngine	INFO	Actual changes for server: 0
+Service.BmkEngine	DEBUG	Actual changes for server: []
+Service.BmkEngine	INFO	Sync complete
+Testing	INFO	Step 'Manually add same bookmark 'bink', but with NaN' succeeded.
 *** test finished
 *** exiting
 *** PASS ***